Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- void setup() {
- Serial.begin(9600); // Initialize the serial monitor
- Serial1.begin(9600); // Initialize Serial1 for HC-12 module
- }
- void loop() {
- if (Serial.available()) {
- String data = Serial.readString(); // Read a string from the serial monitor
- if (data.startsWith("AT")) {
- Serial1.print(data); // Send AT command to HC-12 module
- }
- }
- if (Serial1.available()) {
- String data = Serial1.readString(); // Read a string from HC-12 module
- Serial.println(data); // Print received string to the serial monitor
- }
- // Transmit a string every 5 seconds
- Serial1.print(69); // Replace this with your desired string
- delay(5000);
- Serial.println("Sent"); // Print "Sent" in the serial monitor
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement