| Electronics > Projects, Designs, and Technical Stuff |
| what am i doing wrong |
| (1/2) > >> |
| m3vuv:
Hi all im trying to switch 3 leds on in sequence but have it just do it once untill i reset the arduino,it gives errors when trying to compile,any ideas what im doing wrong and how to fix it?,im using an arduino uno,cheersd Paul m3vuv. int; int LED2 = 12; int LED3 = 11; void setup() { pinMode(LED1, OUTPUT); pinMode(LED2, OUTPUT); pinMode(LED3, OUTPUT); }digitalWrite(LED1, HIGH); // turn on LED1 delay(200); // wait for 200ms digitalWrite(LED2, HIGH); // turn on LED2 delay(200); // wait for 200ms digitalWrite(LED3, HIGH); // turn on LED3 delay(200); // wait for 200ms digitalWrite(LED1, LOW); // turn off LED1 delay(300); // wait for 300ms digitalWrite(LED2, LOW); // turn off LED2 delay(300); // wait for 300ms digitalWrite(LED3, LOW); // turn off LED3 delay(300); // } LED1 = 13 void loop() { |
| m3vuv:
sorry got it wrong,heres the original sketch,need it just to run 1 time until the uno is reset,any ideas? /* A simple program to sequentially turn on and turn off 3 LEDs */ int LED1 = 13; int LED2 = 12; int LED3 = 11; void setup() { pinMode(LED1, OUTPUT); pinMode(LED2, OUTPUT); pinMode(LED3, OUTPUT); } void loop() { digitalWrite(LED1, HIGH); // turn on LED1 delay(200); // wait for 200ms digitalWrite(LED2, HIGH); // turn on LED2 delay(200); // wait for 200ms digitalWrite(LED3, HIGH); // turn on LED3 delay(200); // wait for 200ms digitalWrite(LED1, LOW); // turn off LED1 delay(300); // wait for 300ms digitalWrite(LED2, LOW); // turn off LED2 delay(300); // wait for 300ms digitalWrite(LED3, LOW); // turn off LED3 delay(300); // wait for 300ms before running program all over again } |
| Dave:
Either move the whole code from loop() to the bottom of setup(), or put a while(1); to the bottom of the code inside loop(). |
| kosine:
Your sketch compiles fine, so if there's a problem uploading it's likely with the board setup. Could be the USB drivers, wrong serial port or wrong board selected. Try verifying the sketch before uploading it to make sure the code is OK. |
| m3vuv:
is there any way you could do it for me,i just seem to screw it up and then it wont compile,maybe if you can edit it i can cut and paste it ?cheers Paul m3vuv |
| Navigation |
| Message Index |
| Next page |