As a nuby I"m trying to duplicate the coin toss program that Purdum has in his book. I am able to run his code using the following:
long randomNumber = 0L;<void loop() {>
randomNumber = generateRandomNumber();
When I try to duplicate this my program by cutting and pasting it to the same locations I get the error message. Why?
Here's my code:
#define IOPIN12 12
#define IOPIN13 13
int led1 = IOPIN12;
int led2 = IOPIN13;
long randomNumber = 0L;
void setup() {
randomSeed(analogRead(0));
pinMode(led1, OUTPUT);
pinMode(led2, OUTPUT);
}
void loop() {
long randomNumber = generateRandomNumber(); //This statement is highlighted and i receive error
//saying it's not declared in this scope. But it's in
// the same location as Purdum's.
digitalWrite(led1, LOW);
digitalWrite(led2, LOW);
if (randomNumber % 2 == 1) {
digitalWrite(led1, HIGH);
}else {
digitalWrite(led1, LOW);
delay(1000);
}
}
I run all my sketches on 1.0.5, if i try to run this on 1.6 it just says error compiling.
Thanks Bryan