Hello, I am completely new to coding. I chose this medium as a way to learn.
I am currently working with the Learn Arduino Basics kit, with the UNO R3 Plus board. I am working on the second tutorial in that kit 'controlling digital outputs'.
I am writing the code manually into my sketch from the book, and from what I can observe, I have done so with complete fidelity, and yet I receive LED0 not declared error. Exit status 1 - which from what I read means nothing compiled. This is after doing the 'verify' function. Here is what I have written:
void setup() {
// put your setup code here, to run once:
pinMode(LED0,OUTPUT);
pinMode(LED1,OUTPUT);
pinMode(LED2,OUTPUT);
pinMode(LED3,OUTPUT);
}
Thanks for the help.
Try variable declaration before setup method. You have to assign the pin number to those variables LED0, LED1,...
As an example:
int LED0 = 2;
int LED1 = 4;
int LED2 = 7;
int LED3 = 8;
void setup() {
// put your setup code here, to run once:
pinMode(LED0,OUTPUT);
pinMode(LED1,OUTPUT);
pinMode(LED2,OUTPUT);
pinMode(LED3,OUTPUT);
}
Hopefully it helps
Oh man. LOL. Worked. I tend to learn best by making silly little mistakes, anyway. Thanks for the help.
I am writing the code manually into my sketch from the book,
Is the code wrong in the book or did you not copy it correctly ?
I did not copy the int groups into my original code. It was in // and outside of the void setup and void loop functions, so I assumed it was just notes. My mistake. First code I have written. Book was ok. This is what I have now.
int LED0 = 2;
int LED1 = 3;
int LED2 = 4;
int LED3 = 5;
void setup() {
// put your setup code here, to run once:
pinMode(LED0,OUTPUT);
pinMode(LED1,OUTPUT);
pinMode(LED2,OUTPUT);
pinMode(LED3,OUTPUT);
}
void loop() {
// put your main code here, to run repeatedly:
digitalWrite(LED0, HIGH);
delay(500);
digitalWrite(LED0, LOW);
delay(500);
digitalWrite(LED1, HIGH);
delay(500);
digitalWrite(LED1, LOW);
delay(500);
digitalWrite(LED2, HIGH);
delay(500);
digitalWrite(LED2, LOW);
delay(500);
digitalWrite(LED3, HIGH);
delay(500);
digitalWrite(LED3, LOW);
delay(500);
When you learn about arrays you will find that there is a much neater way to write this program, but at the moment the most important thing is that it works.