#include <PPMReader.h> // library to read data from my flysky i6
#include <LED.h> // custom class to turn on off led
bool led_on; // whether led shall be on or off
int channel;
void setup(){
....
led_on = false;
}
void loop{
channel = ppm.read()// this is a function that reads channel from receiver and it gets value between 1000 and 1998
if( channel <1050){
led_on = false;
}
else if (channel > 1985){
led_on = true;
}
if (led_on){
led.on();
}
else{
led.off();
}
Now the problem is that, I expect once led_is turned on it remains turned on unless I turn if off myself by decreasing the value of channel below 1050.But what happnes is that for whatever time my channel value is more than 1985 led turns on else it remains off.
When my channel4 from flysky is maximum .. for some time it gets zero as shown in the graph. I could not figure it out yesterday.
Still I have not solved the issue. I do not want to use delay in my main thread.
If i missed something please do tell me, so that i can correct it.
Thanking you
@anchalshivank the installation and troubleshooting section is for getting the Arduino system working. It is specifically NOT fir your project. Please take more care when choosing a section to post in. Please read the getting the best from this forum post and the forum section description before posting again.
I have moved your post to this more appropriate place.
I have solved the issue.. As it can be seen from the graph that for a tiny amout of time the value drops to zero and value droping to zero for that tiny amout of time shall not either turn on or off the led.
so simple solution is to change the condition of the if statement.
if(channel4>1985){
led_on = true;
}
else if(channel5>=1000 && channel4 <1017){//as receiver value ranges from 1000 to 1998 , zero shall be excluded in any case
led_on = false;
}
Yes, and it is real because after I had moved it and the opening post, the only post made by the OP, when I used the @ to address the OP no names at all appeared. Where as now all the names of every contributor appeared in a drop down list as normal.
As the iPad I am using can’t display the posts and reply at the same time, unlike my laptop, I had to close the reply remember four letters of the op’s name, open up the reply and type them in. So it was quite a performance getting his name in.