Skip to content

Instantly share code, notes, and snippets.

@garethfoote
Last active January 28, 2018 18:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save garethfoote/9ff116aec48e25a215f81fac3bbc24ac to your computer and use it in GitHub Desktop.
Save garethfoote/9ff116aec48e25a215f81fac3bbc24ac to your computer and use it in GitHub Desktop.
// Make variables to be used throughout code
int sensorPin = A0;
int ledPin = 13;
void setup() {
// Tell pin 13 to work as an output:
pinMode(ledPin, OUTPUT);
}
void loop() {
// Read the value from the sensor:
int sensorValue = analogRead(sensorPin);
// Turn the ledPin on
digitalWrite(ledPin, HIGH);
// Stop the program for <sensorValue> milliseconds:
delay(sensorValue);
// Turn the ledPin off
digitalWrite(ledPin, LOW);
// Stop the program for for <sensorValue> milliseconds:
delay(sensorValue);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment