combo lock

Unlocking system on arduino using two potentiometers and a button. Potentiometers have to be set to a certain range in order for the light to turn green when the button is pressed.

Completed with Hang Do Thi Duc


boolean unlock0 = false;
boolean unlock1 = false;

void setup() {
pinMode(13, OUTPUT);
pinMode(11, OUTPUT);

pinMode(2, INPUT);

void loop() // this function runs repeatedly after setup() finishes
int sensorValue0;
sensorValue0 = analogRead(A0);
// Serial.println(sensorValue0);

int sensorValue1;
sensorValue1 = analogRead(A1);
// Serial.println(sensorValue1);

if (sensorValue0 > 800 && sensorValue0 < 1023) {unlock0 = true;}
else{unlock0 = false;}

if (sensorValue1 > 0 && sensorValue1 < 200) {unlock1 = true;}
else{unlock1 = false;}

if(digitalRead(2) == HIGH){Serial.println(“high”);}
else {Serial.println(“low”);}

if(unlock0 == true && unlock1 == true && digitalRead(2) == HIGH){
digitalWrite(13, HIGH); // Turn the LED on
digitalWrite(11, LOW);
digitalWrite(13, LOW); // Turn the LED on
digitalWrite(11, HIGH);


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s