Hello,
I'm a newbe. I'm trying with very simple programs. When I try to upload this file my arduino freeze and I have to reset a lot of times before upload again a new program. It's only a test program that uses both a led and a servo.
If I remove the servo code lines it works perfectly.
The code is like this:
#include <Servo.h>
Servo myservo;
int ledPin = 13;
void setup() {
Serial.begin(9600);
pinMode(ledPin, OUTPUT);
myservo.attach(9);
}
void loop() {
while (Serial.available() == 0);
int val = Serial.read() - '0';
if (val == 1) {
Serial.println("Led is On");
digitalWrite(ledPin, HIGH);
} else if (val == 0) {
Serial.println("Led is Off");
digitalWrite(ledPin, LOW);
} else {
Serial.println("Move servo");
myservo.write(30);
}
}
what's wrong with that code?
Thank you.
Stefano.