Hey all,
I recently purchased 3 arduino nano clones and wanted make a simple test on the servo that I also just bought. I connected the servo to pin 10 and a button to pin 7, and when the button is pushed the servo moves 180 degrees, the program then delays for 2 seconds and resets the servo to 0 degrees . When I run the code it works fine, but if I push the button a second time before the servo resets to 0 it completely breaks the board. I managed to break 2 out of the 3 nano boards. On one board the tx, pow, and L LEDS stay lit and will give me problems when I try to upload code to it. On the other board just the power light stays on and all the pins get hot when connected to power. can someone please help me understand what I'm doing wrong so I don't break my last nano.
note: when I try this on my arduino mega it does not have this problem.
here is my code:
#include <Servo.h>
Servo myservo;
int button = 0;
void setup() {
// put your setup code here, to run once:
myservo.attach(10);//select servo pin(9 or 10, only to control two pins)
pinMode(7, INPUT);
pinMode(9, OUTPUT);
pinMode(22, OUTPUT);
pinMode(2, OUTPUT);
digitalWrite(2, HIGH);
Serial.begin(9600);
}
void loop() {
// put your main code here, to run repeatedly
button = digitalRead(7);
Serial.println(button);
if(button == 1)
{ digitalWrite(22, HIGH); //dc motor on
myservo.write(180);
delay(1000);
digitalWrite(22, LOW);//dc motor off
delay(1000);
}
else myservo.write(0);
}
note: Ignore anything done with pin 22 and 2 I used it to power a dc motor on the arduino mega, but was not connected when I broke the nano boards.