Hi,
What is wrong with this? I am trying to avoid turning on and off the laser LED manually (which works). I am using pins 3 to 7
Thanks
int laserPin;
void setup() {
// put your setup code here, to run once:
// initialize serial communication:
Serial.begin(9600);
for(int x = 3; x < 8; x++) {
pinMode(laserPin, OUTPUT);
digitalWrite(laserPin, LOW);
}
}
void loop() {
// put your main code here, to run repeatedly:
for(int x = 3; x < 8; x++) {
laserPin = x;
digitalWrite(laserPin, LOW);
delay(500);
digitalWrite(laserPin, HIGH);
delay(1000);
}
}
As a first pass, you never use the x variable in the for loop in setup. Also, the line "laserPin = x;" is unnecessary. Also, you begin serial comms but never use it in the loop.
Also, you didn't post your code using code tags ;).