Build an electric car with Arduino and Bluetooth control or IR (infrared)

ArduinoCar

Infrared Version: Electronic Car, mounting hardware and demo

 


You can easily create a project with Arduino electronics to create a car with infrared control without cable! Objects used for this project:
colored LEDs.
1 servo motor.
1 Arduino development board.
1 ProtoShield extension.
4 engines.
1 bluetooth device
1 distance sensor detector
resitences, jump cables and 1 USB power cable.

Version smartphone: Electronic Car, mounting hardware and demo

 

 


You can easily create a project with Arduino electronics to create a car with Bluetooth and order it with your smartphone without cable!
The viedo is made for educational title and any commercial copy of the product is not permitted. Only personal copies are allowed.

Full source code:


#include 
#include 
#include 
#define CE_PIN   9
#define CSN_PIN 10

const uint64_t pipe = 0xE8E8F0F0E1LL; // Define the transmit pipe=

//int ledPinonoff = 3;
int pin_num=0;
String readString;
int speed=0;

// L9110 connections
#define L9110_A_IA 3 // Pin D10 --> Motor A Input A
#define L9110_A_IB 4 // Pin D11 --> Motor A Input B

#define L9110_B_IA 5 // Pin D10 --> Motor B Input A
#define L9110_B_IB 6 // Pin D11 --> Motor B Input B

// Motor Speed & Direction
#define MOTOR_B_PWM L9110_B_IA // Motor PWM Speed
#define MOTOR_B_DIR L9110_B_IB // Motor Direction

#define MOTOR_A_PWM L9110_A_IA // Motor PWM Speed
#define MOTOR_A_DIR L9110_A_IB // Motor Direction


int ledPin1 = A0;
int ledPin2 = A1;

int Car_state = 0;

void lightderriere(){
  analogWrite(ledPin2,130);digitalWrite(ledPin1,LOW);
}
void lightdevant(){
  digitalWrite(ledPin2,LOW);analogWrite(ledPin1,130);
}
void lightoff(){
  digitalWrite(ledPin2,LOW);digitalWrite(ledPin1,LOW);
}
void setup() {
  Serial.begin (9600);
  Serial.println("Start");
  pinMode( ledPin1, OUTPUT );pinMode( ledPin2, OUTPUT );
}
void up()
{
    if(speed<250)speed +=10;
    //analogWrite(ledPinonoff, speed);
    Serial.println(speed);
    digitalWrite( MOTOR_A_DIR, HIGH ); // direction = forward
    analogWrite( MOTOR_A_PWM, speed ); // PWM speed = 60
    digitalWrite( MOTOR_B_DIR, HIGH ); // direction = forward
    analogWrite( MOTOR_B_PWM, speed ); // PWM speed = 60
    
    lightdevant();
}
void down()
{
   if(speed>=10) speed -=10;
   //analogWrite(ledPinonoff, speed);
   Serial.println(speed);
   lightderriere();
}
void loop() {
  while (Serial.available()) {
    delay(3);  
    char c = Serial.read();
    readString += c; 
  }
  if (readString == "less"){
   if(speed>=10) speed -=10;//sensorValue = analogRead(sensorPin);
    //analogWrite(ledPinonoff, speed);
  }
  if (readString == "more"){
    if(speed<=250)speed +=10;
    //analogWrite(ledPinonoff, speed);
  }
  if (readString == "on"){
    //analogWrite(ledPinonoff, HIGH);
    up();
    Serial.write("LEDs ON");
  }
  if (readString == "off"){
   // digitalWrite(ledPinonoff, LOW);
    down();
    Serial.write("LEDs OFF");
  }
  if (readString == "up"){
    up();
  }
  if (readString == "down"){
    down();
  }
  if (readString == "left"){
    analogWrite(11, speed);
    Serial.write("LEDs OFF");
  }if (readString == "right"){
    analogWrite(11, speed);
  }
  readString="";
}

 

Tags

IR   Infra Red   Bluetooth   Arduino   Car   android   iOs  
(0)
مجاني
معلومات المبرمج
مقدم من ISN Services
83 rue nationale, Tavaux,