Recon85
Published

Lego Robot

Childhood dreams.

IntermediateWork in progress722
Lego Robot

Things used in this project

Hardware components

Arduino UNO & Genuino UNO
Arduino UNO & Genuino UNO
×1
Arduino motor shield r3
×1
HC-05 Bluetooth Module
HC-05 Bluetooth Module
×1
Dual H-Bridge motor drivers L293D
Texas Instruments Dual H-Bridge motor drivers L293D
×1
Resistor 1k ohm
Resistor 1k ohm
×1
led blue
×2
Lego motor XL
×2
Lego motor L
×2
Lego battery box
×2

Software apps and online services

MIT App Inventor
MIT App Inventor

Story

Read more

Schematics

schemat.jpg

Code

Robo

Arduino
int data;

#define E1 6  // Enable Pin for motor 1
#define E2 9  // Enable Pin for motor 2

#define I1 4  // Control pin 1 for motor 1
#define I2 5  // Control pin 2 for motor 1
#define I3 8  // Control pin 1 for motor 2
#define I4 7  // Control pin 2 for motor 2


void setup() 
{
 Serial.begin(9600); 
//silnik 1
pinMode(12,OUTPUT);
//silnik 2
pinMode(13,OUTPUT);
//reszta
pinMode(2,OUTPUT);
//głowa powieki
    pinMode(E1, OUTPUT); // speed engine 1
    pinMode(E2, OUTPUT); // speed engine 2
    pinMode(I1, OUTPUT);
    pinMode(I2, OUTPUT);
    pinMode(I3, OUTPUT);
    pinMode(I4, OUTPUT);
}

void loop() 
{
 data=Serial.read();
 Serial.println(data);
 delay(200);
 
 if(data==5)
 {
    digitalWrite(12,LOW);
    digitalWrite(13,HIGH);
    analogWrite(3,255);
    analogWrite(11,255);
 }

if(data==6)
{
  
  digitalWrite(12,LOW);
  digitalWrite(13,HIGH);
  analogWrite(3,0);
  analogWrite(11,0);
  
}
if(data==7)
 {
    digitalWrite(12,HIGH);
    digitalWrite(13,LOW);
    analogWrite(3,255);
    analogWrite(11,255);
}
if(data==8)
{
  
  digitalWrite(12,LOW);
  digitalWrite(13,HIGH);
  analogWrite(3,0);
  analogWrite(11,0);
}
if(data==1)
 {
    digitalWrite(12,HIGH);
    digitalWrite(13,HIGH);
    analogWrite(3,255);
    analogWrite(11,255);
 }
 if(data==2)
{
  
  digitalWrite(12,LOW);
  digitalWrite(13,HIGH);
  analogWrite(3,0);
  analogWrite(11,0);
}
if(data==3)
 {
    digitalWrite(12,LOW);
    digitalWrite(13,LOW);
    analogWrite(3,255);
    analogWrite(11,255);
 }
 if(data==4)
{
  
  digitalWrite(12,LOW);
  digitalWrite(13,HIGH);
  analogWrite(3,0);
  analogWrite(11,0);
}

if(data==14)
{
  digitalWrite(2,HIGH);
}
if(data==15)
{
  digitalWrite(2,LOW);
}
if(data==18)
{
analogWrite(E2, 255);
digitalWrite(I3, HIGH);
digitalWrite(I4, LOW);
}
if(data==19)
{
analogWrite(E2, LOW);
}

if(data==20)
{
analogWrite(E2, 255);
digitalWrite(I3, LOW);
digitalWrite(I4, HIGH);
}
if(data==21)
{
analogWrite(E2, LOW);
}

if(data==16)
{
analogWrite(E1, 255);
digitalWrite(I1, HIGH);
digitalWrite(I2, LOW);
delay(100);
analogWrite(E1,LOW);
}
if(data==17)
{
analogWrite(E1, 255);
digitalWrite(I1, LOW);
digitalWrite(I2, HIGH);
delay(100);
analogWrite(E1,LOW);
}
}

Credits

Recon85

Recon85

2 projects • 1 follower

Comments