diff --git a/notes/mcopy_projector_debug.py b/notes/mcopy_projector_debug.py new file mode 100644 index 0000000..28f2684 --- /dev/null +++ b/notes/mcopy_projector_debug.py @@ -0,0 +1,24 @@ +import serial +import time +import serial.tools.list_ports + +ports = serial.tools.list_ports.comports() +port = '' +for p in ports: + print p + if "Arduino" in p.description: + print "This is an Arduino!" + port = p.device + break + +if p is '': + print("Arduino is not connected") + exit(1) + +arduino = serial.Serial(port=port, baudrate=57600, timeout=.05) +time.sleep(1) + +while arduino.in_waiting: # Or: while ser.inWaiting(): + print arduino.readline() + + diff --git a/notes/mcopy_projector_debug/mcopy_projector_debug.ino b/notes/mcopy_projector_debug/mcopy_projector_debug.ino new file mode 100644 index 0000000..10cb5b4 --- /dev/null +++ b/notes/mcopy_projector_debug/mcopy_projector_debug.ino @@ -0,0 +1,41 @@ + +const int PROJECTOR_MICROSWITCH = 11; + +const int PROJECTOR_FWD = 3; +const int PROJECTOR_BWD = 4; + +const int PROJECTOR_MICROSWITCH_CLOSED = 0; +const int PROJECTOR_MICROSWITCH_OPENED = 1; + +volatile long startTime = 0; +volatile boolean writing = false; + +void setup () { + pins(); + startTime = millis(); +} + +void loop () { + now = millis(); + if (now >= startTime + 3000) { + digitalWrite(PROJECTOR_FWD, HIGH); + writing = true; + } else if (now >= startTime + 23000) { + digitalWrite(PROJECTOR_FWD, LOW); + writing = false; + } + if (writing) { + Serial.print(now); + Serial.print(","); + Serial.println(digitalRead(PROJECTOR_MICROSWITCH)); + } +} + +void pins () { + pinMode(PROJECTOR_MICROSWITCH, INPUT_PULLUP); + pinMode(PROJECTOR_FWD, OUTPUT); + pinMode(PROJECTOR_BWD, OUTPUT); + + digitalWrite(PROJECTOR_FWD, LOW); + digitalWrite(PROJECTOR_BWD, LOW); +} \ No newline at end of file