I found this place that deals with receiving data from an Arduino into python as a threaded GUI.
http://blog.wickeddevice.com/?p=191
This seems to work but I have discovered that every time the Arduino output is read the arduino gets reset. I have tried all the suggestions to disable auto reset to no avail. To me it seems weird that with the arduino IDE serial monitor there is no reset but is difficult to duplicate this in other software. I would like to find a software solution for this.
What I want to do is receive a data stream into a program. Then in real time manipulate that data to give meaningful information on the screen.
#include <LiquidCrystal.h>
LiquidCrystal lcd( 8, 9, 4, 5, 6, 7 );
int count = 1;
int duration = 0;
int maxduration = 1000;
int lightlevel;
int val = 0;
unsigned long laptime;
unsigned long starttime = 0;
unsigned long triggertime = 0;
boolean startflag = false;
boolean beambroken = false;
boolean newtime = false;
long lapcount = 0;
volatile unsigned long laptimeint = 0;
volatile int state = LOW;
void setup()
{
lcd.begin(16,2);
pinMode(13, OUTPUT);
pinMode(2, INPUT);
attachInterrupt (0,lap,RISING);
Serial.begin(115200);
}
void loop()
{
if(startflag == true)
{
displaytime(millis()-starttime,3,1); //print acunulated time bottom row
}
lcd.setCursor(0,0);
lcd.print(" ");
displaytime(laptimeint- triggertime,0,0); //print laptime top row
lcd.setCursor(13,0);
if(lapcount <=9)
{
lcd.print(" ");
}
lcd.print(lapcount); //print laps
if (newtime)
{
Serial.print("lane1 ");
Serial.print(laptimeint);
Serial.print(" Lap ");
Serial.println(lapcount);
newtime = false;
}
}
void displaytime(unsigned long time,byte colum,byte row)
{
unsigned long millispassed;
byte secspassed;
byte minspassed;
byte hourspassed;
lcd.setCursor(colum,row);
secspassed = ( time / 1000 % 60 ); //"% 100" is the remainder of a divide-by-100, which keeps the value as 0-99 even as the result goes over 100
minspassed = ( time / 1000 / 60 % 60 );
hourspassed = ( time / 1000 / 60 / 60 );
millispassed = (time - ((time/1000) * 1000));
if ( hourspassed <=9)
lcd.print( "");
lcd.print(hourspassed,DEC);
lcd.print( "h");
if (minspassed <= 9)
lcd.print( " ");
lcd.print( minspassed, DEC );
lcd.print("m");
if( secspassed <= 9 )
lcd.print( " " ); //quick trick to right-justify this 2 digit value when it's a single digit
lcd.print( secspassed, DEC );
lcd.print(".");
if ( millispassed <=9 )
lcd.print("00");
if (millispassed >9 && millispassed <=99 )
lcd.print("0");
lcd.print(millispassed,DEC);
lcd.print("s");
//lcd.setCursor(10,0);
//lcd.print(millispassed,DEC);
return;
}
void lap()
{
triggertime = laptimeint;
laptimeint = millis();
if(startflag == true)
{
lapcount = lapcount +1;
}else
{
starttime = millis();
}
startflag = true;
newtime = true;
state = !state;
}