ESP, IoT esp32 bluetooth car

Иван88

✩✩✩✩✩✩✩
3 Ноя 2019
3
1
Всем привет.меня зовут Иван.Мой проект(пока что сырой ,планирую допилить в приложении вайфай-блютуз переключение)машинки ю:cool:
блютуз есп32:
#include <esp32_arduino_rmt_van_rx.h>
#include <esp32_rmt_van_rx.h>

#include <Servo.h>

//ESP32 Bluetooh car
//By Technical_Tamizha
//Circuit Diagram for this project is in my Youtube channel
//Channel Link : https://www.youtube.com/channel/UC1VT8SUJ7yvIkE4eCzXVSNA
#include <WS2812FX.h>
#include "ESP32_RMT_Driver.h"

// The ESP32's RMT hardware supports up to 8 channels, so it
// can drive up to 8 independent WS2812FX instances. We'll use 2.
WS2812FX ws2812fx1 = WS2812FX(8, 12, NEO_GRB  + NEO_KHZ800); // 144 RGB LEDs driven by GPIO_12


#include "BluetoothSerial.h"

BluetoothSerial SerialBT;

char receivedChar;// received value will be stored as CHAR in this variable

const int DIR_2 = 17; //ESP32 pins (MR=Right Motor) (ML=Left Motor) (1=Forward) (2=Backward)
const int DIR_1 = 14;
const int SPEED_1 = 27;
const int SPEED_2 = 16;
int SERVO_1 = 12;
int SERVO_2 = 13;
Servo SERVO1;
Servo SERVO2;
const int LEDG = 5;
const int LEDB = 23;
const int LEDR = 19;
int SPEED = 255;
void setup() {
  Serial.begin(115200);
  SerialBT.begin("VaNBot"); //You can change your Bluetooth device name
  pinMode(SPEED_1, OUTPUT);
  pinMode(SPEED_2, OUTPUT);
  pinMode(DIR_1, OUTPUT);
  pinMode(DIR_2, OUTPUT);
  pinMode(LEDG, OUTPUT);
  pinMode(LEDB, OUTPUT);
  pinMode(LEDR, OUTPUT);
  SERVO1.attach(SERVO_1);
  SERVO2.attach(SERVO_2);
   ws2812fx1.init();
   ws2812fx1.setBrightness(204); // set the overall LED brightnesses
   rmt_tx_int(RMT_CHANNEL_0, ws2812fx1.getPin()); // assign ws2812fx1 to RMT channel 0
ws2812fx1.setCustomShow(myCustomShow1); // set the custom show function to forgo the NeoPixel
ws2812fx1.setSegment(0, 0, 8-1, FX_MODE_COMET,BLUE, 1000, NO_OPTIONS); // setup each ws2812fx's effect
   ws2812fx1.start(); // start'em up

}

void Forward(){
    
    digitalWrite(DIR_1, HIGH);
    digitalWrite(DIR_2, HIGH);
    digitalWrite(SPEED_1, 255);
    digitalWrite(SPEED_2, 255);
}
void Backward(){
      digitalWrite(DIR_1, LOW);
    digitalWrite(DIR_2, LOW);
    digitalWrite(SPEED_1, 255);
    digitalWrite(SPEED_2, 255);
}
void Left(){
     digitalWrite(DIR_1, HIGH);
    digitalWrite(DIR_2, LOW);
    digitalWrite(SPEED_1, 255);
    digitalWrite(SPEED_2, 255);
}
void LeftF(){
     digitalWrite(DIR_1, HIGH);
    digitalWrite(DIR_2, HIGH);
    digitalWrite(SPEED_1, 255);
    digitalWrite(SPEED_2, 50);
}
void LeftB(){
digitalWrite(DIR_1,LOW);
    digitalWrite(DIR_2,LOW);
    digitalWrite(SPEED_1, 255);
    digitalWrite(SPEED_2, 50);
}
void Right(){
    
    digitalWrite(DIR_1, LOW);
    digitalWrite(DIR_2, HIGH);
    digitalWrite(SPEED_1, 255);
    digitalWrite(SPEED_2, 255);
}
void RightF(){
digitalWrite(DIR_1, HIGH);
    digitalWrite(DIR_2, HIGH);
    digitalWrite(SPEED_1, 50);
    digitalWrite(SPEED_2, 255);
}
void RightB(){
digitalWrite(DIR_1,LOW);
    digitalWrite(DIR_2,LOW);
    digitalWrite(SPEED_1, 50);
    digitalWrite(SPEED_2, 255);
}
void Greenon() {
  digitalWrite(LEDG, HIGH);
  ws2812fx1.setSegment(0, 0, 10-1, FX_MODE_SCAN,GREEN , 1000, NO_OPTIONS);
}
void Greenoff() {
  digitalWrite(LEDG, LOW);
}
  void Blueon() {
  digitalWrite(LEDB, HIGH);

}
void Blueoff() {
  digitalWrite(LEDB, LOW);
}
  void Redon() {
  digitalWrite(LEDR, HIGH);
  }
void Stop(){
     digitalWrite(LEDR, LOW);
    digitalWrite(SPEED_1, 0);
    digitalWrite(SPEED_2, 0);
}
void myCustomShow1(void) {
  uint8_t *pixels = ws2812fx1.getPixels();
  // numBytes is one more then the size of the ws2812fx's *pixels array.
  // the extra byte is used by the driver to insert the LED reset pulse at the end.
  uint16_t numBytes = ws2812fx1.getNumBytes() + 1;
  rmt_write_sample(RMT_CHANNEL_0, pixels, numBytes, false); // channel 0
}//void girarSERVO1(int grados){
  //SERVO1.write(grados);
//}
//void girarSERVO2(int grados){
  //SERVO2.write(grados);
//}

void loop() {

ws2812fx1.service(); // service each ws2812fx instance

    receivedChar =(char)SerialBT.read();
  if (Serial.available()) {
    SerialBT.write(Serial.read());

  }
  if (SerialBT.available()) {
  
    Serial.print ("Received:");//print on serial monitor
    Serial.println(receivedChar);//print on serial monitor 
  
    if(receivedChar == 'F')
    {
      Forward();
    }

    if(receivedChar == 'B')
    {

      Backward();
    }       
     if(receivedChar == 'L')
    {

      Left();
    }     
    if(receivedChar == 'R')
    {

      Right();
    }
     if(receivedChar == 'Z')
    {

      LeftF();
    }     
    if(receivedChar == 'Q')
    {

      RightF();
    }
    if(receivedChar == 'E')
    {
        LeftB();
    }     
    if(receivedChar == 'W')
    {

      RightB();
    }
    if(receivedChar == 'S')
    {
    
      Stop();
    }
    if(receivedChar == 'M')
    {
    
  
    }
     if(receivedChar == 'm')
    {
    
      Greenoff();
    }
    if(receivedChar == 'N')
    {
    
      Blueon();
    }
     if(receivedChar == 'n')
    {
    
      Blueoff();
    }
    if(receivedChar == 'X')
    {
    
      Redon();
    }
  }
  delay(20);
}
 
Изменено:

ununnamed

★✩✩✩✩✩✩
18 Авг 2020
75
20
Ниже пример грамотно оформленного поста.

Меня зовут Вася Пупкин, хочу с вами поделится чем то там, чем пока сам не решил.
Мое чем то там создано для : ________
Оно имеет функционал : ________
Алгоритм работы : ________
Интерфейс и настройка : _______
Реализация : _______
В проекте всё хорошо, только немного не понятен второй пункт. Можешь прокомментировать?
 

Иван88

✩✩✩✩✩✩✩
3 Ноя 2019
3
1
В проекте всё хорошо, только немного не понятен второй пункт. Можешь прокомментировать?
Извиняюсь,вроде нажимал чтоб пока не публиковался пост.на выходных переделаю(первый раз вообще решил что-то выложить)