Click here to Skip to main content
15,389,918 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi , i am using a arduino mini pro in a project at the moment and am trying to use this with a hc12 module. I am new to coding and i am finding your videos very helpful. i am after coming into a problem and i am wondering can you help me.

i am building a robot hand
i have 5 poteniometers attacthed to arduino i want my hc12 to send each different signal to different hc12 and arduino and output is to 5 servos

i have created code to work on 1 arduino. i now need to use 2 arduinos and send the information wirelessly through the hc12

i do not know how to use hc12
i want to read pot signals, send pot signals from hc12(1) to hc12(2) and output to servos

attached is my code and i hope you can look at this and show me how to put in the coding for HC12 modules please

i hope you will reply soon and help me PLEASE as my project need to be done in 2 weeks!!!!!



#include <servo.h>
#include <softwareserial.h>

SoftwareSerial mySerial(2, 3); // RX, TX // Create Software Serial Ports (Tx,Rx)

Servo servo1; // create servo object to control servo1
Servo servo2; // create servo object to control servo2
Servo servo3; // create servo object to control servo3
Servo servo4; // create servo object to control servo4
Servo servo5; // create servo object to control servo5

int potpin1 = 0; // analog pin used to connect potentiometer1
int potpin2 = 1; // analog pin used to connect potentiometer2
int potpin3 = 2; // analog pin used to connect potentiometer3
int potpin4 = 3; // analog pin used to connect potentiometer4
int potpin5 = 7; // analog pin used to connect potentiometer5

int val1; // variable to read the value from analog pin1
int val2; // variable to read the value from analog pin2
int val3; // variable to read the value from analog pin3
int val4; // variable to read the value from analog pin4
int val5; // variable to read the value from analog pin5


void setup()

{ Serial.begin(9600); // Open serial port to computer


mySerial.begin(9600); // Open serial port to HC12
mySerial.print(F("AT+C069\r\n")); // set to channel 69
mySerial.print("AT+B9600"); // set baud rate to 9600


servo1.attach(8); // output signal of servo1 on pin 8
servo2.attach(9); // output signal of servo2 on pin 9
servo3.attach(10); // output signal of servo3 on pin 10
servo4.attach(11); // output signal of servo4 on pin 11
servo5.attach(12); // output signal of servo5 on pin 12
}

void loop()
{

val1 = analogRead(potpin1); // reads the value of potentiometer1 (value between 0 and 1023)
val1 = map(val1, 30, 1000, 5, 175); // scale it to use it with servo1 (value between 5 and 175)
servo1.write(val1); // sets servo1 position according to the scaled value


val2 = analogRead(potpin2); // reads the value of potentiometer2 (value between 0 and 1023)
val2 = map(val2, 30, 1000, 5, 175); // scale it to use it with servo2 (value between 5 and 175)
servo2.write(val2); // sets servo2 position according to the scaled value


val3 = analogRead(potpin3); // reads the value of potentiometer3 (value between 0 and 1023)
val3 = map(val3, 30, 1000, 5, 175); // scale it to use it with servo3 (value between 5 and 175)
servo3.write(val3); // sets servo3 position according to the scaled value


val4 = analogRead(potpin4); // reads the value of potentiometer4 (value between 0 and 1023)
val4 = map(val4, 30, 1000, 5, 175); // scale it to use it with servo4 (value between 5 and 175)
servo4.write(val4); // sets servo4 position according to the scaled value


val5 = analogRead(potpin5); // reads the value of potentiometer5 (value between 0 and 1023)
val5 = map(val5, 30, 1000, 5, 175); // scale it to use it with servo5 (value between 5 and 175)
servo5.write(val5); // sets servo5 position according to the scaled value*/

delay(1); // waits for the servos to get there
}

What I have tried:

i have the board working on onee arduino. i need to get it set up to wireless
Posted
Comments
Mike Hankey 25-Mar-17 9:13am
   
https://www.allaboutcircuits.com/projects/understanding-and-implementing-the-hc-12-wireless-transceiver-module/

This might help.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900