Christopher De Vries committed c334364

Added a signal sent from the Arduino every 10 LED flashes. Also updated README file.

  • Participants
  • Parent commits 1c947a8
  • Tags 1.1

Comments (0)

Files changed (3)

 two-way communication, but it relies on executing commands which are not going
 to take a whole lot of time or add any delays to each loop.
+The example includes the following files:
+README.txt --- This file.
+LICENSE.txt --- The license governing distribution and modification of this
+                code.
+ --- A graphical user interface written in python which uses
+                 Tkinter. Note that this program requires that the pySerial
+                 extension be installed. PySerial can be downloaded at
+        .
+comm_example/comm_example.pde --- The example Arduino sketch. This program
+                 Flashes an LED on for a second and off for a second, then
+                 repeats. During this time it sends a signal over the serial
+                 line indicating how many times the LED has been on, every 10
+                 flashes. It also responds to inquiries about the current
+                 state of the LED and the connection.
 Basically every time the Arduino runs through loop I do two things:
 1. Monitor and or change any I/O pins that require monitoring or changing.

File comm_example/comm_example.pde

 The High response indicates that the LED is currently on.
+We also have the Arduino send an alert through the serial port every time it
+cycles on a multiple of 10 times. We do this through the CYCLE output command.
+For example, on the 10th time it flashes on, the Arduino sends the command
+On the 20th it sends the command:
+and so on (until the limit of unsigned int is reached).
 Copyright 2011 Christopher De Vries
 This program is distributed under the Artistic License 2.0, a copy of which
 is included in the file LICENSE.txt
 unsigned long nextStateChange;
 int ledState = LOW;
+unsigned int cycle_number=0;
 void setup() {
   if(ledState==LOW) {
     ledState = HIGH;
+    cycle_number++;
+    if(cycle_number%10==0) {
+      Serial.print("CYCLE ");
+      Serial.println(cycle_number);
+    }
   else {
     ledState = LOW;


                     self.writeline("LED is On")
                 elif tokens[0]=="LOW":
                     self.writeline("LED is Off")
+                elif tokens[0]=="CYCLE":
+                    self.writeline(tokens[1]+" LED Flashes Completed.")
+                elif tokens[0]=="IOHALT":
+                    self.writeline("IO threads halted")
                 elif tokens[0]=="ERROR":
                     self.writeline("Error: "+' '.join(tokens[1:]))
         self.outputQ.put("TERMINATE") # This does not get sent, but stops the outputQ from blocking.
-        self.inputQ.put("All IO Threads stopped")
+        self.inputQ.put("IOHALT")
 if __name__ == "__main__":