Thursday, February 16, 2012

Trigger Buttons with Arduino

This post is a sort of preliminary to the Arduino RC car im working on. I need some way to control the RC car and i figured it would be easier to just trigger the buttons on the remote(as they aren't true analog joytsticks, just joy sticks with springy buttons). Here i will explain the two types of button you will most likely find in a circuit. I am interfacing with a 3v circuit in this case.


Button pulled down to GND
This method is much easier to toggle and is what my RC remote has. One side of the so called "button" is connected to GND, the other is connected to the IC of the TX. The pin of RC transmitter IC that the button is connected to is:  +3v when the button is open and 0v when closed. so that means the button is "pulled" down to ground when closed. To trigger this button with a Arduino, it is quite easy; all that is needed for this type of switch is a diode from the RC transmitter IC pin to a Arduino digital pin. Then the following code. I believe the pin only needs to be set LOW once (the first line of code) but im not sure.

digitalWrite(RCtxBtn, LOW); // RCtxBtn is the number of the digital pin
  pinMode(RCtxBtn, OUTPUT);  // Pull the signal low to activate button
  delay(500);  // Wait half a second
  pinMode(RCtxBtn, INPUT);  // Release the button.
  delay(500);  // Wait half a second


Button pulled up to +3v
This method, on the other hand, is a little harder to implement, but still easily done. This method is used when the IC side of the switch when open is GND and the other side is +3v. Then when the button is pressed, both sides become  +3v  So that means the button is "pulled" up to  +3v  when closed. to trigger a button like this with a Arduino, a resistor and PNP transistor are needed. the PNP has thee pins; Emitter, Base, and Collector. Emitter is the "input", Collector is the "output", and the Base triggers the flow of current from the Emitter to the Collector. Emitter is connected to  +3v , Collector to the IC side of the switch, and Base is connected to a 10k resistor and then Arduino Digital pin.

pinMode(RCtxBtn, OUTPUT);
  digitalWrite(RCtxBtn, LOW); //trigger the button, yes LOW is "on"
  delay(5000); //on for 5 sec
  digitalWrite(RCtxBtn, HIGH); //release button
  delay(5000); //off for 5 sec


Visual Explanation:


4 comments:

  1. Dear Jordan!
    As I understood, the way you simulate the feature of a real buttonswitch, is that you use a diode to connect the digital pin of the Arduino with the high level pin of the transmitter IC. Then you pull the digital pin low. (The diode is missing in the attached picture however).
    I try Ur solution.
    Thank You for your rapid answer btw! ;)
    Yours
    Gergo

    ReplyDelete
    Replies
    1. This comment has been removed by the author.

      Delete
    2. no, the diode is there, its black with the grey strip (showing direction of flow) right outside the black box.

      Delete