Loop serial Data

Hi pro !

I working on led flash project with bluetooth interface.

I send from app two position values of potentiometers to arduino who done cycle (On and OFF led with delay value of potentio.) and stops with waiting for new incoming positions

It stops me when i want to loop serial data (value) until new incoming data from TX.

Code:

#include<SoftwareSerial.h>
SoftwareSerial future(0, 1);
int ledPin=13;

void setup() {
Serial.begin(9600);
pinMode(ledPin, OUTPUT);
future.begin(9600);

}

void loop() {

if (future.available()){
int value1=future.parseInt();
int value2=future.parseInt();
if (future.read() =='\n'){

Serial.println(value1);
Serial.println(value2);

digitalWrite(ledPin, HIGH);

delay(value1);

digitalWrite(ledPin, LOW);

delay(value2);

}
}
}

Any idea how to solve it ?
Maybe with scheduler (multi loop) or SerialEvent ?
Thank u for answers ahead !

I may misunderstand your problem but if you want the flashing to continue you should not have the code for it inside the if (future.available()){

Make the code for receiving the data separate from the code for acting on the data. Receive the data and store it in some variables. In the action code read the variables and use the values. That way the action will continue to use the values until they are changed.

Have a look at the examples in Serial Input Basics - simple reliable ways to receive data. There is also a parse example to illustrate how to extract numbers from the received text.

...R
Planning and Implementing a Program

#include<SoftwareSerial.h>
SoftwareSerial future(0, 1);
int ledPin=13;

void setup() {
 Serial.begin(9600);
 pinMode(ledPin, OUTPUT);
 future.begin(9600);

It makes NO sense to do software serial on the hardware serial pins.

It is IMPOSSIBLE to do software serial on the hardware serial pins while they are being used for hardware serial.

As a result, there is absolutely not a hope in hell of this code working, so there is no point in looking at any more of it.

Hi,
Welcome to the forum.

Please read the first post in any forum entitled how to use this forum.
http://forum.arduino.cc/index.php/topic,148850.0.html then look down to item #7 about how to post your code.
It will be formatted in a scrolling window that makes it easier to read.

Thanks... Tom... :slight_smile:

Wb.
Thanks Robin2 i will read it.
PaulS code is working, i serching only for solution to loop.
TomGeorge thanks iv been serching for code icon.

PaulS code is working

Bullshit! You can NOT possibly be reading data from the software serial instance, because those pins are already in use by the hardware serial instance.