![]() ![]() and the servo should turn to a 0 degree position. write(90) // and the servo should turn to a 90 degree position. In this case we have 3 digits //(123).ĭigitalWrite(redLED, HIGH) //. If ( position = 3) // This part defines how many digits our code will have. SetLocked(true) // The command to close the lock after „*“ or „#“ is pushed If (key = ‚*‘ || key = ‚#‘) If the lock is open it can be locked again by pushing „*“ o r „#“ on the //keypad attach(11) // The servo is connected to pin 11 PinMode(redLED, OUTPUT) // The LEDs are defined as Output Int greenLED = 13 // The green LED is connected to pin 13 Int redLED = 12 // The red LED is connected to pin 12 Keypad keypad = Keypad( makeKeymap(keys), rowPins, colPins, ROWS, COLS ) In this case „123“Ĭonst byte ROWS = 4 // In this two lines we define how many rows and columnsĬhar keys = // listed here Servo servoblue // The servo is called „servoblue“ from now onĬhar* password = „123“ // We set the password. #include // Include Keypad and servo library Search after “keypad” with the search bar on the top > choose the first library by Mark Stanley and install the library.įrom now on we can use the keypad library in our code. Open the arduino software > choose “Sketch” > “Include Library” > “Manage Libraries.” > To run the keypad with the arduino we need a library, which has to be added to the arduino software. One after another the keypad gets contacted to the arduino, until the contact from the keypad, with the number 7 on it, is connected to pin 8 on the arduino. The contact with the number 1 gets connected to pin 2 on the arduino. Hint: You can find the numbers 1 and 7 at the outermost contacts of the keypad. The wiring in this tutorial isn’t that complicated and is shown in the fritzing sketch below. This tutorial can be suggestion for a bigger project, like a door lock or a safe for example. If the lock is closed the red LED should light up and the servo should turn to an other position. Only if we enter the right code on the keypad, we want the green LED to light up and turn the servo to a certain position (lock open). Required equipment: Arduino / Breadboard / Keypad (4×4 in this example) / cables / one red LED / one green LED / two 100 Ohm resistors / servo A latch can be attached to the servo, e.g. Task: We want to turn on a LED and turn a servo to a certain position, after entering the right three-digit code on the keypad.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |