Hello Everyone!
I recently built a simple 5 LED email notification box that lights up when I have new emails. For the project I used a combination of a few other code-bits I found and pieced them together to work on Ubuntu. Essentially this is a 3 part process. The arduino is programmed to recieve eiather an 'M' or 'N' through the serial port. The 'M' and 'N' come from a small python program which uses feedparser to check my account for new emails. The python program currently runs in a loop in a shell script which checks gmail every 30 secounds.
HERE IS MY PROBLEM!
I am connected to the arduino through serial, I am successfully recieving if I have new mail or not (Using echo debug in python program and testing it), When the python program runs the lights are successful in flashing BUT they flash no matter what.
I am using a mail variable set to HIGH or LOW based on weither I recieve a "M" or "N" through the serial. The mail variable is then directly feed into my digitalWrite command like so..
digitalWrite(outPin1, mail);
The problem is that no matter if the mail variable is high or low the lights are still blinking. If you all need me to post more info like the python program or shell script which I don't think is the problem then I certainly will! Here is the sketch im using and where the problem I believe lies...
// led wired + to pin 12, resistor to positive +5v
int outPin1 = 13; // Output connected to digital pin 13
int outPin2 = 12;
int outPin3 = 11;
int outPin4 = 10;
int outPin5 = 9;
int mail = HIGH; // Is there new mail?
int val; // Value read from the serial port
void setup()
{
pinMode(outPin1, OUTPUT);
pinMode(outPin2, OUTPUT);
pinMode(outPin3, OUTPUT);
pinMode(outPin4, OUTPUT);
pinMode(outPin5, OUTPUT);
Serial.begin(9600);
Serial.flush();
mail = HIGH; // start off with lights out
}
void loop()
{
// Read from serial port
if (Serial.available())
{
val = Serial.read();
Serial.println(val);
if (val == 110) // n = 110 in dec
{
mail = HIGH; // HIGH is off because led is connected to +5v on the other side
}
else if (val == 109) //109 = m in dec
{
mail = LOW; // LOW is on because led is connected to +5v on the other side
}
}
// blinking series to run if mail is LOW
delay(500);
digitalWrite(outPin1, mail);
delay(800);
digitalWrite(outPin2, mail);
delay(800);
digitalWrite(outPin3, mail);
delay(800);
digitalWrite(outPin4, mail);
delay(800);
digitalWrite(outPin5, mail);
delay(800);
}
Thank you a ton in advance for any advice/help you can give for this problem.
Happy Hacking,
Trent