Pages: 1 [2]   Go Down
Author Topic: Need help exit for(;;)  (Read 1262 times)
0 Members and 1 Guest are viewing this topic.
USA
Offline Offline
Jr. Member
**
Karma: 0
Posts: 51
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

I think what you are trying to do would require an interrupt. you appear to want to run a loop and display a value and then if that value changes it would be displaying the new value. I could be wrong but I too am still learning the Arduino. you will have to have the variable you want to display define as a global as volitile so that the interrup function could change the value. My understanding is that when am interrupt is called all control does to the interrupt function and all current processing stops until the interrupt function is completed, at which time the process continues. Hopes this helps.

Pretty much what he said. If the value changes, I want the loop to reflect that change.
Logged

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

How are you expecting the value to change?
Logged

Des Moines, WA - USA
Offline Offline
God Member
*****
Karma: 25
Posts: 779
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

You're really not doing much to help yourself are you.

Without referencing any of the responses thus far in this thread, and in plain english (although this may be the problem), describe to us what you wish to do as EXACTLY AS YOU CAN without being the slightest bit vague.

In other words what's in your head is not known to us and thus you have to let us know what you want or you may as well stop posting.
« Last Edit: February 05, 2013, 08:12:42 pm by lloyddean » Logged

USA
Offline Offline
Jr. Member
**
Karma: 0
Posts: 51
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

TexasStingray - Not sure how I am going get the value to change as of right now, I will play around with what I have and see if I can figure out something. As per lloyddean request, I am going to wait to make any more post until I can "clarify" on what I am trying to accomplish.
Logged

0
Offline Offline
Tesla Member
***
Karma: 145
Posts: 9703
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Simple serial test code that continously loops awaiting the appropriate data to turn the arduino board LED on/off.

Code:
//zoomkat 3-5-12 simple delimited ',' string parce
//from serial port input (via serial monitor)
//and print result out serial port
// CR/LF could also be a delimiter

int ledPin = 13;
String readString;

void setup() {
  Serial.begin(9600);
  pinMode(ledPin, OUTPUT);
  Serial.println("serial LED on/off test with , delimiter"); // so I can keep track
}

void loop() {

  if (Serial.available())  {
    char c = Serial.read();  //gets one byte from serial buffer
    if (c == ',') {
      //if (readString.length() >0) {
        Serial.println(readString); //prints string to serial port out
        //do stuff with the captured readString
        if(readString.indexOf("on") >=0)
        {
          digitalWrite(ledPin, HIGH);
          Serial.println("LED ON");
        }
        if(readString.indexOf("off") >=0)
        {
          digitalWrite(ledPin, LOW);
          Serial.println("LED OFF");
        }       
        readString=""; //clears variable for new input
      //}
    } 
    else {     
      readString += c; //makes the string readString
    }
  }
}

Logged

Consider the daffodil. And while you're doing that, I'll be over here, looking through your stuff.   smiley-cool

Pages: 1 [2]   Go Up
Jump to: