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;
//}
}
}