Moderators: adafruit_support_bill, adafruit
int ledPin = 13; // LED connected to digital pin 13
int SwitchPin = 2; // Switch connected to digital pin 2
int val = 0; // variable to store the read value
void setup()
{
pinMode(ledPin, OUTPUT); // sets the digital pin 13 as output
pinMode(SwitchPin, INPUT); // sets the digital pin 2 as input
digitalWrite(SwitchPin, HIGH); // turn on pullup resistor for switch
}
void loop()
{
val = digitalRead(SwitchPin); // read the input pin
digitalWrite(ledPin, val); // sets the LED to the switch's value
}EDIT: I didn't use any additional hardware (i.e. resistors).
digitalWrite(SwitchPin, HIGH); // turn on pullup resistor for switchadafruit_support wrote:But you did enable the internal pullup:
adafruit_support wrote:In the OFF position, does the pin with the led symbol get connected to ground?
Return to Arduino Shields from Adafruit
Users browsing this forum: No registered users and 7 guests