Remember to Bring the Key
by Gooeifiretterthu in Circuits > Arduino
118 Views, 1 Favorites, 0 Comments
Remember to Bring the Key
Using the principle of powering on the key, as long as the key is not taken, the shoe cabinet is not allowed to be opened.
Program
Using the principle of powering on the key, as long as the key is not taken, the shoe cabinet is not allowed to be opened. Invalid setting(){//Put your setting code here and run it once:
pinMode( 12, input); // set the digital pin to input lcd_I2C_27.init(); // initialize the LCD display lcd_I2C_27.backlight(); servo_pin_7.attach(7); // connect the servo pin to the rudder Machine object if (digitalRead( 12 )) {_value = 1; lcd_I2C_27.clear(); lcd_I2C_27.setCursor(3, 0); // Set the cursor and count from 0 lcd_I2C_27.print( "Get key." ); / / Print a message to the LCD. } else {_value = 0; lcd_I2C_27.clear(); lcd_I2C_27.setCursor(2, 0); // Set the cursor and count from 0 lcd_I2C_27.print("Good luck."); // Print a message to the LCD . }
}
void loop(){ // Put your main code here and run it repeatedly: if (_value == 1) {delay( 500 ); // wait a few milliseconds if (!( digitalRead( 12) )) {delay( 500 ); // wait a few milliseconds if (!( digitalRead( 12) )) {serve_pin_7.write( 60 ); // tell the servo to go to position _value = 0; lcd_I2C_27.clear(); lcd_I2C_27.setCursor(2, 0); // Set the cursor and count from 0 lcd_I2C_27.print("Good luck."); // Print a message to the LCD. }}} else {delay (500); // wait a few milliseconds if (digitalRead( 12 )) {delay(500); // wait a few milliseconds if (digitalRead( 12 )) {servo_pin_7.write(150); // Tell the servo to go to position _value = 1; lcd_I2C_27.clear(); lcd_I2C_27.setCursor(3, 0); // Set the cursor and count from 0 lcd_I2C_27.print( "Get key." ); // Print to LCD a message. }}} Delay (100); // Wait a few milliseconds}
Circuit
Is the circuit
Lock
Is a lock