Manufactura industrial
Internet industrial de las cosas | Materiales industriales | Mantenimiento y reparación de equipos | Programación industrial |
home  MfgRobots >> Manufactura industrial >  >> Manufacturing Technology >> Proceso de manufactura

Coche RC 4WD con Arduino: Lista de Componentes y Guía de Montaje

Componentes y materiales

Componente Cantidad
Arduino UNO 2
Módulo transceptor nRF24L01+ (RP-SMA) 2
Shield Joystick Funduino V1.A 1
Driver dual H-Bridge L298 (SparkFun) 2
Kit chasis robot 4WD 1
LED genérico 3
Resistencia 221Ω 2
Protoboard 2
Baterías 18650 2
Powerbank 1
Cables jumpers 1 set

Herramientas necesarias

Aplicaciones y servicios online

Sobre el proyecto

Historia

¡Hola a todos! Este es mi próximo proyecto: un coche RC 4WD con Arduino controlado por joystick, o lo fácil que es controlar un coche inteligente 4WD con un joystick analógico.

Este coche RC usa nRF24L01 como transmisor y receptor, con alcance hasta 1 km en espacio abierto. Es muy simple y fácil de construir.

1. Controlador con Joystick

Componentes del joystick:

El shield joystick se monta sobre el Arduino y lo convierte en un controlador sencillo: 7 botones pulsadores (4 grandes, 2 pequeños, y el botón del joystick) y un joystick de dos ejes dan funcionalidad tipo consola clásica. También ofrece interfaces para LCD Nokia 5110, nRF24L01, Bluetooth e I2C.

Características del shield:

El módulo nRF24L01 usado es el BTE16-49 (nRF24L01+RFX2401C +PA+LNA) con antena blindada, 2.4GHz, 20dBm, alcance 1000m.

Especificaciones del vendedor:

2. Pruebas del Joystick

El shield tiene 4 botones grandes + 2 pequeños + botón del joystick + joystick de dos ejes (X: 0-1023, Y: 0-1023). En mi código: Botón Arriba = Bocina (buzzer), Botón Derecho = Luz frontal (LED + resistencia 200Ω), Botón Izquierdo = Luces traseras (LEDs + resistencia 200Ω). Los demás botones no se usan.

Estado en reposo: X=499, Y=502, Up=1, Right=1, Down=1, Left=1

3. Coche RC 4WD con Arduino

Realiza las conexiones según el diagrama de cableado.

Nota importante: Antes de subir el código, desconecta los jumpers del Arduino Uno (pines 0 y 1).

Una vez completados todos los pasos, ¡el coche está listo! Al encender el Arduino del coche y el controlador, mueve el joystick adelante/atrás para avanzar/retroceder, e izquierda/derecha para girar.

Código: Coche (Car_nRF24.ino)

/* Receptor joystick - CONEXIONES nRF24L01:
1-GND, 2-VCC 3.3V (NO 5V), 3-CE pin 6, 4-CSN pin 8,
5-SCK pin 13, 6-MOSI pin 11, 7-MISO pin 12 */
#include <SPI.h>
#include <nRF24L01.h>
#include <RF24.h>

#define CE_PIN 6
#define CSN_PIN 8
const uint64_t pipe = 0xE8E8F0F0E1LL;

#define light_Front 18 // LED frontal pin A4
#define light_Back 19  // LED trasero pin A5
#define horn_Buzz 7

#define ENA_m1 3  // Enable motor Front Right
#define ENB_m1 5  // Enable motor Back Right
#define ENA_m2 9  // Enable motor Front Left
#define ENB_m2 10 // Enable motor Back Left

#define IN_11 0  // L298N #1 in1 motor Front Right
#define IN_12 1  // L298N #1 in2 motor Front Right
#define IN_13 2  // L298N #1 in3 motor Back Right
#define IN_14 4  // L298N #1 in4 motor Back Right
#define IN_21 14 // L298N #2 in1 motor Front Left
#define IN_22 15 // L298N #2 in2 motor Front Left
#define IN_23 16 // L298N #2 in3 motor Back Left
#define IN_24 17 // L298N #2 in4 motor Back Left

RF24 radio(CE_PIN, CSN_PIN);
int joystick[6];
int speedRight = 0, speedLeft = 0;
int xAxis, yAxis;
int buttonUp, buttonRight, buttonDown, buttonLeft;

void setup() {
  pinMode(light_Front, OUTPUT); pinMode(light_Back, OUTPUT); pinMode(horn_Buzz, OUTPUT);
  pinMode(ENA_m1, OUTPUT); pinMode(ENB_m1, OUTPUT);
  pinMode(ENA_m2, OUTPUT); pinMode(ENB_m2, OUTPUT);
  pinMode(IN_11, OUTPUT); pinMode(IN_12, OUTPUT); pinMode(IN_13, OUTPUT); pinMode(IN_14, OUTPUT);
  pinMode(IN_21, OUTPUT); pinMode(IN_22, OUTPUT); pinMode(IN_23, OUTPUT); pinMode(IN_24, OUTPUT);

  radio.begin();
  radio.openReadingPipe(1, pipe);
  radio.startListening();
}

void loop() {
  if (radio.available()) {
    radio.read(joystick, sizeof(joystick));
    xAxis = joystick[0]; yAxis = joystick[1];
    buttonUp = joystick[2]; buttonRight = joystick[3];
    buttonDown = joystick[4]; buttonLeft = joystick[5];

    // Botones: buzzer y luces
    digitalWrite(horn_Buzz, buttonUp == HIGH ? LOW : HIGH);
    digitalWrite(light_Front, buttonRight == HIGH ? LOW : HIGH);
    digitalWrite(light_Back, buttonLeft == HIGH ? LOW : HIGH);

    // Eje Y: adelante/atrás
    if (yAxis < 470) { // Atrás
      digitalWrite(IN_11, LOW); digitalWrite(IN_12, HIGH);
      digitalWrite(IN_13, HIGH); digitalWrite(IN_14, LOW);
      digitalWrite(IN_21, HIGH); digitalWrite(IN_22, LOW);
      digitalWrite(IN_23, LOW); digitalWrite(IN_24, HIGH);
      speedRight = map(yAxis, 470, 0, 0, 255);
      speedLeft = map(yAxis, 470, 0, 0, 255);
    } else if (yAxis > 550) { // Adelante
      digitalWrite(IN_11, HIGH); digitalWrite(IN_12, LOW);
      digitalWrite(IN_13, LOW); digitalWrite(IN_14, HIGH);
      digitalWrite(IN_21, LOW); digitalWrite(IN_22, HIGH);
      digitalWrite(IN_23, HIGH); digitalWrite(IN_24, LOW);
      speedRight = map(yAxis, 550, 1023, 0, 255);
      speedLeft = map(yAxis, 550, 1023, 0, 255);
    } else { // Centro: parado
      speedRight = 0; speedLeft = 0;
    }

    // Eje X: giro izquierda/derecha
    if (xAxis < 470) { // Izquierda
      int xMapped = map(xAxis, 470, 0, 0, 255);
      speedLeft = max(0, speedLeft - xMapped);
      speedRight = min(255, speedRight + xMapped);
    }
    if (xAxis > 550) { // Derecha
      int xMapped = map(xAxis, 550, 1023, 0, 255);
      speedLeft = min(255, speedLeft + xMapped);
      speedRight = max(0, speedRight - xMapped);
    }

    // Evitar zumbido a baja velocidad (ajustar según motores)
    if (speedLeft < 70) speedLeft = 0;
    if (speedRight < 70) speedRight = 0;

    analogWrite(ENA_m1, speedRight); analogWrite(ENB_m1, speedRight);
    analogWrite(ENA_m2, speedLeft);  analogWrite(ENB_m2, speedLeft);
  }
}

Código: Controlador Joystick (Joystick_nRF24.ino)

/* Transmisor joystick - CONEXIONES nRF24L01:
1-GND, 2-VCC 3.3V (NO 5V), 3-CE pin 9, 4-CSN pin 10,
5-SCK pin 13, 6-MOSI pin 11, 7-MISO pin 12 */
#include <SPI.h>
#include <nRF24L01.h>
#include <RF24.h>

#define CE_PIN 9
#define CSN_PIN 10
#define xAxis 14 // A0
#define yAxis 15 // A1
const uint64_t pipe = 0xE8E8F0F0E1LL;

RF24 radio(CE_PIN, CSN_PIN);
int joystick[6];
int buttonUp = 2, buttonRight = 3, buttonDown = 4, buttonLeft = 5;

void setup() {
  Serial.begin(9600);
  radio.begin();
  radio.openWritingPipe(pipe);
  radio.stopListening();
  pinMode(buttonUp, INPUT_PULLUP); pinMode(buttonRight, INPUT_PULLUP);
  pinMode(buttonDown, INPUT_PULLUP); pinMode(buttonLeft, INPUT_PULLUP);
}

void loop() {
  joystick[0] = analogRead(xAxis);
  joystick[1] = analogRead(yAxis);
  joystick[2] = digitalRead(buttonUp);
  joystick[3] = digitalRead(buttonRight);
  joystick[4] = digitalRead(buttonDown);
  joystick[5] = digitalRead(buttonLeft);
  radio.write(joystick, sizeof(joystick));
  delay(20);
}

Esquemáticos

Archivo Fritzing: rc_car_tp3A7JlpYw.fzz y diagrama de conexiones incluido.

Proceso de manufactura

  1. Proyecto Dados Digitales Arduino: Construye tu Propio Generador de Números Aleatorios con LCD
  2. Mando USB para juegos DIY con Arduino – Construye tu propio gamepad de alto rendimiento
  3. Transforma un viejo coche RC en un vehículo controlado por joystick con Arduino
  4. Construye un Iron Man animado con Arduino: componentes, sensores y guía paso a paso
  5. Find Me: Localizador Inteligente de Objetos con Arduino y Bluetooth
  6. Construye un Brazo Robótico Impreso en 3D Controlado por Arduino – Guía Paso a Paso
  7. Controlador de Humidificador DIY con Arduino y Relé: Configuración Segura de Alto Voltaje
  8. Contador Inteligente de Plazas de Aparcamiento: Seguimiento en Tiempo Real con Arduino, Processing y PHP
  9. Pong Neón en Matriz NeoPixel con Arduino Nano
  10. Construye un volante joystick personalizado con Arduino para gaming
  11. Construye tu Propio Coche RC Porsche con Arduino: Guía Paso a Paso