Christopher De Vries committed c334364

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

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.


 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__":
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.