Technical, Techniques, Hints, and Tips > Microprocessor control

Rc transmitter to arduino

(1/2) > >>

Pete m:
hello everyone
I am having issues with my arduino uno  and hope someone can help
I am trying to input my 4 spare switches on my flysky i6x into the arduino to control output to relays to switch lights on and off
Does anyone have a sketch pre done that they would share ,or would it be easier just to purchase switches that can be controlled directly off of the receiver channels,I would go arduino as I already have got one in a box of goodies from a sale,programming not my strong suit ,
Thankyou

C-3PO:
Hello Pete,

Yes - several ways to approach this one. The example you give may well be easier with a dedicated off the shelf "switcher" unit

If you want to use your Uno then it is also very easy but will require a relay board or MOSFET's to achieve the actual "switching" controlled by the Arduino interfaced to your radio receiver.

A simple 4 x relay board (UK price £3.50) pictured below - ideally the board would encompass Optocouplers and have selectable high/low logic triggers

Step One - Have you got a sketch at the moment that reads the receiver outputs?

Regards
C-3PO

Pete m:
thankyou  i think i have managed to work out the inputs  as i can now see them in the serial monitor, however i think i might go the way of dedicated switches (easy option ) time to fire up ebay or aliexpress,  again thanks for the advice

C-3PO:
Hi Pete,

You will no doubt have seen the values in your serial monitor ranging from 1000-2000 where mid stick is approx 1500

If you did want to proceed with your Arduino solution then you would simply test the state of each receiver channel value and then switch a digital pin high or low that would trigger the relevant relay

Code would be something like this:

if (rxCH01>1650) {
   digitalWrite(9, HIGH);
}
   else
{
   digitalWrite(9, LOW);
}



if (rxCH01>1650) { // 1650 is the receiver channel value we are testing if greater than

// do stuff if the condition is true

// set relay pin on

digitalWrite(9, HIGH);

}

 else

 {

// do stuff if the condition is false

// set relay pin off

digitalWrite(9, LOW);

}

Regards
C-3PO

Pete m:
hi again i have managed a sketch to set inputs and outputs but for some reason on my uno only pin2 (input) is reading and sending output to pin13 none of the other input pins seem to work  i have included my sketch please feel free to edit it
thanks peter



// set variables
int channel1;
int channel2;
int channel3;
int channel4;
int channel5;
int channel6;

void setup() {  //input and outputs
  // input pins
  pinMode(2, INPUT);
  pinMode(3, INPUT);
  pinMode(4, INPUT);
  pinMode(5, INPUT);
  pinMode(6, INPUT);
  pinMode(7, INPUT);

  // output pins
  pinMode(8, OUTPUT);
  pinMode(9, OUTPUT);
  pinMode(10, OUTPUT);
  pinMode(11, OUTPUT);
  pinMode(12, OUTPUT);
  pinMode(13, OUTPUT);

// time for serial
  Serial.begin(9600);

}

void loop() {
  // read inputs
  channel1 = pulseIn(2, HIGH, 25000);
  channel2 = pulseIn(3, HIGH, 25000);
  channel3 = pulseIn(4, HIGH, 25000);
  channel4 = pulseIn(5, HIGH, 25000);
  channel5 = pulseIn(6, HIGH, 25000);
  channel6 = pulseIn(7, HIGH, 25000);

// pin 13 (channel 1)
  if (channel1 > 1400 )
  {
    digitalWrite(13, HIGH);
  }
  else
  {
    digitalWrite(13, LOW);
  }
   // pin 12 (channel 2)
  if (channel2 >1400 )
  {
    digitalWrite(12, HIGH);
  }
  else
  {
    digitalWrite(12, LOW);
  }
    // pin 11 (channel 3)
  if (channel3 >1400 )
  {
    digitalWrite(11, HIGH);
  }
  else
  {
    digitalWrite(11, LOW);
  }
      // pin 10 (channel 4)
  if (channel4 >1400 )
  {
    digitalWrite(10, HIGH);
  }
  else
  {
    digitalWrite(10, LOW);
  }
 
}

Navigation

[0] Message Index

[#] Next page

Go to full version