Skip to content

Instantly share code, notes, and snippets.

@ringodin
Created October 7, 2014 03:23
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 ringodin/866ceca533465132395f to your computer and use it in GitHub Desktop.
Save ringodin/866ceca533465132395f to your computer and use it in GitHub Desktop.
this is too teach students about button use
/*
http://www.arduino.cc/en/Tutorial/Button
*/
const int buttonPin = 7; // the number of the pushbutton pin
const int green = 13; // the number of the LED pin
void setup()
{
pinMode(green, OUTPUT);
pinMode(buttonPin, INPUT);
}
void loop()
{
if (digitalRead(buttonPin) == HIGH)
{
digitalWrite(green, HIGH);
}
else
{
digitalWrite(green, LOW);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment