nt ledPin = D2;
int switchPin = D3;
int ledBrightness = 0;
// int photoCellPin = A0;
// int photoCellReading = 0;
void setup()
{
pinMode( switchPin , INPUT_PULLUP); // sets pin as input
// We also want to use the LED
pinMode( ledPin , OUTPUT ); // sets pin as output
}
void loop()
{
// find out if the button is pushed
// or not by reading from it.
int buttonState = digitalRead( switchPin );
// Using a pulldown resistor we get a LOW
// Signal when its on
if( buttonState == HIGH )
{
digitalWrite( ledPin, HIGH);
}else{
// otherwise
// turn the LED Off
digitalWrite( ledPin, LOW);
}
Click to Expand
Content Rating
Is this a good/useful/informative piece of content to include in the project? Have your say!
You must login before you can post a comment. .