Skip to content

Instantly share code, notes, and snippets.

@vortec
Created June 23, 2014 22:19
Show Gist options
  • Save vortec/3942925f2a86f1a8f560 to your computer and use it in GitHub Desktop.
Save vortec/3942925f2a86f1a8f560 to your computer and use it in GitHub Desktop.
int light;
int ledPin = 2;
int photoresistor = 0;
void setup()
{
//Serial.begin(9600);
pinMode(ledPin, OUTPUT);
analogWrite(ledPin, 0);
light = 50;
}
void loop()
{
/*light = analogRead(photoresistor);
light = constrain(light, 300, 1023);
light = map(light, 300, 1023, 0, 255);
analogWrite(ledPin, light);
Serial.println(light);*/
if (light == 255) {
light = 50;
analogWrite(ledPin, 0);
delay(750);
}
light = light + 1;
analogWrite(ledPin, light);
Serial.println(light);
delay(50);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment