Rohan Barnwal
Published © GPL3+

Arduino Powered 3D RoboSoccer Car with pro 360 Moves

3D Printed Robosoccer Car: Arduino, Bluetooth, precise 360 turns, 3D Printed Structure

BeginnerFull instructions provided187
Arduino Powered 3D RoboSoccer Car with pro 360 Moves

Things used in this project

Hardware components

4 Cell Lithium Battery Holder
×1
Arduino UNO
Arduino UNO
×1
L289N Motor Driver
×1
Jumper wires (generic)
Jumper wires (generic)
×1
HC-05 Bluetooth Module
HC-05 Bluetooth Module
×1

Software apps and online services

Arduino IDE
Arduino IDE
Arduino Car

Story

Read more

Schematics

Connections

Code

Code

Arduino
char t;                  
bool preciseTurning = false;  

// Motor pins
int in1 = 5;   // Left motor forward
int in2 = 6;   // Left motor reverse
int in3 = 9;   // Right motor forward
int in4 = 10;  // Right motor reverse

void setup() {
  pinMode(in1, OUTPUT);
  pinMode(in2, OUTPUT);
  pinMode(in3, OUTPUT);
  pinMode(in4, OUTPUT);

  Serial.begin(9600); // HC-05 on pins 0 and 1
}

void loop() {
  if (Serial.available()) {
    t = Serial.read();
    Serial.println(t);  // Optional debug

    // Mode toggle
    if (t == 'X') {
      preciseTurning = true;
    } 
    else if (t == 'Y') {
      preciseTurning = false;
    }

    // ---- Main Movement ----
    if (t == 'L') {  // Forward
      digitalWrite(in1, LOW);        
      digitalWrite(in2, HIGH);       
      digitalWrite(in3, HIGH);       
      digitalWrite(in4, LOW);        
    }

    else if (t == 'R') {  // Backward
      digitalWrite(in1, HIGH);       
      digitalWrite(in2, LOW);        
      digitalWrite(in3, LOW);        
      digitalWrite(in4, HIGH);       
    }

    else if (t == 'S') {  // Stop
      digitalWrite(in1, LOW);
      digitalWrite(in2, LOW);
      digitalWrite(in3, LOW);
      digitalWrite(in4, LOW);
    }

    else if (t == 'B') {  // Turn Left
      if (preciseTurning) {
        // In-place rotate left
        digitalWrite(in1, LOW);     
        digitalWrite(in2, HIGH);    
        digitalWrite(in3, LOW);     
        digitalWrite(in4, HIGH);    
      } else {
        // Only left motor ON
        digitalWrite(in1, LOW);
        digitalWrite(in2, HIGH);
        digitalWrite(in3, LOW);
        digitalWrite(in4, LOW);
      }
    }

    else if (t == 'F') {  // Turn Right
      if (preciseTurning) {
        // In-place rotate right
        digitalWrite(in1, HIGH);    
        digitalWrite(in2, LOW);
        digitalWrite(in3, HIGH);    
        digitalWrite(in4, LOW);
      } else {
        // Only right motor ON
        digitalWrite(in1, LOW);
        digitalWrite(in2, LOW);
        digitalWrite(in3, HIGH);
        digitalWrite(in4, LOW);
      }
    }
  }
}

Credits

Rohan Barnwal
37 projects • 35 followers
Rohan Barnwal - maker, hacker, tech enthusiast. I explore new tech & find innovative solutions. See my projects on hackster.io!

Comments