Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <SoftwareSerial.h>
- #define pbPin 3
- int pbState = 0;
- SoftwareSerial HC12(10, 9); // RX on arduino connected to TX on HC12, TX on arduino connected to RX on HC12
- void setup() {
- // Open serial communications and wait for port to open:
- Serial.begin(9600);
- HC12.begin(9600);
- pinMode(pbPin, INPUT_PULLUP);
- }
- void loop() { // run over and over
- pbState = digitalRead(pbPin);
- delay(10);
- pbState = digitalRead(pbPin);
- if (pbState == LOW) {
- HC12.write('x');
- Serial.println("x");
- delay(5000);
- HC12.write('v');
- Serial.println("v");
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement