Skip to content

Commit

Permalink
upd
Browse files Browse the repository at this point in the history
  • Loading branch information
k0xxx committed Apr 20, 2022
1 parent 08e04f5 commit 93f0884
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ SimpleServo servoControl;
const int servoPin = 4; // Servo at Arduino digital
const int servoDefaultAngle = 0; // Servo default angle
const int servoTargetAngle = 120; // Servo target angle
int servoAngle = 0;
int servoTmpAngle = 0;
const int servoDelay = 500; // Servo delay time in ms

const int prPin = 5; // Photoresistor at Arduino analog pin A0
Expand All @@ -31,18 +33,16 @@ void loop() {
prValue = analogRead(prPin); // Read pResistor

if (prValue < prLaunch){
digitalWrite(0, HIGH);
digitalWrite(1, HIGH);

servoControl.write(servoTargetAngle);
delay(servoDelay);
servoAngle = servoTargetAngle;
} else {
digitalWrite(0, LOW);
digitalWrite(1, LOW);

servoControl.write(servoDefaultAngle);
delay(servoDelay);
servoAngle = servoDefaultAngle;
}

servoControl.write(servoAngle);
if(servoAngle != servoTmpAngle){
delay(servoDelay);
}
servoTmpAngle = servoAngle;

delay(1); // Idle
}

0 comments on commit 93f0884

Please sign in to comment.