memoryleak
Published © MIT

Autopilot v1.0 Road Sign Recognition

Use Pixy2 and Arduino to train your robot car to follow road signs!

IntermediateFull instructions provided3 hours1,072

Things used in this project

Hardware components

Pixy2 CMUcam5 Smart Vision Sensor
×1
Seeed Robot car Kit- RC Smart Car Chassis Kit
×1
Seeeduino V4.2
Seeeduino V4.2
×1
Base Shield V2
Seeed Base Shield V2
×1

Software apps and online services

Arduino IDE
Arduino IDE
PixyMon V2

Hand tools and fabrication machines

Hot glue gun (generic)
Hot glue gun (generic)

Story

Read more

Schematics

Arduino pixy and motordriver connection

remember to set the pwm and dir pin correctly

Code

Arduino

Arduino
Code for autopilot based on the detected road sign
#include <Pixy2.h>
#include <Servo.h>
#include "CytronMotorDriver.h"

// Configure the motor driver.
CytronMD motor(PWM_DIR, 3, 2); // PWM = Pin 3, DIR = Pin 2.

Servo myservo;
// This is the main Pixy object
Pixy2 pixy;
int carSpeed;
void setup()
{
    Serial.begin(115200);
    myservo.attach(6); // specify the servo pin

    pixy.init();
    Serial.println(pixy.changeProg("line")); //change pixy to line mode
}

void loop()
{
    pixy.line.getAllFeatures(); //get line features

    if (pixy.line.barcodes) // detected road sign
    {
        int code = pixy.line.barcodes[0].m_code;
        switch (code)
        {
        case 0:             // stop
            carSpeed = 0;    
            myservo.write(70);
            break;

        case 1:             //u turn
            motor.setSpeed(40);
            myservo.write(115);
            delay(3600);
            break;

        case 3:             //turn left
            motor.setSpeed(42);
            myservo.write(25);
            delay(1800);
            break;

        case 4:
            carSpeed = 32; // go straight
            myservo.write(70);
            break;

        default:
            break;
        }
    }
    motor.setSpeed(carSpeed); // keep going straight if no road signs are detected
    myservo.write(70);
}

Credits

memoryleak

memoryleak

5 projects • 5 followers
A soft and hardware engineer motivated by interest and fun

Comments