Advertisement
Decee

home_reciever

Jul 24th, 2017
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.01 KB | None | 0 0
  1. int data = 3; //Will be 1
  2. int clocks = 4; //Will be 2
  3. int recievedID[] = {1,0,0,0,0,0,0,0};
  4.  
  5. int debugging = 1; //Enables debugging
  6. void setup() {
  7. // put your setup code here, to run once:
  8. pinMode(clocks, INPUT);
  9. pinMode(data, INPUT);
  10. Serial.begin(115200);
  11. }
  12.  
  13. void loop() {
  14. if (digitalRead(data) == HIGH) {
  15. while (digitalRead(clocks) != HIGH) {} //waits until clock is HIGH
  16. recievedID[0] = 1;
  17. for (int num = 0; num < 7; num++) { //starts counting signals. Only 7 as the first is a "wake up" signal
  18. while (digitalRead(clocks) != LOW) {} //waits until clock is LOW
  19. recievedID[num] = digitalRead(data);
  20. num++;
  21. while (digitalRead(clocks) != HIGH) {} //waits until clock is HIGH
  22. }
  23. if(debugging = 1) {
  24. for (int num = 0; num < 8; num++) {
  25. Serial.print(recievedID[num]);
  26. }
  27. Serial.println();
  28. }
  29.  
  30. while(digitalRead(data) == HIGH) {}
  31. }
  32. for (int num = 0; num < 8; num++) {
  33. int recieved = recievedID[num] + recieved;
  34. }
  35. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement