Pages: [1]   Go Down
Author Topic: Problem by controlling application with Arduino!  (Read 565 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 42
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hello everyone!I would like to help me to something...I have connected a sensor to the input all ok and all good... and i want to read values of the sensor for every 10 minutes.In the meanwhile i want to have the choice between the 10min time to send a choice from a C# application to retrieve these values.The problem has to do with the Arduino's source code, and more specific to the part that i should send the choice....To continue!After that if user for this 10min time didn't send any command for value display,the arduino should continue check as before...


Any idea please??Thanks a lot!
Logged

Chicago
Offline Offline
Full Member
***
Karma: 0
Posts: 113
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

What your asking makes no sense after reading your post 3 times can you clarify the task you are trying to preform?
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 42
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I want to read in every ten minutes one sensor and sending a character which print these values to an C# application...The command which accepts from serialport is serial.read();
The controller stucks here and i don't want something like that.I want to continues read...When the user didn't send command to retrieve values the Arduin's software should continues reading in every 10 minutes.

Code:
   if( millis() >= (10UL*60UL*1000UL) && (!isPressed))
    {
       //read values again if 10 minutes has completed
      //and the user didn't press 'l'
    }
    else if( isPressed ){
      byte serialData = Serial.read();    
      if ((char)serialData =='l')  {      
       //sent data to C# app
      }
      else {
      //something else      
      }
« Last Edit: May 12, 2012, 08:07:02 pm by sirus » Logged

Belgium
Offline Offline
Full Member
***
Karma: 0
Posts: 187
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

i think it's best to let the timing be done byt the arduino... if you let it send something every 10 minutes, and you write your program so that it reads when something gets sent, then there should be no problem
Logged


Seattle, WA USA
Offline Offline
Brattain Member
*****
Karma: 613
Posts: 49307
Seattle, WA USA
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

The way your code is written now, nothing will happen for 10 minutes. After 10 minutes, the if statement will always be true.

I see no practical reason to not read the sensor on every pass through loop. You are only sending data to the C# application when it asks for it. Why does it matter that the data is current, rather than 10 minutes old?
Logged

Pages: [1]   Go Up
Jump to: