i just bought two new HC-12. I was trying to send potentiometer value to other arduino using this transmitter. but it only shows crap data(strange characters) on the other side.
Here is the code:
Transmitter:
/* Arduino Long Range Wireless Communication using HC-12
Example 01
by Dejan Nedelkovski, www.HowToMechatronics.com
*/
int pot = 0;
int pot_value=0;
#include <SoftwareSerial.h>
SoftwareSerial HC12(12, 11); // HC-12 TX Pin, HC-12 RX Pin
void setup() {
pinMode(pot,INPUT);
Serial.begin(9600); // Serial port to computer
HC12.begin(9600); // Serial port to HC12
}
void loop() {
pot_value=analogRead(pot);
while (1) { // If Serial monitor has data
HC12.write(pot_value);
}
}
Receiver:
/* Arduino Long Range Wireless Communication using HC-12
Example 01
by Dejan Nedelkovski, www.HowToMechatronics.com
*/
#include <SoftwareSerial.h>
SoftwareSerial HC12(10, 9); // HC-12 TX Pin, HC-12 RX Pin
void setup() {
Serial.begin(9600); // Serial port to computer
HC12.begin(9600); // Serial port to HC12
}
void loop() {
while (HC12.available()) { // If HC-12 has data
Serial.write(HC12.read()); // Add each byte to ReadBuffer string variable
}
}
Here is the code:
Transmitter:
/* Arduino Long Range Wireless Communication using HC-12
Example 01
by Dejan Nedelkovski, www.HowToMechatronics.com
*/
int pot = 0;
int pot_value=0;
#include <SoftwareSerial.h>
SoftwareSerial HC12(12, 11); // HC-12 TX Pin, HC-12 RX Pin
void setup() {
pinMode(pot,INPUT);
Serial.begin(9600); // Serial port to computer
HC12.begin(9600); // Serial port to HC12
}
void loop() {
pot_value=analogRead(pot);
while (1) { // If Serial monitor has data
HC12.write(pot_value);
}
}
Receiver:
/* Arduino Long Range Wireless Communication using HC-12
Example 01
by Dejan Nedelkovski, www.HowToMechatronics.com
*/
#include <SoftwareSerial.h>
SoftwareSerial HC12(10, 9); // HC-12 TX Pin, HC-12 RX Pin
void setup() {
Serial.begin(9600); // Serial port to computer
HC12.begin(9600); // Serial port to HC12
}
void loop() {
while (HC12.available()) { // If HC-12 has data
Serial.write(HC12.read()); // Add each byte to ReadBuffer string variable
}
}