Lorenzo_Botta_2002MATTIA SCARZELLO
Published © GPL3+

GiocattolINO

A small car controlled by smartphone, made with arduino and bluetooth sensor

IntermediateProtip271
GiocattolINO

Things used in this project

Hardware components

Ultrasonic Sensor - HC-SR04 (Generic)
Ultrasonic Sensor - HC-SR04 (Generic)
×1
HC-05 Bluetooth Module
HC-05 Bluetooth Module
×1
Arduino UNO & Genuino UNO
Arduino UNO & Genuino UNO
×1
AA Batteries
AA Batteries
×8
Battery Holder, AA x 8
Battery Holder, AA x 8
×1
Dual H-Bridge motor drivers L298
SparkFun Dual H-Bridge motor drivers L298
×1
LED (generic)
LED (generic)
×1
DC Motor, 12 V
DC Motor, 12 V
×2
Jumper wires (generic)
Jumper wires (generic)
×1

Software apps and online services

Arduino Bluetooth RC Car
Arduino IDE
Arduino IDE
Fusion 360
Autodesk Fusion 360

Hand tools and fabrication machines

Multitool, Screwdriver
Multitool, Screwdriver
Hot glue gun (generic)
Hot glue gun (generic)
Soldering Station, 110 V
Soldering Station, 110 V
Laser cutter (generic)
Laser cutter (generic)

Story

Read more

Custom parts and enclosures

Car base

This Car Base will be cut with Laser Machine

Schematics

Electrical connection

it is the electrical connection of the circuit, with all the useful components

Code

GiocattolINO Code

Arduino
#include <NewPing.h>
  
int motor_left_f = 5;  // Pin  in1 of L298
int motor_left_b = 6;  // Pin  in2 of L298
int motor_right_f  = 10;  // Pin in3 of L298
int motor_right_b  = 11;  // Pin in4 of L298 
int state;
int vSpeed=200;
int LED = 13;
#define TRIGGER_PIN  12
#define ECHO_PIN     8
#define MAX_DISTANCE 200
NewPing sonar(TRIGGER_PIN, ECHO_PIN, MAX_DISTANCE); 

void setup() {
  pinMode(motor_left_f, OUTPUT);
  pinMode(motor_left_b, OUTPUT);
  pinMode(motor_right_f, OUTPUT);
  pinMode(motor_right_b, OUTPUT);
  pinMode(LED, OUTPUT);
  Serial.begin(9600);
}
 
void loop() {
    if (sonar.ping_cm() < 50){
      digitalWrite(LED, HIGH);
    }
    else{
      digitalWrite(LED, LOW);
    }
    if(Serial.available() > 0){     
      state = Serial.read();  
      Stop(); 
    }
  /***********************forward****************************/
    if (state == 'F') {
      analogWrite(motor_left_f, 200); 
      analogWrite(motor_left_b, 0);
      analogWrite(motor_right_f, 200);      
      analogWrite(motor_right_b, 0); 
    }
  /***********************backward****************************/
    else if (state == 'B') {
      analogWrite(motor_left_f, 0);   
      analogWrite(motor_left_b, 200); 
      analogWrite(motor_right_f, 0);  
      analogWrite(motor_right_b, 200); 
    }
  /***************************left*****************************/
    else if (state == 'L') {
      analogWrite(motor_left_f, 0);    
      analogWrite(motor_left_b, 0); 
      analogWrite(motor_right_f, 200); 
      analogWrite(motor_right_b, 0); 
    }
  /***************************right*****************************/
    else if (state == 'R') {
      analogWrite(motor_left_f, 200);   
      analogWrite(motor_left_b, 0); 
      analogWrite(motor_right_f, 0);   
      analogWrite(motor_right_b, 0);     
    }
      /***************************forward left*****************************/
    else if (state == 'G') {
      analogWrite(motor_left_f, 100);    
      analogWrite(motor_left_b, 0); 
      analogWrite(motor_right_f, 200); 
      analogWrite(motor_right_b, 0); 
    }
  /***************************forward rght*****************************/
    else if (state == 'I') {
      analogWrite(motor_left_f, 200);   
      analogWrite(motor_left_b, 0); 
      analogWrite(motor_right_f, 100);   
      analogWrite(motor_right_b, 0);     
    }
  /************************Stop*****************************/
    else if (state == 'P'){
        analogWrite(motor_right_f, 0);  
        analogWrite(motor_right_b, 0); 
        analogWrite(motor_left_f, 0);  
        analogWrite(motor_left_b, 0);      
    }
}
void Stop() {
  analogWrite(motor_right_f, 0);    
  analogWrite(motor_right_b, 0); 
  analogWrite(motor_left_f, 0); 
  analogWrite(motor_left_b, 0);
}

Credits

Lorenzo_Botta_2002

Lorenzo_Botta_2002

0 projects • 0 followers
MATTIA SCARZELLO

MATTIA SCARZELLO

0 projects • 0 followers

Comments