From 6c4cdab3bc659e545796ff391ee17762d3bd9061 Mon Sep 17 00:00:00 2001 From: mdchaparrror Date: Mon, 5 Aug 2019 22:34:11 -0500 Subject: [PATCH] cckiu8 --- README.md | 26 ++++++++++++++++- firmwareCarroEsp32/platformio.ini | 1 + firmwareCarroEsp32/src/carroEsp32.h | 43 +++++++++++++++++++++++++++++ firmwareCarroEsp32/src/main.cpp | 24 ++++++++++++++-- 4 files changed, 90 insertions(+), 4 deletions(-) create mode 100644 firmwareCarroEsp32/src/carroEsp32.h diff --git a/README.md b/README.md index 20d60df..7dbf0df 100644 --- a/README.md +++ b/README.md @@ -5,7 +5,31 @@ Carro autónomo basado en el tarjeta esp32 MH-ET LIVE Para controlar los motores del carro usamos un driver TB6612FNG, el cual es un módulo que nos permite controlar 2 motores con una corriente de 1.2 A (3.2 A corriente pico) y un voltaje de 15 V -![arduino mega](imagenes/TB6612FNG.jpg) +![TB6612FNG](imagenes/TB6612FNG.jpg) + +--- +## Conexiones: + +### TB6612FNG + + PWMA --> GPIO36 --> 5 + AI2 --> GPIO39 --> 8 + AI1 --> GPIO34 --> 10 + STBY --> GPIO35 --> 11 + BI1 --> GPIO32 --> 12 + BI2 --> GPIO33 --> 13 + +### Sensor TCRT5000 + + OUT1 --> GPIO15 --> ADC2_3 --> A13 + OUT2 --> GPIO14 --> ADC2_2 --> A16 + OUT3 --> GPIO12 --> ADC2_1 --> A15 + OUT4 --> GPIO4 --> ADC2_0 --> A10 + OUT5 --> GPIO13 --> ADC2_4 --> A14 + + + + --- Alimentación: diff --git a/firmwareCarroEsp32/platformio.ini b/firmwareCarroEsp32/platformio.ini index f982a9e..ae9fc16 100644 --- a/firmwareCarroEsp32/platformio.ini +++ b/firmwareCarroEsp32/platformio.ini @@ -13,3 +13,4 @@ platform = espressif32 board = mhetesp32devkit framework = arduino +monitor_speed = 115200 \ No newline at end of file diff --git a/firmwareCarroEsp32/src/carroEsp32.h b/firmwareCarroEsp32/src/carroEsp32.h new file mode 100644 index 0000000..fb5ca54 --- /dev/null +++ b/firmwareCarroEsp32/src/carroEsp32.h @@ -0,0 +1,43 @@ +#ifndef CARROESP32_h +#define CARROESP32_h +#define OUT1 A13 +#define OUT2 A16 +#define OUT3 A15 +#define OUT4 A10 +#define OUT5 A14 + +int sensores[5] = {0, 0, 0, 0, 0}; + +void readSensors() +{ + sensores[0] = analogRead(OUT1); + sensores[1] = analogRead(OUT2); + sensores[2] = analogRead(OUT3); + sensores[3] = analogRead(OUT4); + sensores[4] = analogRead(OUT5); +} + +void printSensores() +{ + for (int i = 0; i < 5; i++) + { + Serial.print(sensores[i]); + Serial.print(','); + } + Serial.println(); +} + +void init_sensores(){ + pinMode(OUT1, INPUT); + pinMode(OUT2, INPUT); + pinMode(OUT3, INPUT); + pinMode(OUT4, INPUT); + pinMode(OUT5, INPUT); +} + + + + + + +# endif \ No newline at end of file diff --git a/firmwareCarroEsp32/src/main.cpp b/firmwareCarroEsp32/src/main.cpp index 58b344c..6f91436 100644 --- a/firmwareCarroEsp32/src/main.cpp +++ b/firmwareCarroEsp32/src/main.cpp @@ -1,9 +1,27 @@ #include +#include "BluetoothSerial.h" +#include "carroEsp32.h" + +BluetoothSerial ESP_BT; //Object for Bluetooth + void setup() { - // put your setup code here, to run once: + init_sensores(); + Serial.begin(115200); + Serial.println("Carro Esp32"); + ESP_BT.begin("CARRO ESP32"); //Name of your Bluetooth Signal } void loop() { - // put your main code here, to run repeatedly: -} \ No newline at end of file + + if (ESP_BT.available()) //Check if we receive anything from Bluetooth + { + //incoming = ESP_BT.read(); //Read what we recevive + Serial.print("Received:"); Serial.println(ESP_BT.read()); + } + //readSensors(); + //printSensores(); + //delay(500); + +} +