RC Truck and Construction  

Go Back   RC Truck and Construction > RC Tech section. > Electronics tech

Electronics tech Anything to do with the electronics in a model. Lights, Radio, ESC, Servo, Basic electrical.


Reply
 
Thread Tools Display Modes
  #1  
Old 06-13-2021, 12:45 PM
Wombii's Avatar
Wombii Wombii is offline
Green Horn
 
Join Date: Feb 2018
Location: Norway
Posts: 231
Wombii is on a distinguished road
Default Re: Switch question

Very nice servo switch!
I don't know if this helps, but if you wanted to replace it with an arduino nano or something, the following code should in theory emulate it, reading one radio channel and switching two outputs. I just wrote it, but I haven't tested it. You could add a couple more channels.
Note that the arduino can only output signal levels of current, less than 20mA per pin, so you'd need some transistors or relays to actually switch the solenoid and pump. Or hook up small esc's or servo boards (or battleswitches?) to the arduino and control those with the servo library instead of switching the outputs high and low.

Code:
//give the pins human readable names
const byte inputPin = 8;

const byte outputPin_A = 2;
const byte outputPin_B = 3;

void setup() {
  // put your setup code here, to run once:

  //Set output pins to type "output". This means the pins switches between 5v and GND. You need to use external resistors to limit current under 20mA.
  pinMode(outputPin_A,OUTPUT);
  pinMode(outputPin_B,OUTPUT);

}

void loop() {
  // put your main code here, to run repeatedly:

  int radioSignal = 0;
  radioSignal = pulseIn(inputPin,HIGH);            //Reads the pulsewidth of the input pin


  if (radioSignal > 1700)                          //if switch is up set output A to 5v and B to 0v
  { 
    digitalWrite(outputPin_A,HIGH);
    digitalWrite(outputPin_B,LOW);
  } 
  else if (radioSignal < 1300 && radioSignal > 0)  //if switch is down set output A and B to 5v
  { 
    digitalWrite(outputPin_A,HIGH);
    digitalWrite(outputPin_B,HIGH);
  } 
  else                                             //if switch is centered or no signal set output A and B to 0v
  {
    digitalWrite(outputPin_A,LOW);
    digitalWrite(outputPin_B,LOW); 
  }

}
Reply With Quote
  #2  
Old 06-13-2021, 03:17 PM
Tgrzes Tgrzes is offline
Newbie
 
Join Date: Aug 2020
Posts: 95
Tgrzes is on a distinguished road
Default Re: Switch question

Thanks so much for doing that! Learning arduino is something I’d definitely like to do some day, but it probably won’t be for quite awhile. In the mean time, I just found a couple of these dual relays for $10 each on eBay. They’re exactly what I needed. With the transmitter switch in the center position, both relays are open. Throw the switch in one direction and one relay closes. Throw the switch in the opposite direction and the other relay closes. Thanks again!!
[IMG][/IMG]
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 02:53 AM.


Powered by vBulletin® Version 3.8.6
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.