Skip to content

Instantly share code, notes, and snippets.

@nkymut
Created January 28, 2019 10:59
Show Gist options
  • Save nkymut/e9e1a70dc261470defe3b189ae38b12e to your computer and use it in GitHub Desktop.
Save nkymut/e9e1a70dc261470defe3b189ae38b12e to your computer and use it in GitHub Desktop.
/* Anti-PowerSave Light
rage against the stupid auto-turn off timer.
*/
#include <Servo.h>
Servo myservo; // create servo object to control a servo
// twelve servo objects can be created on most boards
float light = 0;
int lightOn = 0;
void setup() {
myservo.attach(9); // attaches the servo on pin 9 to the servo object
myservo.write(90);
delay(100);
myservo.detach();
Serial.begin(9600);
}
void pokeSwitch(){
myservo.attach(9);
myservo.write(60);
delay(100);
myservo.write(100);
delay(1000);
myservo.write(60);
delay(100);
myservo.detach();
lightOn = 3;
}
void loop() {
light = analogRead(0);
Serial.println(light);
if(light > 900 ){
lightOn--;
if(lightOn <= 0 ) pokeSwitch();
}else{
delay(1000);
}
delay(1000);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment