Carro Todo Terreno Arduino
Carro "Todo Terreno" :) Tutorial completo: https://youtu.be/BqBb3FfbrHk
Materiales:
(12) tornillo M3-25mm cabeza Allen cónica
(13) tuerca M3
(6) tornillo M6-25mm cabeza Allen cónica
(8) tornillo M3-10mm cabeza Allen cónica
(3) tornillo M3-10mm cabeza hexagonal
(1) tornillo M3-16mm cabeza hexagonal
(1) arandela M3
(2) ligas
Componentes:
(1) Arduino Nano
(2) L293D puente H
(1) L7805CV regulador de voltaje 5VDC
(1) L7809CV regulador de voltaje 9VDC
(1) Módulo Bluetooth HC06 esclavo
(1) HC-SR04 Sensor de ultrasonido
(6) Motor reductor 3-6V + Llantas
#define motorPin1 7 // Pin de control del motor 1
#define motorPin2 8 // Pin de control del motor 2
#define motorPin3 2 // Pin de control del motor 3
#define motorPin4 4 // Pin de control del motor 4
#define TRIGGER_PIN 11 // Pin de disparo del sensor ultrasónico
#define ECHO_PIN 10 // Pin de eco del sensor ultrasónico
bool rotating = false;
bool ultrasonicEnabled = false;
void setup() {
pinMode(motorPin1, OUTPUT);
pinMode(motorPin2, OUTPUT);
pinMode(motorPin3, OUTPUT);
pinMode(motorPin4, OUTPUT);
Serial.begin(9600);
pinMode(TRIGGER_PIN, OUTPUT);
pinMode(ECHO_PIN, INPUT);
}
void loop() {
if (Serial.available() > 0) {
char command = Serial.read();
if (command == 'F') {
forward();
}
else if (command == 'G') {
backward();
}
else if (command == 'L') {
turnLeft();
}
else if (command == 'R') {
turnRight();
}
else if (command == 'S') {
stop();
}
else if (command == 'X') {
rotate();
ultrasonicEnabled = true;
}
else if (command == 'Y') {
stopMotors();
ultrasonicEnabled = false;
}
}
if (ultrasonicEnabled) {
long duration, distance;
digitalWrite(TRIGGER_PIN, LOW);
delayMicroseconds(2);
digitalWrite(TRIGGER_PIN, HIGH);
delayMicroseconds(10);
digitalWrite(TRIGGER_PIN, LOW);
duration = pulseIn(ECHO_PIN, HIGH);
distance = (duration / 2) / 29.1;
if (distance < 30) {
stop();
backward();
delay(500);
stop();
delay(200);
turnLeft();
delay(500);
stop();
forward();
}
}
}
void forward() {
digitalWrite(motorPin1, HIGH);
digitalWrite(motorPin2, LOW);
digitalWrite(motorPin3, HIGH);
digitalWrite(motorPin4, LOW);
}
void backward() {
digitalWrite(motorPin1, LOW);
digitalWrite(motorPin2, HIGH);
digitalWrite(motorPin3, LOW);
digitalWrite(motorPin4, HIGH);
}
void turnLeft() {
digitalWrite(motorPin1, LOW);
digitalWrite(motorPin2, HIGH);
digitalWrite(motorPin3, HIGH);
digitalWrite(motorPin4, LOW);
}
void turnRight() {
digitalWrite(motorPin1, HIGH);
digitalWrite(motorPin2, LOW);
digitalWrite(motorPin3, LOW);
digitalWrite(motorPin4, HIGH);
}
void stop() {
digitalWrite(motorPin1, LOW);
digitalWrite(motorPin2, LOW);
digitalWrite(motorPin3, LOW);
digitalWrite(motorPin4, LOW);
}
void rotate() {
if (!rotating) {
rotating = true;
digitalWrite(motorPin1, HIGH);
digitalWrite(motorPin2, LOW);
digitalWrite(motorPin3, LOW);
digitalWrite(motorPin4, HIGH);
delay(200);
stop();
delay(200);
backward();
delay(500);
stop();
rotating = false;
forward();
}
}
void stopMotors() {
stop();
}
Carro Todo Terreno Arduino
*PCBWay community is a sharing platform. We are not responsible for any design issues and parameter issues (board thickness, surface finish, etc.) you choose.
- Comments(0)
- Likes(4)
- Engineer Jan 08,2024
- Fabri Creator Dec 31,2023
- Engineer Jul 24,2023
- Engineer Jul 06,2023
- 0 USER VOTES
- YOUR VOTE 0.00 0.00
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
More by Fabri Creator
-
-
-
-
-
-
3D printed Enclosure Backplate for Riden RD60xx power supplies
154 1 1 -
-