/*
Fourth Project:
Three rotary knobs and three small screens showing numbers like 12.5 With the rotary button,
you have to turn the correct numbers on the screens, and if the correct numbers are in front,
the relay switches.
*/
#include <TM1637.h> // https://github.com/RobTillaart/TM1637_RT
TM1637 TM1, TM2, TM3;
#define pot1 A1
#define pot2 A2
#define pot3 A3
#define relay 12
// enter the correct numbers
#define num1 1023
#define num2 1023
#define num3 1023
void setup(){
Serial.begin(9600);
// First display
TM1.begin(8, 9, 4); // clockpin, datapin, #digits
TM1.displayClear();
TM1.setBrightness(7); // full brightness, default is 3
// Second display
TM2.begin(6, 7, 4);
TM2.displayClear();
TM2.setBrightness(7);
// Third display
TM3.begin(4, 5, 4);
TM3.displayClear();
TM3.setBrightness(7);
pinMode(relay, OUTPUT);
digitalWrite(relay, 0);
}
void loop(){
int value1 = analogRead(pot1);
int value2 = analogRead(pot2);
int value3 = analogRead(pot3);
TM1.displayInt(value1);
TM2.displayInt(value2);
TM3.displayInt(value3);
if(value1 == num1 && value2 == num2 && value3 == num3){
Serial.println("Unlocked");
digitalWrite(relay, 1);
while(1);
}
}