From 4beef04a3fd5e57a5e303d23db8d1e599a14b2cb Mon Sep 17 00:00:00 2001 From: mattmcw Date: Sun, 2 Jul 2023 13:56:03 -0400 Subject: [PATCH] Projector debug idea. --- notes/mcopy_projector_debug.py | 24 +++++++++++ .../mcopy_projector_debug.ino | 41 +++++++++++++++++++ 2 files changed, 65 insertions(+) create mode 100644 notes/mcopy_projector_debug.py create mode 100644 notes/mcopy_projector_debug/mcopy_projector_debug.ino 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