Things used in this project

Hardware components:
Old RC car
×1
Arduino Motor Shield
http://arduino.cc/en/Main/ArduinoMotorShieldR3
×1
Udoo cam 5mp
UDOO Camera Module
×1
Stepped motors
×2
2
UDOO DUAL
A Wifi-enabled model is required
×1
1434509556 android phone color
Android device
×1

Code

code.txtPlain text
sudo apt-get install libgstreamer0.10-dev libgstrtspserver-0.10-dev build-essential git
code.txtPlain text
sudo apt-get install wicd-curses wireless-tools
code.txtBatchFile
CPPFLAGS += -I. -I$(top_builddir)/include -I/usr/include/gstreamer-0.10 -I/usr/include/glib-2.0 -I/usr/lib/arm-linux-gnueabihf/glib-2.0/include -I/usr/include/libxml2 -I/usr/lib/glib-2.0/include -I/usr/include/gstreamer-0.10/gst/rtsp-server/
OBJ = rtsptest.o

%.o: %.c $(DEPS)
    $(CC) -c -o $@ $< $(CPPFLAGS)

rtsptest: $(OBJ)
    $(CC) -o $@ $^ $(LDFLAGS) $(CPPFLAGS) -pthread -lstdc++ -lgstreamer-0.10 -lgstrtsp-0.10 -lgstrtspserver-0.10 -lgobject-2.0 -lgmodule-2.0 -lgthread-2.0 -lrt -lxml2 -lglib-2.0 -lm

clean:
    rm *.o
    rm test
code.txtPlain text
ln -s /dev/ttymxc3 /dev/ttyS0           
sleep 60s
/carmadillo/rtspserver/rtsptest &       
java -jar /carmadillo/carmadillo.jar      
exit 0
code.txtC/C++
#include <stdio.h>
#include <Servo.h>

#define DIR_A 12
#define BRAKE_A 9
#define SPEED_A 3
#define DIR_B 13
#define BRAKE_B 8
#define SPEED_B 11

Servo panServo;
Servo tiltServo;
byte pan = (byte)90;   // init servo values
byte tilt = (byte)40;
boolean received = false;
int initSerialGarbage = 0;
int msg1garbage = 55;
int msg2garbage = 29;
int msg4garbage = 124;

void setup()
{
    // set communiation speed
    Serial.begin(230400);   
    pinMode(DIR_A, OUTPUT);
    pinMode(BRAKE_A, OUTPUT);
    pinMode(SPEED_A, OUTPUT);
    pinMode(DIR_B, OUTPUT);
    pinMode(BRAKE_B, OUTPUT);
    pinMode(SPEED_B, OUTPUT);
    digitalWrite(BRAKE_A, HIGH);
    analogWrite(SPEED_A, 0);
    printf("\r\Carmadillo serial start\r\n");
    panServo.attach(5);
    tiltServo.attach(6);
    delay(50);
    panServo.write(pan);
    tiltServo.write(tilt);
}

#define RCVSIZE 5

void loop()
{
    byte incomingByte = 0;
    uint8_t msg[RCVSIZE];
    uint32_t nbread = 0; 
    
    while (Serial.available() > 0) {
        // read the incoming byte:
        incomingByte = Serial.read();
        msg[nbread] = incomingByte;
        nbread++;
       // Serial.println(incomingByte);
        received = true;
        initSerialGarbage ++;
    } 

   if (received && initSerialGarbage > 5) {
     /*Serial.print("msg0: ");Serial.println(msg[0]);
     Serial.print("msg1: ");Serial.println(msg[1]);
     Serial.print("msg2: ");Serial.println(msg[2]);
     Serial.print("msg3: ");Serial.println(msg[3]);
     Serial.print("msg4: ");Serial.println(msg[4]); */

     if (msg[0] > 30 && msg[0] < 90){  // direction
        //digitalWrite(BRAKE_B, HIGH);
        analogWrite(SPEED_B, 0);
     } else if (msg[0] <= 30 && msg[0] > 0){
        digitalWrite(DIR_B, HIGH);
        digitalWrite(BRAKE_B, LOW);
        analogWrite(SPEED_B, 255);
     } else if (msg[0] >= 90){
        digitalWrite(DIR_B, LOW);
        digitalWrite(BRAKE_B, LOW);
        analogWrite(SPEED_B, 255);
     }

     if (msg[1] == 0 || msg[1] == 63){  // speed
        digitalWrite(BRAKE_A, HIGH);
        analogWrite(SPEED_A, 0);
     } else if (msg[1] < 63 && msg[1] > 0 && msg[1] != msg1garbage){
        digitalWrite(DIR_A, LOW);
        digitalWrite(BRAKE_A, LOW);
        analogWrite(SPEED_A, 127 - msg[1]);
     } else if (msg[1] > 63 && msg[1] < 128){
        digitalWrite(DIR_A, HIGH);
        digitalWrite(BRAKE_A, LOW);
        analogWrite(SPEED_A, msg[1]); 
     }

     if(msg[2] == 0 || msg[2] == 63){
     }if(msg[2] < 30 && msg[2] > 0 && msg[2] != msg2garbage){
         pan += 3;            // inverted axes
         if (pan > 170) pan = 170;
     } else if(msg[2] > 90){
         pan -= 3;
         if (pan < 5) pan = 5;
     }

     if(msg[3] == 0 || msg[3] == 63){
     }else if(msg[3] < 30 && msg[3] > 0){
         tilt += 3;  
         if (tilt > 125) tilt = 125;
     } else if(msg[3] > 90){
         tilt -= 3;
         if (tilt < 10) tilt = 10;
     } 

     if(msg[4] != 0 && msg[4] != msg4garbage) {
       if(msg[4] == 1){
         pan = 90;
         tilt = 40;
       }
     }

     panServo.write(pan);
     tiltServo.write(tilt); 
     received = false;
   } 
   delay(20);
}
Github
https://github.com/UDOOProjects/CarmadilloMk1/tree/master/CARMadilloDUE

Credits

Michelangelon2
Michelangelo Guarise

Founder @ volumio.org , passionate maker, unpredictable developer, misunderstood creative. I do stuff, I build things.

Replications

Did you replicate this project? Share it!

I made one

Love this project? Think it could be improved? Tell us what you think!

Give feedback

Comments

Similar projects you might like

CarPC Android 
  • 20,818
  • 83

Full instructions

Android board computer for vehicles using UDOO

Benson
  • 2,234
  • 31

Full instructions

A sassy virtual assistant, with Wolfram API access and real-world control

Baby Room Automation
  • 19,503
  • 109

Work in progress

Baby room automation and monitoring with Udoo.

HomeController
  • 6,928
  • 28

Full instructions

Coordinate networked sensors with this UDOO-based system

UDOO All-in-one Case
  • 2,782
  • 4

Work in progress

Elegant all-in-one UDOO based computer that is compact, easy to assemble and move around

X-EMS
  • 1,273
  • 11

Full instructions

The world's first ECU, that's also a eXpandable, eXtendable, and 100% open electronic management platform!

Add projectSign up / Login
Respect project