Advertisement
gabbyshimoni

NANOwHC12TX

Feb 12th, 2019
137
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.59 KB | None | 0 0
  1. #include <SoftwareSerial.h>
  2. #define pbPin 3
  3. int pbState = 0;
  4. SoftwareSerial HC12(10, 9); // RX on arduino connected to TX on HC12, TX on arduino connected to RX on HC12
  5.  
  6. void setup() {
  7.   // Open serial communications and wait for port to open:
  8.   Serial.begin(9600);
  9.   HC12.begin(9600);
  10.   pinMode(pbPin, INPUT_PULLUP);
  11.  
  12. }
  13.  
  14.  
  15. void loop() { // run over and over
  16.  
  17.   pbState = digitalRead(pbPin);
  18.   delay(10);
  19.   pbState = digitalRead(pbPin);
  20.   if (pbState == LOW) {
  21.     HC12.write('x');
  22.     Serial.println("x");
  23.     delay(5000);
  24.     HC12.write('v');
  25.     Serial.println("v");
  26.   }
  27. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement