Step 3: Assemble The Circuit
Remove these ads by
Signing Up
Remove these ads by
Signing Up
PDF Downloads
As a Pro member, you will gain access to download any Instructable in the PDF format.
You also have the ability to customize your PDF download.
I'm using a 9v battery instead of a power supply
Is this ok?....:
int buttonPin = 2;
int ledPin = 13;
int lock = 9; //pin 9 on Arduino
int buttonState = 0;
void setup() {
pinMode(lock, OUTPUT);
pinMode(buttonPin, INPUT);
digitalWrite(lock, HIGH);
pinMode(ledPin, OUTPUT);
}
void loop(){
buttonState = digitalRead(buttonPin);
if (buttonState == HIGH) {
digitalWrite(ledPin, HIGH);
digitalWrite(lock, LOW);
delay(5000);
}
else {
digitalWrite(ledPin, LOW);
digitalWrite(lock, HIGH);
}
delay(500);
}