diff options
Diffstat (limited to 'main.ino')
-rw-r--r-- | main.ino | 8 |
1 files changed, 4 insertions, 4 deletions
@@ -85,7 +85,7 @@ ServoEasing servo; #define SERVO_POS_INIT 0 #define SERVO_POS_MAX 90 -int servo_should_move = 0; +volatile int pills_requested = 0; void setup() { Serial.begin(BAUDRATE); @@ -173,7 +173,7 @@ IRAM_ATTR // avoid crash e.g. when other code reads SD card void onButtonActionPressed() { Serial.println("button ACTION clicked"); led.fastBlinking(); - servo_should_move = 1; + pills_requested++; rolling_green(); } @@ -212,10 +212,10 @@ void printData() { // source: https://robojax.com/learn/arduino/?vid=robojax_Servo_PB1_move_return void servoLoop() { - if (servo_should_move == 1) { + if (pills_requested > 1) { servo.easeTo(SERVO_POS_MAX); delay(500); servo.easeTo(SERVO_POS_INIT); - servo_should_move = 0; + pills_requested--; } } |