I'm having a syntax issue that I don't quite understand. I have two pieces of code: one works and one doesn't. I can't figure out why.
The first piece of code, which is how I originally wrote it, is as follows:
Code: Select all
void setup() {
// put your setup code here, to run once:
int relay1=2;
pinMode(relay1, OUTPUT);
digitalWrite(relay1, HIGH);
}
void loop() {
delay(1000);
digitalWrite(relay1, LOW);
delay(1000);
digitalWrite(relay1, HIGH);
}
So, I changed the code to this:
Code: Select all
void setup() {
// put your setup code here, to run once:
int relay1=2;
pinMode(relay1, OUTPUT);
digitalWrite(relay1, HIGH);
}
void loop() {
delay(1000);
digitalWrite(2, LOW);
delay(1000);
digitalWrite(2, HIGH);
}