Hardware Reference
In-Depth Information
Figure 9-9. Circuit diagram of the knock box
The Arduino sketch is called KnockUnlock.ino , and includes a servo.h library and a SecretKnock.h library. The
servo.h library simply configures the servo to move at a specific pulse for a specified number of milliseconds.
The SecretKnock.h library defines an object, which allows for the configuration of an initial secret knock and the
appropriate feedback pins to reprogram the knock sequence.
Listing 9-13 is the main sketch.
Listing 9-13. Main Sketch of Secret Knock Box
#include "SecretKnock.h"
#define SERVO_PIN 1
int initKnocks[MAX_KNOCKS]= { 50, 25, 25, 50, 100, 50, 50, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
SecretKnock sKnock;
void setup() {
sKnock.begin(initKnocks);
}
 
Search WWH ::




Custom Search