Go Down

Topic: Problem upload this program (Read 778 times) previous topic - next topic


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:

Code: [Select]

#include <Servo.h>
Servo myservo;
int ledPin = 13;

void setup() {
  pinMode(ledPin, OUTPUT);

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");

what's wrong with that code?

Thank you.


The code looks correct to me.  I can't think of a good reason why that particular code would prevent new sketches from loading.  Perhaps the auto-reset of your Arduino is not working properly.  What model Arduino is it?
Send Bitcoin tips to: 1G2qoGwMRXx8az71DVP1E81jShxtbSh5Hp


I have the arduino uno and I bought it 1 week ago!


I've read lots of mentions of some UNOs needing to have the firmware on the USB chip re-flashed because of USB problems.  Do a search for "DFU" to find out how to do that.
Send Bitcoin tips to: 1G2qoGwMRXx8az71DVP1E81jShxtbSh5Hp

Go Up