Permalink
Browse files

Add debugging output and change openDoor to display it

  • Loading branch information...
1 parent f61ad67 commit 4a65a10d321648e2e686f4b3f65ee63597a071bc @marksteward marksteward committed with root Sep 27, 2010
Showing with 41 additions and 7 deletions.
  1. +34 −6 Doorbot_pde/Doorbot_pde.pde
  2. +7 −1 openDoor.py
@@ -1,35 +1,62 @@
int triggerPin = 13;
+int ledPin = 12;
int doorBellButton = 2;
void setup()
{
Serial.begin(9600);
pinMode(triggerPin, OUTPUT);
+ pinMode(ledPin, OUTPUT);
+
/*
pinMode(doorBellButton, INPUT);
pinMode(doorBellLEDGreen, OUTPUT);
pinMode(doorBellLEDRed, OUTPUT);
digitalWrite(doorBellButton, HIGH);
*/
+
+ // Booted signal
+ for(int i = 0; i < 3; i++) {
+ digitalWrite(ledPin, LOW);
+ delay(300);
+ digitalWrite(ledPin, HIGH);
+ delay(100);
+ }
+
}
void loop()
{
+
// Check for door unlock command
if (Serial.available() > 0) {
- char inByte = Serial.read();
+ int inByte = Serial.read();
if (inByte == '1') {
- // Strobe a little
- for (int i = 0; i < 2; i++) {
+ Serial.println("Opening door");
+ digitalWrite(ledPin, LOW);
+
+ if(false) {
+ // Strobe a little
+ for (int i = 0; i < 3; i++) {
+ digitalWrite(triggerPin, HIGH);
+ delay(100);
+ digitalWrite(triggerPin, LOW);
+ delay(30);
+ }
+ } else {
+ // Constant on
digitalWrite(triggerPin, HIGH);
- delay(100);
+ delay(1000);
digitalWrite(triggerPin, LOW);
- delay(30);
}
- delay(500); // Pause to ensure it resets
+
+ digitalWrite(ledPin, HIGH);
+ Serial.println("Door opened");
}
+ Serial.flush();
}
+
/*
// Check door bell button
if(digitalRead(doorBellButton)){
@@ -41,4 +68,5 @@ void loop()
digitalWrite(doorBellLEDGreen, HIGH);
}
*/
+
}
View
@@ -1,12 +1,18 @@
#!/usr/bin/env python
-import serial, sys
+import serial, sys, time
try:
port = sys.argv[1]
except:
port = '/dev/ttyUSB0'
+print 'Using port %s' % port
ser = serial.Serial(port, 9600)
+time.sleep(2) # Wait for it to reboot
+
ser.write('1')
+time.sleep(0.5)
+print 'Response: %s' % ser.readline()
+
ser.close()

0 comments on commit 4a65a10

Please sign in to comment.