Skip to content

Instantly share code, notes, and snippets.

@zach-c-d
Created January 27, 2016 18:43
Show Gist options
  • Save zach-c-d/64ce17b2331cabd15d03 to your computer and use it in GitHub Desktop.
Save zach-c-d/64ce17b2331cabd15d03 to your computer and use it in GitHub Desktop.
//blink LED at rate specified by analog input from light resistor
int light_resistor = 0;
int LED = 13;
int i = 0; //level of resistance from light_resistor
void setup() {
Serial.begin(9600); //begin serial communication
pinMode(light_resistor, INPUT);
pinMode(LED, OUTPUT);
}
void loop() {
Serial.println(analogRead(light_resistor)); //print light_resistor
//value to serial
i = analogRead(light_resistor);
digitalWrite(LED, LOW);
delay(i/2);
digitalWrite(LED, LOW);
delay(i/2);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment