Things used in this project

Schematics

Car diagram
Easy diagram
Carro prototipo bb fxyqfnke0n

Code

Arduino car codeArduino
Please use with Blynk App
#define BLYNK_PRINT Serial
#include <BlynkSimpleCurieBLE.h>
#include <CurieBLE.h>

char auth[] = "5733e53afff240d79e49d7acc0849faa";

BLEPeripheral  blePeripheral;

const int DIR_A1 = 4;
const int DIR_B1 = 5;
const int PWM1 = 6;
const int DIR_A2 = 7;
const int DIR_B2 = 8;
const int PWM2 = 9;
const int luz = 13;
int pinValue1=0,pinValue2=0,pinValue3=0,pinValue4=0;
bool cambio=LOW;
byte random1;
const byte pin1=10,pin2=11,pin3=12,pin4=13;
long currentMillis;
long previousMillis = 0; 
bool estado=LOW;

BLYNK_WRITE(V1)
{
  pinValue1 = param.asInt(); // assigning incoming value from pin V1 to a variable

}
BLYNK_WRITE(V2)
{
  pinValue2 = param.asInt(); // assigning incoming value from pin V1 to a variable

}
BLYNK_WRITE(V3)
{
  pinValue3 = param.asInt(); // assigning incoming value from pin V1 to a variable

}
BLYNK_WRITE(V4)
{
  pinValue4 = param.asInt(); // assigning incoming value from pin V1 to a variable

}

void setup()
{
  // Debug console
  Serial.begin(9600);
  pinMode(DIR_A1, OUTPUT);
  pinMode(DIR_B1, OUTPUT);
  pinMode(PWM1, OUTPUT);
  pinMode(DIR_A2, OUTPUT);
  pinMode(DIR_B2, OUTPUT);
  pinMode(PWM2, OUTPUT);
  pinMode(luz, OUTPUT);
  pinMode(pin1,OUTPUT);
  pinMode(pin2,OUTPUT);
  pinMode(pin3,OUTPUT);
  pinMode(pin4,OUTPUT);
  delay(1000);

  blePeripheral.setLocalName("Blynk");
  blePeripheral.setDeviceName("Blynk");
  blePeripheral.setAppearance(384);

  Blynk.begin(blePeripheral, auth);

  blePeripheral.begin();

  Serial.println("Waiting for connections...");
  
}

void loop()
{
  blePeripheral.poll();
  Blynk.run();
  digitalWrite(luz, HIGH);
 if(pinValue1==1)
 {
 digitalWrite(DIR_A1, LOW);
 digitalWrite(DIR_B1, HIGH);
 digitalWrite(DIR_A2, LOW);
 digitalWrite(DIR_B2, HIGH);
 analogWrite(PWM1, 255);
 analogWrite(PWM2, 255);
 }
 else if(pinValue2==1)
 {
  cambio=HIGH;
 digitalWrite(DIR_A1, HIGH);
 digitalWrite(DIR_B1, LOW);
 digitalWrite(DIR_A2, HIGH);
 digitalWrite(DIR_B2, LOW);
 analogWrite(PWM1, 255);
 analogWrite(PWM2, 255);
 }

else if(pinValue3==1)
 {
 cambio=HIGH;
 digitalWrite(DIR_A1, HIGH);
 digitalWrite(DIR_B1, LOW);
 digitalWrite(DIR_A2, LOW);
 digitalWrite(DIR_B2, HIGH);
 analogWrite(PWM1, 100);
 analogWrite(PWM2, 255);
 }

else if(pinValue4==1)
 {
 cambio=HIGH;
 digitalWrite(DIR_A1, LOW);
 digitalWrite(DIR_B1, HIGH);
 digitalWrite(DIR_A2, HIGH);
 digitalWrite(DIR_B2, LOW);
 analogWrite(PWM1, 255);
 analogWrite(PWM2, 100);
 } 

else if(pinValue1==0 && pinValue2==0 && pinValue3==0 && pinValue4==0 )
 {
 digitalWrite(DIR_A1, HIGH);
 digitalWrite(DIR_B1, LOW);
 digitalWrite(DIR_A2, HIGH);
 digitalWrite(DIR_B2, LOW);
 analogWrite(PWM1, 0);
 analogWrite(PWM2, 0);
 }
 random1 = random(10,14);
 currentMillis = millis();
      // if 10s have passed, check the sensor:
      if (currentMillis - previousMillis >= 500) {
        previousMillis = currentMillis;
        estado = ! estado ;                       // cambiamos el estado
        digitalWrite(random1, estado) ;            // escribimos el nuevo valor
          }

}

Credits

Soka cdsdtvc7fp
Alexis Santiago Allende

Im a person who since young feel a passion for electronics, I also like to cook pizza and travel. Now Im working on the internet of things

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

Similar projects you might like

Using CA and CC RGB LED by Current Sourcing and Sinking!
Easy
  • 340
  • 23

Protip

RGB LEDs are of two types, common cathode and common anode which behave differently with same Arduino code; how to resolve this.

Arduino Amiga Floppy Disk Reader
Easy
  • 1,993
  • 5

Work in progress

An Arduino powered floppy disk controller and reader for making disk images from old AmigaDOS floppy disks.

Micro:bit Moisture sensor
Easy
  • 155
  • 4

Protip

In this quick and easy project, you build a micro:bit moisture sensor

3D-Printed, Internet-Controlled, Self-Balancing FPV Robot
Easy
  • 1,607
  • 22

Full instructions

Open source telepresence robot that keeps its balance on two wheels. Controlled from UI in the web browser.

Arduino Controlled USB Trackpad
Easy
  • 2,561
  • 4

Full instructions

I really want to make a Raspberry Pi laptop but just can't find the right size trackpad so in this project we will be salvaging an old one.

Arduino - Web-Based Keypad
Easy
  • 3,782
  • 33

Full instructions

Remotely controlling Arduino by using web-based keypad.

ProjectsCommunitiesTopicsContestsLiveAppsBetaFree StoreBlogAdd projectSign up / Login