It is necessary to control 2 brushless motors using the HC-12 modules.
Dabbed from the Internet just a little bit, but apparently somewhere I missed something in the sketches,
The first sketch that works on arduino without a connection, directly to the controller.
My sketch, but it is not work
transmiter
#include <SoftwareSerial.h>
SoftwareSerial HC12(2, 3);
#define LED_PIN 13
void setup()
{
Serial.begin(9600);
}
void loop()
{
Serial.write('');
Serial.write('c');
Serial.write(map(analogRead(pot1y), 0, 1023, 800, 2300));
Serial.write('d');
Serial.write(digitalRead(knopka1)); //кнопка 1
Serial.write('e');
Serial.write(digitalRead(knopka2)); //кнопка 2
delay(50);
}
recivied
#include <Servo.h>
Servo motor1;
Servo motor2;
#include <SoftwareSerial.h>
int bashnyal = 3;
int basnyar = 4;
int b;
int c;
void setup()
{
Serial.begin(9600);
pinMode(bashnyal, OUTPUT);
digitalWrite(bashnyal, LOW);
pinMode(basnyar, OUTPUT);
digitalWrite(basnyar, LOW);
motor1.attach(2);
motor2.attach(3);
}
void loop()
{
if(Serial.available() && Serial.read() == 'b')
{
b = Serial.read();
motor1.writeMicroseconds(b);
}
if(Serial.available() && Serial.read() == 'c')
{
c = Serial.read();
motor2.writeMicroseconds(c);
}
if(Serial.available() && Serial.read() == 'd')
{
int d = Serial.read();
digitalWrite(bashnyal,d);
}
if(Serial.available() && Serial.read() == 'e')
{
int e = Serial.read();
digitalWrite(basnyar,e);
}
delay(50);
}