Hi guys, I have uploaded the program below on to a Arduino Uno and it works fine, however, I have uploaded the same program to an Arduino Nano 3.0 Atmel ATmega328 Mini and although it works initially whenever the button is pressed, if left standing for minutes or so it stops working. If the button is pressed Led#1 flashes briefly and nothing else happens. If I disconnect the power and reconnect the power it works fine until it is left standing again. Any help would be greatly appreciated. Many thanks
Dave
[cpp int switchpin = 11; // pin 11 connected to switch int timer = 2000; // The higher the number, the slower the timing. int timer2 = 500; int timer3 = 4000; int thisPin; int allpin2 = 2; int allpin3 = 3; int allpin4 = 4; int allpin5 = 5; int allpin6 = 6; int allpin7 = 7; int allpin8 = 8; void setup() { // set up digital pin read for switch // for loop need this ---> { } for (int thisPin = 2; thisPin < 9; thisPin++) { // this will set pin 2 to pin 8 as output pinMode(thisPin, OUTPUT); } // use a for loop to initialize each pin as an output: pinMode(switchpin, INPUT); } void loop() { // I prefer you hook up like +5 V --- Resistor -- pin 11 --- push button --- GND // when the switch is press ... it will produce a LOW - 0 - 0 V signal if (digitalRead(switchpin) == LOW) { // you forgot the { } delay(100); // debounce time for (int thisPin = 2; thisPin < 9; thisPin++) { // loop from the lowest pin to the highest: // turn the pin on digitalWrite(thisPin, HIGH); delay(timer); // turn the pin off: digitalWrite(thisPin, LOW); } // end of loop one // loop from the highest pin to the lowest: { // turn the pin on: digitalWrite(allpin2, HIGH); digitalWrite(allpin3, HIGH); digitalWrite(allpin4, HIGH); digitalWrite(allpin5, HIGH); digitalWrite(allpin6, HIGH); digitalWrite(allpin7, HIGH); digitalWrite(allpin8, HIGH); delay(timer3); digitalWrite(allpin2, LOW); digitalWrite(allpin3, LOW); digitalWrite(allpin4, LOW); digitalWrite(allpin5, LOW); digitalWrite(allpin6, LOW); digitalWrite(allpin7, LOW); digitalWrite(allpin8, LOW); } // end of loop 2 } // closing the if () stament } ](https://```cpp int switchpin = 11; // pin 11 connected to switch int timer = 2000; // The higher the number, the slower the timing. int timer2 = 500; int timer3 = 4000; int thisPin; int allpin2 = 2; int allpin3 = 3; int allpin4 = 4; int allpin5 = 5; int allpin6 = 6; int allpin7 = 7; int allpin8 = 8; void setup() { // set up digital pin read for switch // for loop need this ---> { } for (int thisPin = 2; thisPin < 9; thisPin++) { // this will set pin 2 to pin 8 as output pinMode(thisPin, OUTPUT); } // use a for loop to initialize each pin as an output: pinMode(switchpin, INPUT); } void loop() { // I prefer you hook up like +5 V --- Resistor -- pin 11 --- push button --- GND // when the switch is press ... it will produce a LOW - 0 - 0 V signal if (digitalRead(switchpin) == LOW) { // you forgot the { } delay(100); // debounce time for (int thisPin = 2; thisPin < 9; thisPin++) { // loop from the lowest pin to the highest: // turn the pin on digitalWrite(thisPin, HIGH); delay(timer); // turn the pin off: digitalWrite(thisPin, LOW); } // end of loop one // loop from the highest pin to the lowest: { // turn the pin on: digitalWrite(allpin2, HIGH); digitalWrite(allpin3, HIGH); digitalWrite(allpin4, HIGH); digitalWrite(allpin5, HIGH); digitalWrite(allpin6, HIGH); digitalWrite(allpin7, HIGH); digitalWrite(allpin8, HIGH); delay(timer3); digitalWrite(allpin2, LOW); digitalWrite(allpin3, LOW); digitalWrite(allpin4, LOW); digitalWrite(allpin5, LOW); digitalWrite(allpin6, LOW); digitalWrite(allpin7, LOW); digitalWrite(allpin8, LOW); } // end of loop 2 } // closing the if () stament } ```)
