-
Notifications
You must be signed in to change notification settings - Fork 0
/
hw4.ino
72 lines (59 loc) · 1.47 KB
/
hw4.ino
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
//based off of the code graciously provided by Ayo
#include <RFduinoGZLL.h>
device_t role = HOST;
char state = 0;
const int blueLed = 6;
const int redLed = 4;
const int piezo = 2;
int sound = 330;//E tone
void setup()
{
Serial.begin(9600);
Serial.print("This is your last chance. After this, there is no turning back.");
Serial.print('\n');
Serial.print("You take the blue pill -- the story ends,");
Serial.print('\n');
Serial.print("you wake up in your bed and believe whatever you want to believe.");
Serial.print('\n');
Serial.print("You take the red pill -- you stay in Wonderland");
Serial.print('\n');
Serial.print("and I show you how deep the rabbit hole goes.");
Serial.print('\n');
}
pinMode(redLed, OUTPUT);
pinMode(blueLed, OUTPUT);
// start the GZLL stack
RFduinoGZLL.begin(role);
}
void loop()
{
}
void on() {
digitalWrite(redLed, HIGH);
digitalWrite(blueLed, HIGH);
}
void off() {
digitalWrite(redLed, LOW);
digitalWrite(blueLed, LOW);
}
void RFduinoGZLL_onReceive(device_t device, int rssi, char *data, int len)
{
Serial.println(data);
if (data[0] == '1') {
Serial.print("Boo, lame.");
digitalWrite(blueLed, HIGH);
delay(50);
} else {
digitalWrite(blueLed, LOW);
}
else if (data[0] == '0') {
Serial.print("ENTER THE MATRIX!");
digitalWrite(redLed, HIGH);
tone(piezo, sound, 100);
delay(50);
} else {
digitalWrite(redLed, LOW);
digitalWrite(redLed, LOW);
noTone;
}
}