Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

new to Ardunio but trying to compile

Status
Not open for further replies.
As I already specified... If you are wishing MrDeb well in this C++ endeavor, Its a big leap and I applaud him for making the move..

If all you want todo is bring him down, then I will threadban the neigh sayers... Lets give our support... C and C++ isn't as forgiving as basic, so think before you post..
 
As I've specified and stated on many occasions, I believe MRDEB to be a troll and he's never denied it once. Now he has the moderators helping in his endeavours. I tried to help him about 10 years ago. His questions haven't changed in that time. I now stay away from his threads for this reason.

Mike.
 
FWIW, and I may be wrong, some_of_us are simply not wired for programming, no matter how hard we try, but others are.
Some of us are able to comprehend lefty-loosey and righty-tighty without a problem, design fantastic structures and products, produce polymers and chemicals that make all of our lives easier, or open up a body and fix it following an accident or illness...
What is easy for one, is not easy for all.
I would love to be proficient at programming, but it's not going to happen because I am much more inclined to solve mechanical problems, which are far easier to visualize to me.

We do and get paid for the things we are good at, and pay someone else to do the things we aren't.

Everything else we wish to try is a steep curve.
 
YES I know what a sub routine is, have used numerous times. Hoping the book "LEARN ARDUINO IN 24 HOURS" will get to that section soon. Still pondering with the IR remote code. Set up a SWITCH CASE routine and seems to work well but now I need the remote to "train" the UNO to remember the output from the remote then add several subroutines to the code.
 
lately having issues with the Arduino IDE locking up and after the ctr, alt, delete I end task and it shows "Java(TM) platform SE binary(32bit)
any thoughts as to why?
 
Musicmanager inquired about the ARDUINO PROGRAMMING IN 24 HOURS"
here is a list of the books I recently purchased. The first one is Arduino in 24 hours


 
this looks right but hangs up on line 40 a "printin statement? I corrected hopefully all the typos?
Code:
const int micPin = A0;          //MIC PORT
const int LedPin = LED_BUILTIN; //FLASH BUILT IN LED
const int numberOfSamples = 128; //NUMBER OF READINGS
const int middleValue = 512;    //MIDDLE OF RANGE

int sample;                     //VALUE FROM MIC
long Signal;                    //READING AFTER DC OFFSET
long newReading;                //AVERAGE OF LOOP READINGS

long runningAverage = 0;          //CACULATED VALUES
const int averagedOver = 16;    //HOW QUICK NEW VALUES AFFECT RUNNING AVG

const int threshold = 400;       //AT WHAT LEVEL LED COMES ON

void setup()
{
  pinMode(LedPin, OUTPUT);      //
  Serial.begin(9600);
}
// put your setup code here, to run once:


void loop()
{
  long sumOfSquares = 0;
  for (int I = 0; I < numberOfSamples; I++) { //average readings
    sample = analogRead(micPin);              //take a reading
    Signal = (sample - middleValue);
    Signal *= Signal;                         //SQUARE IT
    sumOfSquares += Signal;                   //add to the total
  }
  newReading = sumOfSquares / numberOfSamples;

  //caculate running average
  runningAverage = (((averagedOver - 1) * runningAverage) + newReading) / averagedOver;

  Serial.print("new:"); Serial.print(newReading);
  Serial.print(".");
  Serial.print("running:");
  Serial.printin(runningAverage);

  if (runningAverage > threshold) {           //is average more than threshold?
    digitalWrite(LedPin, HIGH);
  } else {
    digitalWrite(LedPin, LOW;
  }

}




// put your main code here, to run repeatedly:

}
 
this looks right but hangs up on line 40 a "printin statement? I corrected hopefully all the typos?

Except for that one !

It should read "println" ( lowercase l, not i ) at the moment it reads "printin" .. .. ..

MM
 
Ah ! I found a couple of others too .. .. this compiles OK, but you need to make sure you can see the differences .. OK ?

C:
const int micPin = A0;          //MIC PORT
const int LedPin = LED_BUILTIN; //FLASH BUILT IN LED
const int numberOfSamples = 128; //NUMBER OF READINGS
const int middleValue = 512;    //MIDDLE OF RANGE

int sample;                     //VALUE FROM MIC
long Signal;                    //READING AFTER DC OFFSET
long newReading;                //AVERAGE OF LOOP READINGS

long runningAverage = 0;          //CACULATED VALUES
const int averagedOver = 16;    //HOW QUICK NEW VALUES AFFECT RUNNING AVG

const int threshold = 400;       //AT WHAT LEVEL LED COMES ON

void setup()
{
  pinMode(LedPin, OUTPUT);      //
  Serial.begin(9600);
}
// put your setup code here, to run once:


void loop()
{
  long sumOfSquares = 0;
  for (int i = 0; i < numberOfSamples; i++) { //average readings .. .. .. .. ( NORMALLY I is lowercase )
    sample = analogRead(micPin);              //take a reading
    Signal = (sample - middleValue);
    Signal *= Signal;                         //SQUARE IT
    sumOfSquares += Signal;                   //add to the total
  }
  newReading = sumOfSquares / numberOfSamples;

  //caculate running average
  runningAverage = (((averagedOver - 1) * runningAverage) + newReading) / averagedOver;

  Serial.print("new:"); Serial.print(newReading);
  Serial.print(".");
  Serial.print("running:");
  Serial.println(runningAverage);

  if (runningAverage > threshold) {           //is average more than threshold?
    digitalWrite(LedPin, HIGH);
  } else {
    digitalWrite(LedPin, LOW);
  }
}

MM
 
Try to understand the words you are typing. They aren't random words. It should not take a genius to find and correct typos.

Println = Print L(i)n(e).

Println prints the text and starts a new line.

Print prints the text without advancing to a new line. Whatever is printed next will be printed on the same line without a break.
 
Also notice MM's code – it's color coded, as it will be in the Arduino editor. Command words show up as light blue. If a command doesn't show up that way, you have a typo.
 
You might want to try a dark theme for the Arduino IDE.

Dracula Theme is one example. It makes the color coding easier to see.

You can also turn on line numbers so it's easier to track down typos. In the IDE, look under Files/Preferences and click the box. Picture below.

ARDUINO DARK THEME.jpg



arduino line numbers.jpg
 
Last edited:
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top