Error with updated code, Original Code not working either

Hello,

I am trying to update a code of mines, and when I uploaded the new code, everything stopped working and was getting this error:

avrdude: stk500_paged_write(): (a) protocol error, expect=0x14, resp=0x00
avrdude: stk500_cmd(): programmer is out of sync
avrdude: stk500_cmd(): programmer is out of sync
avrdude: stk500_cmd(): programmer is out of sync
avrdude: stk500_cmd(): programmer is out of sync
avrdude: stk500_cmd(): programmer is out of sync
avrdude: stk500_cmd(): programmer is out of sync
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_recv(): programmer is not responding

I am attaching the code below: (Side note: when I try to upload the original code, nothing works as well but there's no error code?)

#include <IRremote.h>

int receiver = 13; // Signal Pin of IR receiver to Arduino Digital Pin 6

IRrecv irrecv(receiver);    // create instance of 'irrecv'
decode_results results;     // create instance of 'decode_results'
uint32_t hexVal = 0;

int dirPin = 2;
int stepPin = 3;

bool stop = true;
float speedRPM = 5.0; // the speed of rotation. Optomotor experiments often use around 2-4 RPM
int dir = -1; // initial direction: -1 = clockwise, 1 = anticlockwise

void setup() {

  Serial.begin(9600);
  
  Serial.println("Initialised"); 
  irrecv.enableIRIn(); // Start the receiver

  pinMode(dirPin,OUTPUT);
  pinMode(stepPin,OUTPUT);
  digitalWrite(dirPin,LOW);
}

void loop() {
  //stop = false;
  //speedRPM = 9;

  if (irrecv.decode(&results)){ // have we received an IR signal?

    hexVal = results.value;
    Serial.print("IR Value = ");
    Serial.println(hexVal, HEX);
    switch(hexVal){

      case 0xFFA25D: // power - stop everything!
          if (stop){
            stop = false;
            Serial.println("Start");
          }
          else{
            stop = true;
            Serial.println("Stop");
          };

      break;

      case 0xFF02FD: // play/pause - switch direction manually
          if (dir == 1){
            dir = -1;
            digitalWrite(dirPin,LOW);
          }
          else{
            dir = 1;
            digitalWrite(dirPin,HIGH);
          };
      break;

      case 0xFF906F: // up
         digitalWrite(dirPin,LOW);
      break;

      case 0xFFE01F: // down
         digitalWrite(dirPin,HIGH);
      break;

      case 0xFF30CF: // 1
         speedRPM = 1.0;
      break;
      
      case 0xFF18E7: // 2
         speedRPM = 2.0;
      break;

      case 0xFF7A85: // 3
         speedRPM = 3.0;
      break;
      
      case 0xFF10EF: // 4
         speedRPM = 4.0;
      break;
      
      case 0xFF38C7: // 5
         speedRPM = 5.0;
      break;
      
      case 0xFF5AA5: // 6
         speedRPM = 6.0;
      break;

      case 0xFF42BD: // 7
         speedRPM = 7.0;
      break;
      
      case 0xFF4AB5: // 8
         speedRPM = 8.0;
      break;

      case 0xFF52AD: // 9
         speedRPM = 9.0;
      break;
      
      case 0xFF6897: // 0
         speedRPM = 10.0;
      break;
      
    }
    irrecv.resume(); // receive the next value
  }

if (!stop){
    //Serial.print("Running at ");
    //Serial.println(speedRPM);

    //for(int i=0; i<800; i++){
      digitalWrite(stepPin,HIGH);
      delayMicroseconds(8000/speedRPM);
      digitalWrite(stepPin,LOW);
      delayMicroseconds(8000/speedRPM);
      //if (irrecv.decode(&results)){
      //  hexVal = results.value;
      //}
    //}
}
else{
  //if (irrecv.decode(&results)){
  //  hexVal = results.value;
  //}
}




}

Hi,
What version IDE are you using?
What model Arduino are you using?

Can you upload the "Blink without Delay" code in the IDE examples?

Thanks.. Tom.. :grinning: :+1: :coffee: :australia:

Make sure you have selected the right Arduino board before uploading your sketch

Hi, I am using IDE Version 2.2.1 and the Model is Arduino Uno?

I am not sure how to post the code with blink without delay. Sorry, first time ever using this software, and all i was shown was how to upload a code into the device .

I double checked and its the right board, thanks for the reminder.

That was not the question :wink: The question is if you can upload the blink-without-delay example that comes with the IDE; or any standard example that comes with the IDE for that matter. Do you get the same error message.

Does the question mark indicate that you don't know which board you are using?

Disconnect evevrything from the board and try to upload a standard example?

Some questions

  1. Which operating system?
  2. What is the serial-to-usb converter on your board; it's the ic closest to the USB port.
  3. If the board does not use the CH340 serial-to-usb converter, what are the results of the loopback test?