I wanted to try a low power sleeping feature by Rocketscream from his LowPower library. (here)
I uploaded my code without any interruption option (I know that was not smart).
Basically I can’t upload any new code to my Arduino Micro because it doesn’t allow a Serial connection as it’s sleeping all the time.
It’s only 1s of sleeping but it is run all the time again.
My question is whether I can interrupt this or if there is any possibilty of uploading new code to the board.
Any help appreciated!
Code:
#include <LowPower.h>
#define pinY 8
#define pinX 9
short valY;
short valX;
void setup() {
pinMode(pinX, INPUT);
pinMode(pinY, INPUT);
Serial.begin(9600);
}
void loop() {
valX = analogRead(pinX);
valY = analogRead(pinY);
byte shiftpos = shiftPosition();
Serial.println(shiftpos);
LowPower.powerDown(SLEEP_1S, ADC_OFF, BOD_OFF);
}
byte shiftPosition(){
if(valY < 100){
if(valX < 100){
return 1;
}
else if(valX > 100 && valX < 900){
return 3;
}
else{
return 5;
}
}
else if(valY > 900){
if(valX < 100){
return 2;
}
else if(valX > 100 && valX < 900){
return 4;
}
else{
return 6;
}
}
else{
return 0;
}
}