Control Delay with Buttons

Hello

I have programmed an Arduino that plays a minigame on the mobile phone with a servo and a light sensor. The game is like a jump and run where there is always a gap and then he has to jump. Unfortunately the game is getting faster and faster and I have to push the light sensor forward. Since this is very risky, I ask here if you can do 2 buttons that, for example, + 0.05s and -0.05s. so I don't have to move the light sensor but can just press the buttons to adjust.

Hallo

Ich habe einen Arduino Programmiert der mit einem Servo und einem Lichtsensor ein minigame auf dem Handy spielt. Das Spiel ist wie ein Jump and Run wo immer eine Lücke kommt und er dann springen muss. Leider wird das Spiel immer schneller heißt ich muss den Lichtsensor nach vorne schieben. Da das sehr riskant ist, frage ich hier ob man mir 2 Knöpfen die zum Beispiel +0.05s und -0.05s machen. so muss ich nicht den Lichtsensor verschieben sondern kann zum justieren nur die Knöpfe drücken.

Code:

#include <Servo.h>
int licht; // light

Servo servoblau; // sero blue

void setup() {
Serial.begin(9600);
servoblau.attach(8); // servo on pin 8
}

void loop() {
licht = analogRead(0); // light on pin A0
Serial.println(licht);

if(licht > 710) { // when the gap comes, it jumps
servoblau.write(30);
}
else {
servoblau.write(50); //

}

}

Your code doesn't seem to have any delays.

This topic was automatically closed 120 days after the last reply. New replies are no longer allowed.