Flysky and Relay

Thanks -it works now . I am still learning and will take note of this in my future code

I will try your code too and see if it works .thanks

My Arduino is acting really funny - so when I connect my multimeter to the output, I see 5v with HIGH and 0V LOW but the relay will not turn on . I have everything connect from my power supply to the Arduino then everything off the 5v and ground of the Arduino . I am so close but something is just not right - see the serial output . I have tested the relay and I know 100% it works . Could it be just how I am connecting the relay and radio receiver.

Relay Connection
5V- Arduino
Gnd- Arduino
IN1 - Pin 7 Arduino
IN2- Pin 8 Arduino

Input ch1: 989 Input ch6: 989 1: 0 2: 0
Input ch1: 989 Input ch6: 990 1: 0 2: 0 989 Input ch6: 989 1: 0 2: 0
Input ch1: 989 Input ch6: 989 1: 0 2: 0
Input ch1: 989 Input ch6: 989 1: 0 2: 0
Input ch1: 989 Input ch6: 989 1: 0 2: 0
Input ch1: 989 Input ch6: 990 1: 0 2: 0
Input ch1: 989 Input ch6: 989 1: 0 2: 0
Input ch1: 989 Input ch6: 989 1: 0 2: 0
Input ch1: 990 Input ch6: 990 1: 0 2: 0
Input ch1: 989 Input ch6: 989 1: 0 2: 0
Input ch1: 989 Input ch6: 989 1: 0 2: 0
Input ch1: 989 Input ch6: 989 1: 0 2: 0
Input ch1: 989 Input ch6: 990 1: 0 2: 0
Input ch1: 989 Input ch6: 989 1: 0 2: 0
Input ch1: 1984 Input ch6: 989 1: 1 2: 0
Input ch1: 1978 Input ch6: 989 1: 1 2: 0
Input ch1: 1978 Input ch6: 989 1: 1 2: 0
Input ch1: 1978 Input ch6: 989 1: 1 2: 0
Input ch1: 1978 Input ch6: 995 1: 1 2: 0
Input ch1: 1978 Input ch6: 989 1: 1 2: 0
Input ch1: 1978 Input ch6: 989 1: 1 2: 0
Input ch1: 1978 Input ch6: 989 1: 1 2: 0
Input ch1: 1978 Input ch6: 989 1: 1 2: 0
Input ch1: 1978 Input ch6: 989 1: 1 2: 0
Input ch1: 1978 Input ch6: 989 1: 1 2: 0
Input ch1: 1978 Input ch6: 1978 1: 1 2: 1
Input ch1: 1978 Input ch6: 1978 1: 1 2: 1
Input ch1: 1978 Input ch6: 1978 1: 1 2: 1
Input ch1: 1978 Input ch6: 1978 1: 1 2: 1
Input ch1: 1978 Input ch6: 1978 1: 1 2: 1
Input ch1: 1978 Input ch6: 1978 1: 1 2: 1
Input ch1: 1978 Input ch6: 1978 1: 1 2: 1
Input ch1: 1978 Input ch6: 1978 1: 1 2: 1
Input ch1: 1981 Input ch6: 1978 1: 1 2: 1
Input ch1: 1978 Input ch6: 1978 1: 1 2: 1
Input ch1: 1978 Input ch6: 990 1: 1 2: 0
Input ch1: 1978 Input ch6: 989 1: 1 2: 0
Input ch1: 1978 Input ch6: 993 1: 1 2: 0
Input ch1: 1978 Input ch6: 989 1: 1 2: 0
Input ch1: 1978 Input ch6: 989 1: 1 2: 0
Input ch1: 1978 Input ch6: 989 1: 1 2: 0
Input ch1: 1977 Input ch6: 990 1: 1 2: 0

type or paste code here

neverminded I have to get my power supply voltage to 12v and everything works . I was at 9v (battery)

Guys one last help if I may ask is I am trying to get the the 3 pole switch on my receiver to work now , so this is the basic concept there

the switch has 3 position

Up - (989) I put in 1200

Middle - I want to do range (1400 and 1500) This the part I am trying to figure out the equation for

Down- 1800 I in1800

if (sig6 < 1100)
    plowup = HIGH;
  else if (sig6 == 1400)
    plowup = LOW;

if (sig6 > 1800)
    plowdown = HIGH;
  else if (sig6 == 1500)
    plowdown = LOW;type or paste code here

else if (sig6 1400<==>1500)Preformatted text

I tried this and only one side works

  if (sig1 > 1800)
    armrobot = HIGH;
  else if (sig1 < 1200)
    armrobot = LOW;

  if (sig6 < 900)
    plowup = HIGH;
  else if ((sig6 < 1400)&&(sig6 >1500))
    plowup = LOW;

**if (sig6 > 1800)**
**    plowdown = HIGH;**
** else if ((sig6 > 1400)&&(sig6 <1500))**
**    plowdown = LOW;**

only the down (Bold) works

You can’t really expect sig6 to simultaneously be less than 1400 and greater than 1500. So that expression is always false…

a7

kk what do I use to achieve my goal of keeping the 1400 and 1500 to keep the output low

 if (sig6 < 1200)
   plowup = HIGH;
  
   else if ((sig6 > 1400)&&(sig6 < 1500))
    plowup = LOW;

if (sig6 > 1900)
    plowdown = HIGH;
 else if ((sig6 > 1400)&&(sig6 <1500))
    plowdown = LOW;

I tried this with some success one the serial monitor phew

works like charm . Thank Alto777


Input ch1: 989    Input ch6: 988    Armed: 0    Plowup: 1    Plowdown: 1    Armed: 0    Plowup: 1    Plowdown: 1    
Input ch1: 989    Input ch6: 1484    Armed: 0    Plowup: 0    Plowdown: 0    
Input ch1: 989    Input ch6: 1484    Armed: 0    Plowup: 0    Plowdown: 0    
Input ch1: 989    Input ch6: 1484    Armed: 0    Plowup: 0    Plowdown: 0    
Input ch1: 989    Input ch6: 1478    Armed: 0    Plowup: 0    Plowdown: 0    
Input ch1: 989    Input ch6: 1478    Armed: 0    Plowup: 0    Plowdown: 0    
Input ch1: 989    Input ch6: 1478    Armed: 0    Plowup: 0    Plowdown: 0    
Input ch1: 989    Input ch6: 1478    Armed: 0    Plowup: 0    Plowdown: 0    
Input ch1: 989    Input ch6: 1484    Armed: 0    Plowup: 0    Plowdown: 0    
Input ch1: 1978    Input ch6: 1484    Armed: 1    Plowup: 0    Plowdown: 0    
Input ch1: 1978    Input ch6: 1484    Armed: 1    Plowup: 0    Plowdown: 0    
Input ch1: 1978    Input ch6: 1484    Armed: 1    Plowup: 0    Plowdown: 0    
Input ch1: 1978    Input ch6: 1484    Armed: 1    Plowup: 0    Plowdown: 0    
Input ch1: 1978    Input ch6: 1478    Armed: 1    Plowup: 0    Plowdown: 0    
Input ch1: 1978    Input ch6: 1478    Armed: 1    Plowup: 0    Plowdown: 0    
Input ch1: 1978    Input ch6: 1478    Armed: 1    Plowup: 0    Plowdown: 0    
Input ch1: 989    Input ch6: 1478    Armed: 0    Plowup: 0    Plowdown: 0    
Input ch1: 989    Input ch6: 1478    Armed: 0    Plowup: 0    Plowdown: 0    
Input ch1: 989    Input ch6: 1484    Armed: 0    Plowup: 0    Plowdown: 0    
Input ch1: 989    Input ch6: 1484    Armed: 0    Plowup: 0    Plowdown: 0    
Input ch1: 989    Input ch6: 1484    Armed: 0    Plowup: 0    Plowdown: 0    
Input ch1: 989    Input ch6: 1484    Armed: 0    Plowup: 0    Plowdown: 0    
Input ch1: 989    Input ch6: 990    Armed: 0    Plowup: 1    Plowdown: 0    
Input ch1: 989    Input ch6: 989    Armed: 0    Plowup: 1    Plowdown: 0    
Input ch1: 989    Input ch6: 989    Armed: 0    Plowup: 1    Plowdown: 0    
Input ch1: 989    Input ch6: 990    Armed: 0    Plowup: 1    Plowdown: 0    
Input ch1: 990    Input ch6: 989    Armed: 0    Plowup: 1    Plowdown: 0    
Input ch1: 989    Input ch6: 989    Armed: 0    Plowup: 1    Plowdown: 0    
Input ch1: 989    Input ch6: 989    Armed: 0    Plowup: 1    Plowdown: 0    
Input ch1: 990    Input ch6: 989    Armed: 0    Plowup: 1    Plowdown: 0    
Input ch1: 989    Input ch6: 990    Armed: 0    Plowup: 1    Plowdown: 0    
Input ch1: 989    Input ch6: 1484    Armed: 0    Plowup: 0    Plowdown: 0    
Input ch1: 989    Input ch6: 1484    Armed: 0    Plowup: 0    Plowdown: 0    
Input ch1: 989    Input ch6: 1478    Armed: 0    Plowup: 0    Plowdown: 0    
Input ch1: 989    Input ch6: 1478    Armed: 0    Plowup: 0    Plowdown: 0    
Input ch1: 989    Input ch6: 1978    Armed: 0    Plowup: 0    Plowdown: 1    
Input ch1: 989    Input ch6: 1978    Armed: 0    Plowup: 0    Plowdown: 1    
Input ch1: 995    Input ch6: 1978    Armed: 0    Plowup: 0    Plowdown: 1    
Input ch1: 989    Input ch6: 1978    Armed: 0    Plowup: 0    Plowdown: 1    
Input ch1: 989    Input ch6: 1978    Armed: 0    Plowup: 0    Plowdown: 1    
Input ch1: 989    Input ch6: 1978    Armed: 0    Plowup: 0    Plowdown: 1    
Input ch1: 989    Input ch6: 1978    Armed: 0    Plowup: 0    Plowdown: 1    
Input ch1: 989    Input ch6: 1984    Armed: 0    Plowup: 0    Plowdown: 1    
Input ch1: 990    Input ch6: 1978    Armed: 0    Plowup: 0    Plowdown: 1    
Input ch1: 989    Input ch6: 1978    Armed: 0    Plowup: 0    Plowdown: 1    
Input ch1: 989    Input ch6: 1478    Armed: 0    Plowup: 0    Plowdown: 0    
Input ch1: 989    Input ch6: 1478    Armed: 0    Plowup: 0    Plowdown: 0    
Input ch1: 991    Input ch6: 1484    Armed: 0    Plowup: 0    Plowdown: 0    
Input ch1: 989    Input ch6: 1484    Armed: 0    Plowup: 0    Plowdown: 0    
Input ch1: 989    Input ch6: 1484    Armed: 0    Plowup: 0    Plowdown: 0    
Input ch1: 989    Input ch6: 1484    Armed: 0    Plowup: 0    Plowdown: 0    
Input ch1: 989    Input ch6: 1484    Armed: 0    Plowup: 0    Plowdown: 0    
Input ch1: 989    Input ch6: 1484    Armed: 0    Plowup: 0    Plowdown: 0    
Input ch1: 989    Input ch6: 1478    Armed: 0    Plowup: 0    Plowdown: 0    
Input ch1: 989    Input ch6: 1478    Armed: 0    Plowup: 0    Plowdown: 0    
Input ch1: 989    Input ch6: 1478    Armed: 0    Plowup: 0    Plowdown: 0    
Input ch1: 989    Input ch6: 1478    Armed: 0    Plowup: 0    Plowdown: 0    
Input ch1: 990    Input ch6: 1484    Armed: 0    Plowup: 0    Plowdown: 0    
Input ch1: 989    Input ch6: 1484    Armed: 0    Plowup: 0    Plowdown: 0    
Input ch1: 989    Input ch6: 1484    Armed: 0    Plowup: 0    Plowdown: 0    
Input ch1: 989    Input ch6: 1484    Armed: 0    Plowup: 0    Plowdown: 0    
Input ch1: 989    Input ch6: 1484    Armed: 0    Plowup: 0    Plowdown: 0    
Input ch1: 989    Input ch6: 1483    Armed: 0    Plowup: 0    Plowdown: 0    
Input ch1: 989    Input ch6: 1478    Armed: 0    Plowup: 0    Plowdown: 0    
Input ch1: 989    Input ch6: 1478    Armed: 0    Plowup: 0    Plowdown: 0    
Input ch1: 989    Input ch6: 1478    Armed: 0    Plowup: 0    Plowdown: 0