Step 10The (Hard) Hardware
THIS helped me get started.
The basic logic of the program was this:
Someone pushes the doorbell, It activates a relay that rings the doorbell and activates the Arduino.
The Arduino then:
1) Ignores all activation commands for 4 mins (in case someone rings the doorbell again)
2) Starts a Applescript command on the host Mac computer
3) Activates a second relay (for future ideas)
4) Resets after 4 mins, and goes back to stand-by
Here is the code:
int ledPin = 13; // LED connected to digital pin 13
int potPin = 0; // white doorbell wire to analog pin 0
int val = 0;
long time = 0;
long debounce = 1000;
void setup() {
pinMode(ledPin, OUTPUT); // sets the digital pin as output
Serial.begin(9600); // open serial port at 9600 baud
digitalWrite(14 + potPin, HIGH); // set pullup on the analog pin
// (analog 0 = digital 14, a1 = d15, etc)
}
void loop() {
val = analogRead(potPin);
if (val < 100) { // if the circuit is completed
// (for me, it generally drops from 1023 to ~ 15 when 'ringing')
if (millis()-time > debounce) {
Serial.println("A");
delay(500);
Serial.println("A");
delay(500);
Serial.println("A");
digitalWrite(ledPin, HIGH); // sets the LED on
delay(120000); // ... 240000 = 4 mins
digitalWrite(ledPin, LOW); // and turns the LED off
time = millis();
}
}
}
NOTE: The Appleshare Proxy program was only accepting every third "A" from my Arduino, so I send three and the board now responds instantly without error (I am sure it's sloppy code, but HEY it works!) The 'delay' is where the board ignores all key presses, so the program does not restart if someone keeps ringing the doorbell.
| « Previous Step | Download PDFView All Steps | Next Step » |
![]() |
Add Comment
|

















































