loading

I want to bring my old RC cars into this century by making them controllable using (digital) wireless and also programmable. I found a quick and simple way to add the lightblue bean to the controller and open up some possibilities without losing the original RC operation.

Step 1: Tap Into the Simple Controller

I had a few controllers and I found the quickest and simplest to work with was an older controller that took two 1.5v AA cells and had a single switch under the hood for each controller action.

I also confirmed that closing the switch to go forward or backward for example is done by grounding a single contact in the remote. This was important because I wanted the simplest kind of interface.

So I opened the controller and wired up + and - to the battery and the four contact points for controlling the car.

The four control points I wired to GPIO 0, 1, 2, 3 on the controller and I sent these to up, down, left, right. I used colorful wires so I chose rainbow-order to keep them straight.

Step 2: Interface to the Bean

I want to use the LED to show what the board is up to, so it wouldn't work to have it closed up inside the controller. So for my purposes I brought the wires through the side of the controller and up into the bean, secured to the front with a mounting square.

I also punted a bit on a power switch because I can disconnect the + jumper from the bean to power things down.

Step 3: Program the Controller

Next, I opened the Lightblue bean loader app on an ipad and used it to upload this code to the board.

Notice this sample only uses the accelerometer. I will add code to disable the accelerometer and receive commands over bluetooth in the future when I make the link possible from a cellphone.

Also notice the way I activate the buttons is by setting the line to be an output and setting it low. This grounds the output and allows the controller to detect a buttonpress. When it's not being pressed, I change the button to be an input so it doesn't assert anything on the line.

I did notice this trick only works on a this low-voltage controller. On a controller that uses a 9v battery, the bean doesn't offer enough resistance and the controller thinks the button is always pressed. So it's another reason (in addition to avoiding the need for a 3.3v regulator) to go with a low-voltage controller.

Also the LED is green when driving forward, blue when backward, and red when stopped. This was helpful when debugging what the bean was trying to send.

I'm not sure why the code appears in multiple code boxes, but it should copy/paste out properly.

void setup() {
    // initialize serial communication at 57600 bits per second:
    Serial.begin(57600);
}
void output(int16_t d, int16_t v) {
    if(v==0) {
        pinMode(d, OUTPUT);
        digitalWrite(d, LOW);
    } else {
        pinMode(d, INPUT_PULLUP);
    }
}
void loop() {
    int16_t threshold = 8;
    Bean.setLed(0,0,0);
    
    AccelerationReading accel = Bean.getAcceleration();
    int16_t side = (accel.xAxis)/8;
    int16_t drive = (accel.yAxis)/8;
    if(drive < -threshold) {
        output(0,0);
        output(1,1);
        Bean.setLedGreen(100);
    } else if(drive > threshold) {
        output(1,0);
        output(0,1);
        Bean.setLedBlue(100);
    } else {
        output(0,1);
        output(1,1);
        Bean.setLedRed(abs(drive));
    }
    if(side < -threshold) {
        output(2,1);
        output(3,0);
    } else if(side > threshold) {
        output(3,1);
        output(2,0);
    } else {
        output(2,1);
        output(3,1);
    }

    Bean.sleep(250);
}
<p>Very cool! </p>

About This Instructable

753views

13favorites

License:

More by BradM5:Lightblue bean-driven RC car mod 
Add instructable to: