Go Down

Topic: Need help exit for(;;) (Read 2015 times) previous topic - next topic


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.


How are you expecting the value to change?


Feb 06, 2013, 02:11 am Last Edit: Feb 06, 2013, 02:12 am by lloyddean Reason: 1
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.


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.


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

Code: [Select]

//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() {
  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

Google forum search: Use Google Search box in upper right side of this page.
Why I like my 2005 Rio Yellow Honda S2000  https://www.youtube.com/watch?v=pWjMvrkUqX0

Go Up