/*
***Created by Lucian R***
All Rights Reserved. Use at own risk.
BUTTON DEFAULT CODE
*/
// Put your variables here:
int led = 6; // Change this to your LED's DigitalPin
int button = 2; // Change this to your button's DigitalPin
int value = 0; //Don't change this!!
void setup() {
// Put your setup code here, to run once:
pinMode(led, OUTPUT);
// This declares the LED as an OUTPUT
pinMode(button, INPUT);
// This declares the button as an INPUT
}
void loop() {
// Put your main code here, to run repeatedly:
value = digitalRead(button);
// This checks and gives us the state of the button: Pressed (HIGH), Released (LOW). It's funny- "value" was an integer, now it's a boolean. LOL
if (value == HIGH) {
// This checks if it's pressed.
digitalWrite(led, HIGH);
// And this turns the LED on.
}
else {
// This checks if it's NOT pressed.
digitalWrite(led,LOW);
// This turns the LED off.
}
}
Comments