The question as I'm learning this lesson of local scope, the goal is to print "2."
I got it happening, but I like to know why because an error happened beforehand because, in the lesson, he had "<" as you can see below the first code that no longer works, but in his lesson, it did. I read line for line to make sure I wasn't crazy. then check it again
/Users/nicolasganea/Documents/Arduino/Hackster Activity 27 Local scope ( not global )/Hackster Activity 27 Local scope ( not global ).ino: In function 'void loop()':
/Users/nicolasganea/Documents/Arduino/Hackster Activity 27 Local scope ( not global )/Hackster Activity 27 Local scope ( not global ).ino:14:14: error: expected primary-expression before '<' token
for ( a = 0; < 3; a++) {
^
Compilation error: Error: 2 UNKNOWN: exit status 1
this was the code that didn't work
Preformatted text
int i = 3;
void setup() {
// put your setup code here, to run once:
Serial.begin (9600);
//Serial.println(i);
}
void loop() {
// put your main code here, to run repeatedly:
int a = 0; // "a" is a "local variable"
//a++;
//Serial.println(a);
int b = 2; // How to fix the printing of just "1"
for ( a = 0; < 3; a++) {
Serial.println(b);
} // question why does < this no longer work?
delay(500);
}
Preformatted text
I experimented removing "<" it worked, allowing me to print "2" was there an update? if it was an update, is it faster to removing < less than? that's all that makes logical sense to me for such a thing I need to see the proof I don't like assumptions
Or maybe someone can see what I am not seeing.
(code that worked to printing 2)
Preformatted text
int i = 3;
void setup() {
// put your setup code here, to run once:
Serial.begin (9600);
//Serial.println(i);
}
void loop() {
// put your main code here, to run repeatedly:
int a = 0; // "a" is a "local variable"
//a++;
//Serial.println(a);
int b = 2; // How to fix the printing of just "1"
for ( a = 0; 3; a++) {
Serial.println(b);
} // question why does < this no longer work?
delay(500);
}Preformatted text
Thank you for your time