Marco
Published © GPL3+

RC Pololu 3Pi

Building a RC controlled Pololu (3Pi), using a couple of TX/RX 433Mhz modules and a Joystick.

IntermediateFull instructions provided1 hour3,314
RC Pololu 3Pi

Things used in this project

Hardware components

Pololu 3Pi
×1
Arduino UNO
Arduino UNO
You can use any type of Arduino. You only have to check that it supports the radio module
×1
433 KHz RX+TX Radio modules
In this project I'll use this modules. You can use any type of radios that supports VirtualWire
×1
Male/Female Jumper Wires
Male/Female Jumper Wires
×1
Pololu AVR Programmer
I'll use this programmer to program the Pololu. This is the original programmer, but you can use any type of compatible programmers
×1
SparkFun Thumb Joystick Breakout
SparkFun Thumb Joystick Breakout
×1

Software apps and online services

Arduino IDE
Arduino IDE

Story

Read more

Schematics

Arduino TX.fzz

Pololu RX.fzz

Code

TX Radio Arduino Code

Arduino
This is the code to upload to the Arduino that sends Joystick's values through the TX radio module
// tx.ino
//
// Using any Arduino board compatible with radio modules to send Jostick data to Pololu robot
// 
// Author: Marco Veneziano (macvenez@gmail.com)
// Following library example of Mike McCauley (mikem@airspayce.com)

#include <VirtualWire.h>
const int led_pin = 13;
const int transmit_pin = 12;

void setup()
{
    // Initialise the IO and ISR
    vw_set_tx_pin(transmit_pin);
    vw_set_ptt_inverted(true); // Required for DR3100
    vw_setup(9000);       // Bits per sec
    pinMode(led_pin, OUTPUT);
    pinMode(A0, INPUT);
    pinMode(A1, INPUT);
}

void loop()
{
  char msg[2] = {};

  msg[0] = map(analogRead(A0),0,1023,0,9);
  msg[1] = map(analogRead(A1),0,1023,0,9);
  digitalWrite(led_pin, HIGH); // Flash a light to show transmitting
  vw_send((uint8_t *)msg, 2);
  vw_wait_tx(); // Wait until the whole message is gone
  digitalWrite(led_pin, LOW);
  delay(10);
}

RX Radio Pololu 3Pi Code

Arduino
This is the code to upload to the Pololu 3Pi that receives Joystick's values through the RX radio module
// rx.ino
//
// Using the Pololu as RC car controlled by the other radio module
// 
// Author: Marco Veneziano (macvenez@gmail.com)
// Following library example of Mike McCauley (mikem@airspayce.com)
#include <OrangutanLCD.h>
#include <OrangutanMotors.h>
OrangutanLCD lcd;
OrangutanMotors motors;
#include <VirtualWire.h>

const int receive_pin = 0;
int val[2];

void setup()
{
    lcd.clear();
    delay(1000);
    Serial.println("setup");

    // Initialise the IO and ISR
    vw_set_rx_pin(receive_pin);
    vw_set_ptt_inverted(true); // Required for DR3100
    vw_setup(9000);  // Bits per sec

    vw_rx_start();       // Start the receiver PLL running
}

void loop()
{ 
    uint8_t buf[VW_MAX_MESSAGE_LEN];
    uint8_t buflen = VW_MAX_MESSAGE_LEN;

    if (vw_get_message(buf, &buflen))
    {
  int i;
  
  for (i = 0; i < buflen; i++)
  {
      val[0] = buf[0];
      val[1] = buf[1];
  }
 lcd.clear();
 lcd.gotoXY(0, 0); 
 lcd.print(val[0]);
 lcd.gotoXY(0, 1); 
 lcd.print(val[1]);
 if(val[0] == 4 && val[1] == 4){
 motors.setSpeeds(0, 0);
 }
 else{
  int forward=map(val[0],0, 9, -255, 255);
   motors.setSpeeds(forward-map(val[1],9, 0, 0, 100), forward-map(val[1],0, 9, 0, 100));
 }
    }
}

Credits

Marco

Marco

4 projects • 0 followers

Comments