Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- int data = 3; //Will be 1
- int clocks = 4; //Will be 2
- int recievedID[] = {1,0,0,0,0,0,0,0};
- int debugging = 1; //Enables debugging
- void setup() {
- // put your setup code here, to run once:
- pinMode(clocks, INPUT);
- pinMode(data, INPUT);
- Serial.begin(115200);
- }
- void loop() {
- if (digitalRead(data) == HIGH) {
- while (digitalRead(clocks) != HIGH) {} //waits until clock is HIGH
- recievedID[0] = 1;
- for (int num = 0; num < 7; num++) { //starts counting signals. Only 7 as the first is a "wake up" signal
- while (digitalRead(clocks) != LOW) {} //waits until clock is LOW
- recievedID[num] = digitalRead(data);
- num++;
- while (digitalRead(clocks) != HIGH) {} //waits until clock is HIGH
- }
- if(debugging = 1) {
- for (int num = 0; num < 8; num++) {
- Serial.print(recievedID[num]);
- }
- Serial.println();
- }
- while(digitalRead(data) == HIGH) {}
- }
- for (int num = 0; num < 8; num++) {
- int recieved = recievedID[num] + recieved;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement