-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathprogram1.ino
More file actions
23 lines (18 loc) · 833 Bytes
/
program1.ino
File metadata and controls
23 lines (18 loc) · 833 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
#include <SoftwareSerial.h>
const byte HC12RxdPin = 4; // Recieve Pin on HC12
const byte HC12TxdPin = 5; // Transmit Pin on HC12
SoftwareSerial HC12(HC12TxdPin,HC12RxdPin); // Create Software Serial Port
void setup() {
// pinMode(6, OUTPUT);
// digitalWrite(6, HIGH); // HC-12 in normal mode
Serial.begin(9600); // Open serial port to computer
HC12.begin(9600); // Open serial port to HC12
}
void loop() {
if(HC12.available()){ // If Arduino's HC12 rx buffer has data
Serial.write(HC12.read()); // Send the data to the computer
}
if(Serial.available()){ // If Arduino's computer rx buffer has data
HC12.write(Serial.read()); // Send that data to serial
}
}