Advertisement
Guest User

Untitled

a guest
Jan 18th, 2019
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.40 KB | None | 0 0
  1. char data_rx;
  2. int bitDelay = 1000;
  3. int halfBitDelay = 1500;
  4. int rx = 2;
  5.  
  6. void setup() {
  7. // put your setup code here, to run once:
  8. Serial.begin(9600);
  9. pinMode(rx,INPUT);
  10. }
  11.  
  12. void loop() {
  13. delayMicroseconds(halfBitDelay);
  14. for (int offset = 0; offset < 8; offset++) {
  15. delayMicroseconds(bitDelay);
  16. data_rx |= digitalRead(rx) << offset;
  17. }
  18. Serial.print(data_rx);
  19. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement