canon_ble #82

Merged
mattmcw merged 149 commits from canon_ble into main 2023-08-01 03:38:52 +00:00
2 changed files with 65 additions and 0 deletions
Showing only changes of commit 4beef04a3f - Show all commits

View File

@ -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()

View File

@ -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);
}