Things used in this project

Hardware components:
DFRobot MiniQ Chassis
×1
Texas instruments l293dne image
Texas Instruments Dual H-Bridge motor drivers L293D
×1
11026 02
Jumper wires (generic)
×1
5v Regulator
×1
1800 mAh 11.7V LiPo Battery
×1
13711 01
SparkFun ESP8266 Thing - Dev Board
×1
Omron b3f 1000 image 75px
SparkFun Pushbutton switch 12mm
×3
DFRobot Raspberry Pi 3
×1
DFRobot Raspberry Pi Camera Module
×1
Software apps and online services:
Ide web
Arduino IDE
Hand tools and fabrication machines:
3drag
3D Printer (generic)

Custom parts and enclosures

Battery Platform

Schematics

Schematic of Robot
Schematic bb 2ixkgdvcqw

Code

Controller GoodC/C++
#include <Arduino.h>
#include <ESP8266WiFi.h>
#include <ESP8266WiFiMulti.h>

#include <ESP8266HTTPClient.h>

ESP8266WiFiMulti WiFiMulti;

#define SSID "SSID"
#define PSSWD "PASSWORD"

int pins[3] = {12,13,4};

void setup() {
  // put your setup code here, to run once:
  Serial.begin(9600);
  for(int i=0; i<3;i++){
    pinMode(pins[i], INPUT_PULLUP);
  }
  WiFiMulti.addAP(SSID, PSSWD);
}

void loop() {
  // put your main code here, to run repeatedly:
  int motor1, motor2;
  if(digitalRead(pins[0])==0){ //Turn left
    Serial.println("left");
    motor1 = 50;
    motor2 = 50;
  }
  else if(digitalRead(pins[1])==0){ //Go forward
    Serial.println("forward");
    motor1 = 50;
    motor2 = -50;
  }
  else if(digitalRead(pins[2])==0){ //Turn right
    Serial.println("right");
    motor1 = -50;
    motor2 = -50;
  }
  else{
    motor1 = 0;
    motor2 = 0;
  }
  
  if(WiFiMulti.run() == WL_CONNECTED){
    HTTPClient http;
    http.begin("http://<RaspberryPiIP:5000/control/");
    http.addHeader("Content-Type", "application/json");
    int httpCode = http.POST("{\"motor1\":"+String(motor1)+", \"motor2\":"+String(motor2)+"}");
    String payload = http.getString();
    Serial.print('\t');
    Serial.println(httpCode);
    Serial.println(payload);
  }
  delay(40);
}
Robot CodePython
from flask import *
import RPi.GPIO as GPIO
import subprocess
import shlex

p=subprocess.Popen(shlex.split('./mjpg_streamer -o "output_http.so -w ./www" -i "input_raspicam.so"'))

app=Flask(__name__)
GPIO.setmode(GPIO.BCM)
motor_array = [6,5,19,13]
for pin in motor_array:
    GPIO.setup(pin, GPIO.OUT)
motorL1_pwm = GPIO.PWM(6, 100)
motorL2_pwm = GPIO.PWM(5, 100)
motorR1_pwm = GPIO.PWM(19, 100)
motorR2_pwm = GPIO.PWM(13, 100)
motorL1_pwm.start(0)
motorL2_pwm.start(0)
motorR1_pwm.start(0)
motorR2_pwm.start(0)

def turn_wheel(motor1, motor2):
    motor1 = motor1 / 2
    motor2 = motor2 / 2
    
    if motor1<0:
        motorL2_pwm.ChangeDutyCycle(motor1*-1)
        motorL1_pwm.ChangeDutyCycle(0)#make positive if negative
    else:
        motorL1_pwm.ChangeDutyCycle(motor1)
        motorL2_pwm.ChangeDutyCycle(0)
        
    if motor2<0:
        motorR2_pwm.ChangeDutyCycle(motor2*-1)
        motorR1_pwm.ChangeDutyCycle(0)#make positive if negative
    else:
        motorR1_pwm.ChangeDutyCycle(motor2)
        motorR2_pwm.ChangeDutyCycle(0)

@app.route("/control/", methods=['GET','POST'])
def control():
    data = request.get_json()
    motor1 = data['motor1']
    motor2 = data['motor2']
    turn_wheel(motor1, motor2)
    print("Motor 1 value is: "+str(motor1)+", motor 2 value is: "+str(motor2))
    return "ACK"
if __name__=="__main__":
    try:
        app.run(host='0.0.0.0')
    except KeyboardInterrupt: 
        p.terminate()
        pass

Credits

Download
Arduino “having11” Guy
24 projects • 153 followers
I love creating cloud solutions that can interact with hardware along with using Arduino boards and Raspberry Pis to create new projects.
Contact

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

Sign up / LoginProjectsPlatformsTopicsContestsLiveAppsBetaBlog