ticker added

Dependencies:   mbed neopixels_spi

Committer:
el12moe
Date:
Thu May 14 02:06:56 2015 +0000
Revision:
0:1c121c73ab08
new code with ticker bits

Who changed what in which revision?

UserRevisionLine numberNew contents of line
el12moe 0:1c121c73ab08 1 #include "mbed.h"
el12moe 0:1c121c73ab08 2
el12moe 0:1c121c73ab08 3 #include "neopixels_spi.h"
el12moe 0:1c121c73ab08 4
el12moe 0:1c121c73ab08 5 neopixels_spi lights;
el12moe 0:1c121c73ab08 6 Ticker xmas;
el12moe 0:1c121c73ab08 7
el12moe 0:1c121c73ab08 8 Serial xbee(p9,p10); //Initalise xbee_lib
el12moe 0:1c121c73ab08 9
el12moe 0:1c121c73ab08 10 Serial pi(USBTX, USBRX);// Initialse USB serial port
el12moe 0:1c121c73ab08 11 void mbedReceive(void);
el12moe 0:1c121c73ab08 12 void modeActivated(void);
el12moe 0:1c121c73ab08 13 void security(void);
el12moe 0:1c121c73ab08 14 void brightness(void);
el12moe 0:1c121c73ab08 15 void colour(void);
el12moe 0:1c121c73ab08 16 void festive(void);
el12moe 0:1c121c73ab08 17 void sleep(void);
el12moe 0:1c121c73ab08 18 void presetBrightness(void);
el12moe 0:1c121c73ab08 19 void presetColour(void);
el12moe 0:1c121c73ab08 20 void christmas(void);
el12moe 0:1c121c73ab08 21 void hunika(void);
el12moe 0:1c121c73ab08 22 void akwansa(void);
el12moe 0:1c121c73ab08 23 void rainbow(void);
el12moe 0:1c121c73ab08 24 void rgbm(void);
el12moe 0:1c121c73ab08 25 void christmas2(void);
el12moe 0:1c121c73ab08 26 void hunika2(void);
el12moe 0:1c121c73ab08 27 void akwansa2(void);
el12moe 0:1c121c73ab08 28 void rainbow2(void);
el12moe 0:1c121c73ab08 29 void rgbm2(void);
el12moe 0:1c121c73ab08 30
el12moe 0:1c121c73ab08 31
el12moe 0:1c121c73ab08 32
el12moe 0:1c121c73ab08 33 //wireless commm dependencies
el12moe 0:1c121c73ab08 34 void xbee_detect(void);
el12moe 0:1c121c73ab08 35 void light2(void);
el12moe 0:1c121c73ab08 36 void light1(void);
el12moe 0:1c121c73ab08 37 void reed1(void);
el12moe 0:1c121c73ab08 38 void reed2(void);
el12moe 0:1c121c73ab08 39 void count1(void);
el12moe 0:1c121c73ab08 40 void count2(void);
el12moe 0:1c121c73ab08 41 void count3(void);
el12moe 0:1c121c73ab08 42 void count4(void);
el12moe 0:1c121c73ab08 43 void normal_mode(void);
el12moe 0:1c121c73ab08 44 void normal_mode2(void);
el12moe 0:1c121c73ab08 45
el12moe 0:1c121c73ab08 46 //alarm dependencies
el12moe 0:1c121c73ab08 47 void alarmP1(void);
el12moe 0:1c121c73ab08 48 void alarmR1(void);
el12moe 0:1c121c73ab08 49 void alarmP2(void);
el12moe 0:1c121c73ab08 50 void alarmR2(void);
el12moe 0:1c121c73ab08 51
el12moe 0:1c121c73ab08 52 void b1(void);
el12moe 0:1c121c73ab08 53 void b2(void);
el12moe 0:1c121c73ab08 54
el12moe 0:1c121c73ab08 55
el12moe 0:1c121c73ab08 56 //ticker stuff
el12moe 0:1c121c73ab08 57 void xb11(void);
el12moe 0:1c121c73ab08 58 void xb12(void);
el12moe 0:1c121c73ab08 59
el12moe 0:1c121c73ab08 60 Ticker xb1;// ticker for room 1
el12moe 0:1c121c73ab08 61 Ticker xb2;// ticker for room 2
el12moe 0:1c121c73ab08 62
el12moe 0:1c121c73ab08 63 int r10=0;//xbee1 pir
el12moe 0:1c121c73ab08 64 int r20=0;//xbee2pir
el12moe 0:1c121c73ab08 65
el12moe 0:1c121c73ab08 66
el12moe 0:1c121c73ab08 67 DigitalOut myled(LED1);
el12moe 0:1c121c73ab08 68 DigitalOut mled(LED2);
el12moe 0:1c121c73ab08 69 DigitalOut m3led(LED3);
el12moe 0:1c121c73ab08 70 DigitalOut m4led(LED4);
el12moe 0:1c121c73ab08 71
el12moe 0:1c121c73ab08 72 int xbee1 = 104;// reed switches
el12moe 0:1c121c73ab08 73 int xbee2 = 45; // PIR
el12moe 0:1c121c73ab08 74 int xbee3 = 76;// reed switches
el12moe 0:1c121c73ab08 75 int xbee4 = 69;// PIR
el12moe 0:1c121c73ab08 76
el12moe 0:1c121c73ab08 77
el12moe 0:1c121c73ab08 78 short counter1 = 0;
el12moe 0:1c121c73ab08 79 short counter2 = 0;
el12moe 0:1c121c73ab08 80 short counter3 = 0;
el12moe 0:1c121c73ab08 81 short counter4 = 0;
el12moe 0:1c121c73ab08 82 int readAddress = 0;
el12moe 0:1c121c73ab08 83 int readValue=0;
el12moe 0:1c121c73ab08 84
el12moe 0:1c121c73ab08 85 PwmOut buzzer(p21);
el12moe 0:1c121c73ab08 86 float frequency[]= {659,554}; //frequency array for both sound and LED (Taken from the mbed website)
el12moe 0:1c121c73ab08 87 float beat[]= {1,1}; //beat array for both sound and LED
el12moe 0:1c121c73ab08 88
el12moe 0:1c121c73ab08 89 //RSP packets dependencies
el12moe 0:1c121c73ab08 90 int room=0;
el12moe 0:1c121c73ab08 91 int mode=0;
el12moe 0:1c121c73ab08 92 int red=0;
el12moe 0:1c121c73ab08 93 int green=0;
el12moe 0:1c121c73ab08 94 int blue=0;
el12moe 0:1c121c73ab08 95
el12moe 0:1c121c73ab08 96 //lights mode dependencies
el12moe 0:1c121c73ab08 97 int rg[8][3] = {{255,0,0},{0,255,0},{255,0,0},{0,255,0},{255,0,0},{0,255,0},{255,0,0},{0,225,0}};
el12moe 0:1c121c73ab08 98 int gr[8][3] = {{0,255,0},{255,0,0},{0,255,0},{255,0,0},{0,255,0},{255,0,0},{0,225,0},{255,0,0}};
el12moe 0:1c121c73ab08 99
el12moe 0:1c121c73ab08 100 int bw[8][3] = {{0,0,255},{255,255,255},{0,0,255},{255,255,255},{0,0,255},{255,255,255},{0,0,255},{255,255,255}};
el12moe 0:1c121c73ab08 101 int wb[8][3] = {{255,255,255},{0,0,255},{255,255,255},{0,0,255},{255,255,255},{0,0,255},{255,255,255},{0,0,255}};
el12moe 0:1c121c73ab08 102
el12moe 0:1c121c73ab08 103 int rgb[8][3] = {{255,0,0},{0,255,0},{0,0,255},{255,0,0},{0,255,0},{0,0,255},{255,0,0},{0,255,0}};
el12moe 0:1c121c73ab08 104 int brg[8][3] = {{0,0,255},{255,0,0},{0,255,0},{0,0,255},{255,0,0},{0,255,0},{0,0,255},{255,0,0}};
el12moe 0:1c121c73ab08 105 int gbr[8][3] = {{0,255,0},{0,0,255},{255,0,0},{0,255,0},{0,0,255},{255,0,0},{0,255,0},{0,0,255}};
el12moe 0:1c121c73ab08 106 int bgr[8][3] = {{0,0,255},{0,255,0},{255,0,0},{0,0,255},{0,255,0},{255,0,0},{0,0,255},{0,255,0}};
el12moe 0:1c121c73ab08 107
el12moe 0:1c121c73ab08 108 int ak1[8][3] = {{255,0,0},{0,255,0},{0,0,0},{255,0,0},{0,255,0},{0,0,0},{255,0,0},{0,255,0}};
el12moe 0:1c121c73ab08 109 int ak2[8][3] = {{0,0,0},{255,0,0},{0,255,0},{0,0,0},{255,0,0},{0,255,0},{0,0,0},{255,0,0}};
el12moe 0:1c121c73ab08 110 int ak3[8][3] = {{0,255,0},{0,0,0},{255,0,0},{0,255,0},{0,0,0},{255,0,0},{0,255,0},{0,0,0}};
el12moe 0:1c121c73ab08 111 int ak4[8][3] = {{0,0,0},{0,255,0},{255,0,0},{0,0,0},{0,255,0},{255,0,0},{0,0,0},{0,255,0}};
el12moe 0:1c121c73ab08 112
el12moe 0:1c121c73ab08 113 int ra1[8][3] = {{255,0,0},{255,165,0},{255,255,0},{255,255,255},{0,255,0},{0,0,255},{75,0,255},{238,130,238}};
el12moe 0:1c121c73ab08 114 int ra2[8][3] = {{255,165,0},{255,255,0},{255,255,255},{0,255,0},{0,0,255},{75,0,255},{238,130,238},{255,0,0}};
el12moe 0:1c121c73ab08 115 int ra3[8][3] = {{255,255,0},{255,255,255},{0,255,0},{0,0,255},{75,0,255},{238,130,238},{255,0,0},{255,165,0}};
el12moe 0:1c121c73ab08 116 int ra4[8][3] = {{255,255,255},{0,255,0},{0,0,255},{75,0,255},{238,130,238},{255,0,0},{255,165,0},{255,255,0}};
el12moe 0:1c121c73ab08 117 int ra5[8][3] = {{0,255,0},{0,0,255},{75,0,255},{238,130,238},{255,0,0},{255,165,0},{255,255,0},{255,255,255}};
el12moe 0:1c121c73ab08 118 int ra6[8][3] = {{0,0,255},{75,0,255},{238,130,238},{255,0,0},{255,165,0},{255,255,0},{255,255,255},{0,255,0}};
el12moe 0:1c121c73ab08 119 int ra7[8][3] = {{75,0,255},{238,130,238},{255,0,0},{255,165,0},{255,255,0},{255,255,255},{0,255,0},{0,0,255}};
el12moe 0:1c121c73ab08 120 int ra8[8][3] = {{238,130,238},{255,0,0},{255,165,0},{255,255,0},{255,255,255},{0,255,0},{0,0,255},{75,0,255}};
el12moe 0:1c121c73ab08 121
el12moe 0:1c121c73ab08 122
el12moe 0:1c121c73ab08 123 int main() {
el12moe 0:1c121c73ab08 124 xmas.attach(&mbedReceive, 1.0);
el12moe 0:1c121c73ab08 125 while(1) {
el12moe 0:1c121c73ab08 126 if(pi.readable()){
el12moe 0:1c121c73ab08 127 modeActivated();
el12moe 0:1c121c73ab08 128 //mbedReceive();
el12moe 0:1c121c73ab08 129 }
el12moe 0:1c121c73ab08 130 xbee_detect();
el12moe 0:1c121c73ab08 131 if(r10 ==0){
el12moe 0:1c121c73ab08 132 xb1.attach(&xb11, 0.05);
el12moe 0:1c121c73ab08 133 }
el12moe 0:1c121c73ab08 134 if(r20 ==0){
el12moe 0:1c121c73ab08 135 xb2.attach(&xb12, 0.05);
el12moe 0:1c121c73ab08 136 }
el12moe 0:1c121c73ab08 137 if(r10 ==1){
el12moe 0:1c121c73ab08 138 xb1.detach();
el12moe 0:1c121c73ab08 139 }
el12moe 0:1c121c73ab08 140 if(r20 ==1){
el12moe 0:1c121c73ab08 141 xb2.detach();
el12moe 0:1c121c73ab08 142 }
el12moe 0:1c121c73ab08 143 }
el12moe 0:1c121c73ab08 144 }
el12moe 0:1c121c73ab08 145
el12moe 0:1c121c73ab08 146 void xb11(void){
el12moe 0:1c121c73ab08 147 normal_mode();
el12moe 0:1c121c73ab08 148 }
el12moe 0:1c121c73ab08 149
el12moe 0:1c121c73ab08 150 void xb12(void){
el12moe 0:1c121c73ab08 151 normal_mode2();
el12moe 0:1c121c73ab08 152 }
el12moe 0:1c121c73ab08 153
el12moe 0:1c121c73ab08 154 // function to receive stuff from pi
el12moe 0:1c121c73ab08 155 void mbedReceive(void){
el12moe 0:1c121c73ab08 156 int section = pi.getc();
el12moe 0:1c121c73ab08 157 if (section==1){
el12moe 0:1c121c73ab08 158 security(); //activate security mode
el12moe 0:1c121c73ab08 159 r20=1;
el12moe 0:1c121c73ab08 160 r10=1;
el12moe 0:1c121c73ab08 161 }
el12moe 0:1c121c73ab08 162 else if (section==2){
el12moe 0:1c121c73ab08 163 room = pi.getc();
el12moe 0:1c121c73ab08 164 mode = pi.getc();
el12moe 0:1c121c73ab08 165 red = pi.getc();
el12moe 0:1c121c73ab08 166 green = pi.getc();
el12moe 0:1c121c73ab08 167 blue = pi.getc();
el12moe 0:1c121c73ab08 168 r20=1;
el12moe 0:1c121c73ab08 169 r10=1;
el12moe 0:1c121c73ab08 170 }
el12moe 0:1c121c73ab08 171 else if (section==0){
el12moe 0:1c121c73ab08 172 //normal lights function a way of stopping different light modes
el12moe 0:1c121c73ab08 173 // b2() stop alarm
el12moe 0:1c121c73ab08 174 r20=0;
el12moe 0:1c121c73ab08 175 r10=0;
el12moe 0:1c121c73ab08 176 room = pi.getc();
el12moe 0:1c121c73ab08 177 if (room==1){
el12moe 0:1c121c73ab08 178 r10=0;
el12moe 0:1c121c73ab08 179 //normal mode 1
el12moe 0:1c121c73ab08 180 }
el12moe 0:1c121c73ab08 181 else if (room==2){
el12moe 0:1c121c73ab08 182 r20=0;
el12moe 0:1c121c73ab08 183 //normal mode 2
el12moe 0:1c121c73ab08 184 }
el12moe 0:1c121c73ab08 185
el12moe 0:1c121c73ab08 186 }
el12moe 0:1c121c73ab08 187 }
el12moe 0:1c121c73ab08 188
el12moe 0:1c121c73ab08 189 void modeActivated(void){
el12moe 0:1c121c73ab08 190 mbedReceive();
el12moe 0:1c121c73ab08 191 if (mode==1){
el12moe 0:1c121c73ab08 192 brightness();
el12moe 0:1c121c73ab08 193 }
el12moe 0:1c121c73ab08 194 if (mode==2){
el12moe 0:1c121c73ab08 195 colour();
el12moe 0:1c121c73ab08 196 }
el12moe 0:1c121c73ab08 197 if (mode==3){
el12moe 0:1c121c73ab08 198 festive();
el12moe 0:1c121c73ab08 199 }
el12moe 0:1c121c73ab08 200 if (mode==4){
el12moe 0:1c121c73ab08 201 sleep();
el12moe 0:1c121c73ab08 202 }
el12moe 0:1c121c73ab08 203 if (mode==5){
el12moe 0:1c121c73ab08 204 presetBrightness();
el12moe 0:1c121c73ab08 205 }
el12moe 0:1c121c73ab08 206 if (mode==6){
el12moe 0:1c121c73ab08 207 presetColour();
el12moe 0:1c121c73ab08 208 }
el12moe 0:1c121c73ab08 209
el12moe 0:1c121c73ab08 210 }
el12moe 0:1c121c73ab08 211
el12moe 0:1c121c73ab08 212 void security(void){
el12moe 0:1c121c73ab08 213
el12moe 0:1c121c73ab08 214 }
el12moe 0:1c121c73ab08 215
el12moe 0:1c121c73ab08 216 void brightness(void){
el12moe 0:1c121c73ab08 217 if (room==1){
el12moe 0:1c121c73ab08 218 r10=1;
el12moe 0:1c121c73ab08 219 lights.setRGBStrip1(red, red, red);
el12moe 0:1c121c73ab08 220 }
el12moe 0:1c121c73ab08 221 if (room==2){
el12moe 0:1c121c73ab08 222 r20=1;
el12moe 0:1c121c73ab08 223 lights.setRGBStrip2(red, red, red);
el12moe 0:1c121c73ab08 224 }
el12moe 0:1c121c73ab08 225 }
el12moe 0:1c121c73ab08 226 void colour(void){
el12moe 0:1c121c73ab08 227 if (room==1){
el12moe 0:1c121c73ab08 228 r10=1;
el12moe 0:1c121c73ab08 229 lights.setRGBStrip1(red, green, blue);
el12moe 0:1c121c73ab08 230 }
el12moe 0:1c121c73ab08 231 if (room==2){
el12moe 0:1c121c73ab08 232 r20=1;
el12moe 0:1c121c73ab08 233 lights.setRGBStrip2(red, green, blue);
el12moe 0:1c121c73ab08 234 }
el12moe 0:1c121c73ab08 235
el12moe 0:1c121c73ab08 236 }
el12moe 0:1c121c73ab08 237 void festive(void){
el12moe 0:1c121c73ab08 238 if (room==1){
el12moe 0:1c121c73ab08 239 r10=1;
el12moe 0:1c121c73ab08 240 if(red==1){
el12moe 0:1c121c73ab08 241 christmas();
el12moe 0:1c121c73ab08 242 }
el12moe 0:1c121c73ab08 243 if(red==2){
el12moe 0:1c121c73ab08 244 hunika();
el12moe 0:1c121c73ab08 245 }
el12moe 0:1c121c73ab08 246 if(red==3){
el12moe 0:1c121c73ab08 247 akwansa();
el12moe 0:1c121c73ab08 248 }
el12moe 0:1c121c73ab08 249 if(red==4){
el12moe 0:1c121c73ab08 250 rainbow();
el12moe 0:1c121c73ab08 251 }
el12moe 0:1c121c73ab08 252 if(red==5){
el12moe 0:1c121c73ab08 253 rgbm();
el12moe 0:1c121c73ab08 254 }
el12moe 0:1c121c73ab08 255 }
el12moe 0:1c121c73ab08 256 else if (room==2){
el12moe 0:1c121c73ab08 257 r20=1;
el12moe 0:1c121c73ab08 258 if(red==1){
el12moe 0:1c121c73ab08 259
el12moe 0:1c121c73ab08 260 christmas2();
el12moe 0:1c121c73ab08 261 }
el12moe 0:1c121c73ab08 262 if(red==2){
el12moe 0:1c121c73ab08 263 hunika2();
el12moe 0:1c121c73ab08 264 }
el12moe 0:1c121c73ab08 265 if(red==3){
el12moe 0:1c121c73ab08 266 akwansa2();
el12moe 0:1c121c73ab08 267 }
el12moe 0:1c121c73ab08 268 if(red==4){
el12moe 0:1c121c73ab08 269 rainbow2();
el12moe 0:1c121c73ab08 270 }
el12moe 0:1c121c73ab08 271 if(red==5){
el12moe 0:1c121c73ab08 272 rgbm2();
el12moe 0:1c121c73ab08 273 }
el12moe 0:1c121c73ab08 274 }
el12moe 0:1c121c73ab08 275 }
el12moe 0:1c121c73ab08 276 void sleep(void){
el12moe 0:1c121c73ab08 277 if (room==1){
el12moe 0:1c121c73ab08 278 r10=1;
el12moe 0:1c121c73ab08 279 // setRGBStrip1(red, green, blue); sleep pattern for strip1
el12moe 0:1c121c73ab08 280 }
el12moe 0:1c121c73ab08 281 if (room==2){
el12moe 0:1c121c73ab08 282 r20=1;
el12moe 0:1c121c73ab08 283 // setRGBStrip2(red, green, blue);sleep pattern for strip1
el12moe 0:1c121c73ab08 284 }
el12moe 0:1c121c73ab08 285 }
el12moe 0:1c121c73ab08 286 void presetBrightness(void){
el12moe 0:1c121c73ab08 287
el12moe 0:1c121c73ab08 288 }
el12moe 0:1c121c73ab08 289 void presetColour(void){
el12moe 0:1c121c73ab08 290
el12moe 0:1c121c73ab08 291 }
el12moe 0:1c121c73ab08 292
el12moe 0:1c121c73ab08 293 //xmas red & green
el12moe 0:1c121c73ab08 294 void christmas(void){
el12moe 0:1c121c73ab08 295 lights.setRGBPixels1(rg);
el12moe 0:1c121c73ab08 296 wait(1);
el12moe 0:1c121c73ab08 297 lights.setRGBPixels1(gr);
el12moe 0:1c121c73ab08 298 wait(1);
el12moe 0:1c121c73ab08 299 lights.setRGBPixels1(rg);
el12moe 0:1c121c73ab08 300 wait(1);
el12moe 0:1c121c73ab08 301 lights.setRGBPixels1(gr);
el12moe 0:1c121c73ab08 302 wait(1);
el12moe 0:1c121c73ab08 303 lights.setRGBPixels1(rg);
el12moe 0:1c121c73ab08 304 wait(1);
el12moe 0:1c121c73ab08 305 lights.setRGBPixels1(gr);
el12moe 0:1c121c73ab08 306 wait(1);
el12moe 0:1c121c73ab08 307 lights.setRGBPixels1(rg);
el12moe 0:1c121c73ab08 308 wait(1);
el12moe 0:1c121c73ab08 309 lights.setRGBPixels1(gr);
el12moe 0:1c121c73ab08 310 wait(1);
el12moe 0:1c121c73ab08 311 lights.setRGBPixels1(rg);
el12moe 0:1c121c73ab08 312 wait(1);
el12moe 0:1c121c73ab08 313 lights.setRGBPixels1(gr);
el12moe 0:1c121c73ab08 314 wait(1);
el12moe 0:1c121c73ab08 315 lights.setRGBStrip1(255, 0, 0);
el12moe 0:1c121c73ab08 316 wait(1);
el12moe 0:1c121c73ab08 317 lights.setRGBStrip1(0,255,0);
el12moe 0:1c121c73ab08 318 wait(1);
el12moe 0:1c121c73ab08 319 }
el12moe 0:1c121c73ab08 320 void hunika(void){
el12moe 0:1c121c73ab08 321 lights.setRGBPixels1(bw);
el12moe 0:1c121c73ab08 322 wait(1);
el12moe 0:1c121c73ab08 323 lights.setRGBPixels1(wb);
el12moe 0:1c121c73ab08 324 wait(1);
el12moe 0:1c121c73ab08 325 lights.setRGBPixels1(bw);
el12moe 0:1c121c73ab08 326 wait(1);
el12moe 0:1c121c73ab08 327 lights.setRGBPixels1(wb);
el12moe 0:1c121c73ab08 328 wait(1);
el12moe 0:1c121c73ab08 329 lights.setRGBPixels1(bw);
el12moe 0:1c121c73ab08 330 wait(1);
el12moe 0:1c121c73ab08 331 lights.setRGBPixels1(wb);
el12moe 0:1c121c73ab08 332 wait(1);
el12moe 0:1c121c73ab08 333 lights.setRGBPixels1(bw);
el12moe 0:1c121c73ab08 334 wait(1);
el12moe 0:1c121c73ab08 335 lights.setRGBPixels1(wb);
el12moe 0:1c121c73ab08 336 wait(1);
el12moe 0:1c121c73ab08 337 lights.setRGBPixels1(bw);
el12moe 0:1c121c73ab08 338 wait(1);
el12moe 0:1c121c73ab08 339 lights.setRGBPixels1(wb);
el12moe 0:1c121c73ab08 340 wait(1);
el12moe 0:1c121c73ab08 341 lights.setRGBStrip1(0, 0, 255);
el12moe 0:1c121c73ab08 342 wait(1);
el12moe 0:1c121c73ab08 343 lights.setRGBStrip1(255,255,255);
el12moe 0:1c121c73ab08 344 wait(1);
el12moe 0:1c121c73ab08 345 }
el12moe 0:1c121c73ab08 346
el12moe 0:1c121c73ab08 347 void akwansa(void){
el12moe 0:1c121c73ab08 348 lights.setRGBPixels1(ak1);
el12moe 0:1c121c73ab08 349 wait(1);
el12moe 0:1c121c73ab08 350 lights.setRGBPixels1(ak2);
el12moe 0:1c121c73ab08 351 wait(1);
el12moe 0:1c121c73ab08 352 lights.setRGBPixels1(ak3);
el12moe 0:1c121c73ab08 353 wait(1);
el12moe 0:1c121c73ab08 354 lights.setRGBPixels1(ak4);
el12moe 0:1c121c73ab08 355 wait(1);
el12moe 0:1c121c73ab08 356 lights.setRGBPixels1(ak1);
el12moe 0:1c121c73ab08 357 wait(1);
el12moe 0:1c121c73ab08 358 lights.setRGBPixels1(ak2);
el12moe 0:1c121c73ab08 359 wait(1);
el12moe 0:1c121c73ab08 360 lights.setRGBPixels1(ak3);
el12moe 0:1c121c73ab08 361 wait(1);
el12moe 0:1c121c73ab08 362 lights.setRGBPixels1(ak4);
el12moe 0:1c121c73ab08 363 wait(1);
el12moe 0:1c121c73ab08 364 lights.setRGBPixels1(ak1);
el12moe 0:1c121c73ab08 365 wait(1);
el12moe 0:1c121c73ab08 366 lights.setRGBPixels1(ak2);
el12moe 0:1c121c73ab08 367 wait(1);
el12moe 0:1c121c73ab08 368 lights.setRGBPixels1(ak3);
el12moe 0:1c121c73ab08 369 wait(1);
el12moe 0:1c121c73ab08 370 lights.setRGBPixels1(ak4);
el12moe 0:1c121c73ab08 371 wait(1);
el12moe 0:1c121c73ab08 372 }
el12moe 0:1c121c73ab08 373 void rainbow(void){
el12moe 0:1c121c73ab08 374 lights.setRGBPixels1(ra1);
el12moe 0:1c121c73ab08 375 wait(1);
el12moe 0:1c121c73ab08 376 lights.setRGBPixels1(ra2);
el12moe 0:1c121c73ab08 377 wait(1);
el12moe 0:1c121c73ab08 378 lights.setRGBPixels1(ra3);
el12moe 0:1c121c73ab08 379 wait(1);
el12moe 0:1c121c73ab08 380 lights.setRGBPixels1(ra4);
el12moe 0:1c121c73ab08 381 wait(1);
el12moe 0:1c121c73ab08 382 lights.setRGBPixels1(ra5);
el12moe 0:1c121c73ab08 383 wait(1);
el12moe 0:1c121c73ab08 384 lights.setRGBPixels1(ra6);
el12moe 0:1c121c73ab08 385 wait(1);
el12moe 0:1c121c73ab08 386 lights.setRGBPixels1(ra7);
el12moe 0:1c121c73ab08 387 wait(1);
el12moe 0:1c121c73ab08 388 lights.setRGBPixels1(ra8);
el12moe 0:1c121c73ab08 389 wait(1);
el12moe 0:1c121c73ab08 390 }
el12moe 0:1c121c73ab08 391
el12moe 0:1c121c73ab08 392 void rgbm(void){
el12moe 0:1c121c73ab08 393 lights.setRGBPixels2(rgb);
el12moe 0:1c121c73ab08 394 wait(1);
el12moe 0:1c121c73ab08 395 lights.setRGBPixels2(brg);
el12moe 0:1c121c73ab08 396 wait(1);
el12moe 0:1c121c73ab08 397 lights.setRGBPixels2(gbr);
el12moe 0:1c121c73ab08 398 wait(1);
el12moe 0:1c121c73ab08 399 lights.setRGBPixels2(bgr);
el12moe 0:1c121c73ab08 400 wait(1);
el12moe 0:1c121c73ab08 401 lights.setRGBPixels2(rgb);
el12moe 0:1c121c73ab08 402 wait(1);
el12moe 0:1c121c73ab08 403 lights.setRGBPixels2(brg);
el12moe 0:1c121c73ab08 404 wait(1);
el12moe 0:1c121c73ab08 405 lights.setRGBPixels2(gbr);
el12moe 0:1c121c73ab08 406 wait(1);
el12moe 0:1c121c73ab08 407 lights.setRGBPixels2(bgr);
el12moe 0:1c121c73ab08 408 wait(1);
el12moe 0:1c121c73ab08 409 lights.setRGBPixels2(rgb);
el12moe 0:1c121c73ab08 410 wait(1);
el12moe 0:1c121c73ab08 411 lights.setRGBPixels2(brg);
el12moe 0:1c121c73ab08 412 wait(1);
el12moe 0:1c121c73ab08 413 lights.setRGBPixels2(gbr);
el12moe 0:1c121c73ab08 414 wait(1);
el12moe 0:1c121c73ab08 415 lights.setRGBPixels2(bgr);
el12moe 0:1c121c73ab08 416 wait(1);
el12moe 0:1c121c73ab08 417 lights.setRGBStrip2(255, 0, 0);
el12moe 0:1c121c73ab08 418 wait(1);
el12moe 0:1c121c73ab08 419 lights.setRGBStrip2(0,255,0);
el12moe 0:1c121c73ab08 420 wait(1);
el12moe 0:1c121c73ab08 421 lights.setRGBStrip2(0,0,255);
el12moe 0:1c121c73ab08 422 wait(1);
el12moe 0:1c121c73ab08 423 }
el12moe 0:1c121c73ab08 424
el12moe 0:1c121c73ab08 425 void christmas2(void){
el12moe 0:1c121c73ab08 426 lights.setRGBPixels2(rg);
el12moe 0:1c121c73ab08 427 wait(1);
el12moe 0:1c121c73ab08 428 lights.setRGBPixels2(gr);
el12moe 0:1c121c73ab08 429 wait(1);
el12moe 0:1c121c73ab08 430 lights.setRGBPixels2(rg);
el12moe 0:1c121c73ab08 431 wait(1);
el12moe 0:1c121c73ab08 432 lights.setRGBPixels2(gr);
el12moe 0:1c121c73ab08 433 wait(1);
el12moe 0:1c121c73ab08 434 lights.setRGBPixels2(rg);
el12moe 0:1c121c73ab08 435 wait(1);
el12moe 0:1c121c73ab08 436 lights.setRGBPixels2(gr);
el12moe 0:1c121c73ab08 437 wait(1);
el12moe 0:1c121c73ab08 438 lights.setRGBPixels2(rg);
el12moe 0:1c121c73ab08 439 wait(1);
el12moe 0:1c121c73ab08 440 lights.setRGBPixels2(gr);
el12moe 0:1c121c73ab08 441 wait(1);
el12moe 0:1c121c73ab08 442 lights.setRGBPixels2(rg);
el12moe 0:1c121c73ab08 443 wait(1);
el12moe 0:1c121c73ab08 444 lights.setRGBPixels2(gr);
el12moe 0:1c121c73ab08 445 wait(1);
el12moe 0:1c121c73ab08 446 lights.setRGBStrip2(255, 0, 0);
el12moe 0:1c121c73ab08 447 wait(1);
el12moe 0:1c121c73ab08 448 lights.setRGBStrip2(0,255,0);
el12moe 0:1c121c73ab08 449 wait(1);
el12moe 0:1c121c73ab08 450 }
el12moe 0:1c121c73ab08 451
el12moe 0:1c121c73ab08 452 void hunika2(void){
el12moe 0:1c121c73ab08 453 lights.setRGBPixels2(bw);
el12moe 0:1c121c73ab08 454 wait(1);
el12moe 0:1c121c73ab08 455 lights.setRGBPixels2(wb);
el12moe 0:1c121c73ab08 456 wait(1);
el12moe 0:1c121c73ab08 457 lights.setRGBPixels2(bw);
el12moe 0:1c121c73ab08 458 wait(1);
el12moe 0:1c121c73ab08 459 lights.setRGBPixels2(wb);
el12moe 0:1c121c73ab08 460 wait(1);
el12moe 0:1c121c73ab08 461 lights.setRGBPixels2(bw);
el12moe 0:1c121c73ab08 462 wait(1);
el12moe 0:1c121c73ab08 463 lights.setRGBPixels2(wb);
el12moe 0:1c121c73ab08 464 wait(1);
el12moe 0:1c121c73ab08 465 lights.setRGBPixels2(bw);
el12moe 0:1c121c73ab08 466 wait(1);
el12moe 0:1c121c73ab08 467 lights.setRGBPixels2(wb);
el12moe 0:1c121c73ab08 468 wait(1);
el12moe 0:1c121c73ab08 469 lights.setRGBPixels2(bw);
el12moe 0:1c121c73ab08 470 wait(1);
el12moe 0:1c121c73ab08 471 lights.setRGBPixels2(wb);
el12moe 0:1c121c73ab08 472 wait(1);
el12moe 0:1c121c73ab08 473 lights.setRGBStrip2(0, 0, 255);
el12moe 0:1c121c73ab08 474 wait(1);
el12moe 0:1c121c73ab08 475 lights.setRGBStrip2(255,255,255);
el12moe 0:1c121c73ab08 476 wait(1);
el12moe 0:1c121c73ab08 477 }
el12moe 0:1c121c73ab08 478
el12moe 0:1c121c73ab08 479 void akwansa2(void){
el12moe 0:1c121c73ab08 480 lights.setRGBPixels2(ak1);
el12moe 0:1c121c73ab08 481 wait(1);
el12moe 0:1c121c73ab08 482 lights.setRGBPixels2(ak2);
el12moe 0:1c121c73ab08 483 wait(1);
el12moe 0:1c121c73ab08 484 lights.setRGBPixels2(ak3);
el12moe 0:1c121c73ab08 485 wait(1);
el12moe 0:1c121c73ab08 486 lights.setRGBPixels2(ak4);
el12moe 0:1c121c73ab08 487 wait(1);
el12moe 0:1c121c73ab08 488 lights.setRGBPixels2(ak1);
el12moe 0:1c121c73ab08 489 wait(1);
el12moe 0:1c121c73ab08 490 lights.setRGBPixels2(ak2);
el12moe 0:1c121c73ab08 491 wait(1);
el12moe 0:1c121c73ab08 492 lights.setRGBPixels2(ak3);
el12moe 0:1c121c73ab08 493 wait(1);
el12moe 0:1c121c73ab08 494 lights.setRGBPixels2(ak4);
el12moe 0:1c121c73ab08 495 wait(1);
el12moe 0:1c121c73ab08 496 lights.setRGBPixels2(ak1);
el12moe 0:1c121c73ab08 497 wait(1);
el12moe 0:1c121c73ab08 498 lights.setRGBPixels2(ak2);
el12moe 0:1c121c73ab08 499 wait(1);
el12moe 0:1c121c73ab08 500 lights.setRGBPixels2(ak3);
el12moe 0:1c121c73ab08 501 wait(1);
el12moe 0:1c121c73ab08 502 lights.setRGBPixels2(ak4);
el12moe 0:1c121c73ab08 503 wait(1);
el12moe 0:1c121c73ab08 504 }
el12moe 0:1c121c73ab08 505
el12moe 0:1c121c73ab08 506
el12moe 0:1c121c73ab08 507 void rainbow2(void){
el12moe 0:1c121c73ab08 508 lights.setRGBPixels2(ra1);
el12moe 0:1c121c73ab08 509 wait(1);
el12moe 0:1c121c73ab08 510 lights.setRGBPixels2(ra2);
el12moe 0:1c121c73ab08 511 wait(1);
el12moe 0:1c121c73ab08 512 lights.setRGBPixels2(ra3);
el12moe 0:1c121c73ab08 513 wait(1);
el12moe 0:1c121c73ab08 514 lights.setRGBPixels2(ra4);
el12moe 0:1c121c73ab08 515 wait(1);
el12moe 0:1c121c73ab08 516 lights.setRGBPixels2(ra5);
el12moe 0:1c121c73ab08 517 wait(1);
el12moe 0:1c121c73ab08 518 lights.setRGBPixels2(ra6);
el12moe 0:1c121c73ab08 519 wait(1);
el12moe 0:1c121c73ab08 520 lights.setRGBPixels2(ra7);
el12moe 0:1c121c73ab08 521 wait(1);
el12moe 0:1c121c73ab08 522 lights.setRGBPixels2(ra8);
el12moe 0:1c121c73ab08 523 wait(1);
el12moe 0:1c121c73ab08 524 }
el12moe 0:1c121c73ab08 525
el12moe 0:1c121c73ab08 526
el12moe 0:1c121c73ab08 527 void rgbm2(void){
el12moe 0:1c121c73ab08 528 lights.setRGBPixels2(rgb);
el12moe 0:1c121c73ab08 529 wait(1);
el12moe 0:1c121c73ab08 530 lights.setRGBPixels2(brg);
el12moe 0:1c121c73ab08 531 wait(1);
el12moe 0:1c121c73ab08 532 lights.setRGBPixels2(gbr);
el12moe 0:1c121c73ab08 533 wait(1);
el12moe 0:1c121c73ab08 534 lights.setRGBPixels2(bgr);
el12moe 0:1c121c73ab08 535 wait(1);
el12moe 0:1c121c73ab08 536 lights.setRGBPixels2(rgb);
el12moe 0:1c121c73ab08 537 wait(1);
el12moe 0:1c121c73ab08 538 lights.setRGBPixels2(brg);
el12moe 0:1c121c73ab08 539 wait(1);
el12moe 0:1c121c73ab08 540 lights.setRGBPixels2(gbr);
el12moe 0:1c121c73ab08 541 wait(1);
el12moe 0:1c121c73ab08 542 lights.setRGBPixels2(bgr);
el12moe 0:1c121c73ab08 543 wait(1);
el12moe 0:1c121c73ab08 544 lights.setRGBPixels2(rgb);
el12moe 0:1c121c73ab08 545 wait(1);
el12moe 0:1c121c73ab08 546 lights.setRGBPixels2(brg);
el12moe 0:1c121c73ab08 547 wait(1);
el12moe 0:1c121c73ab08 548 lights.setRGBPixels2(gbr);
el12moe 0:1c121c73ab08 549 wait(1);
el12moe 0:1c121c73ab08 550 lights.setRGBPixels2(bgr);
el12moe 0:1c121c73ab08 551 wait(1);
el12moe 0:1c121c73ab08 552 lights.setRGBStrip2(255, 0, 0);
el12moe 0:1c121c73ab08 553 wait(1);
el12moe 0:1c121c73ab08 554 lights.setRGBStrip2(0,255,0);
el12moe 0:1c121c73ab08 555 wait(1);
el12moe 0:1c121c73ab08 556 lights.setRGBStrip2(0,0,255);
el12moe 0:1c121c73ab08 557 wait(1);
el12moe 0:1c121c73ab08 558 }
el12moe 0:1c121c73ab08 559
el12moe 0:1c121c73ab08 560 void xbee_detect(void){
el12moe 0:1c121c73ab08 561 if (xbee.getc() == 0x7E) {
el12moe 0:1c121c73ab08 562 for (int i = 0; i < 19; i++) {
el12moe 0:1c121c73ab08 563 if (i<10){
el12moe 0:1c121c73ab08 564 int discard = xbee.getc();
el12moe 0:1c121c73ab08 565 }
el12moe 0:1c121c73ab08 566 else if (i<11){
el12moe 0:1c121c73ab08 567 readAddress = xbee.getc();
el12moe 0:1c121c73ab08 568 }
el12moe 0:1c121c73ab08 569 else{
el12moe 0:1c121c73ab08 570 int discarded = xbee.getc();
el12moe 0:1c121c73ab08 571 }
el12moe 0:1c121c73ab08 572 }
el12moe 0:1c121c73ab08 573 readValue = xbee.getc();
el12moe 0:1c121c73ab08 574 }
el12moe 0:1c121c73ab08 575 }
el12moe 0:1c121c73ab08 576 //lights room1
el12moe 0:1c121c73ab08 577 void light1(void){
el12moe 0:1c121c73ab08 578 if ( readAddress == xbee2){
el12moe 0:1c121c73ab08 579 if (readValue == 0){
el12moe 0:1c121c73ab08 580 counter2++;
el12moe 0:1c121c73ab08 581 count2();
el12moe 0:1c121c73ab08 582 }
el12moe 0:1c121c73ab08 583 else if(readValue == 16){
el12moe 0:1c121c73ab08 584 counter2 = 0;
el12moe 0:1c121c73ab08 585 lights.setRGBStrip1(127,127,127);
el12moe 0:1c121c73ab08 586 // wait(2);//mled = 1;
el12moe 0:1c121c73ab08 587 }
el12moe 0:1c121c73ab08 588 }
el12moe 0:1c121c73ab08 589 }
el12moe 0:1c121c73ab08 590 //room 2
el12moe 0:1c121c73ab08 591 void light2(void){
el12moe 0:1c121c73ab08 592 if ( readAddress == xbee4){
el12moe 0:1c121c73ab08 593 if (readValue == 0){
el12moe 0:1c121c73ab08 594 counter4++;
el12moe 0:1c121c73ab08 595 count4();
el12moe 0:1c121c73ab08 596
el12moe 0:1c121c73ab08 597 }
el12moe 0:1c121c73ab08 598
el12moe 0:1c121c73ab08 599 else if(readValue == 16){
el12moe 0:1c121c73ab08 600 counter4 = 0;
el12moe 0:1c121c73ab08 601 lights.setRGBStrip2(127,127,127);
el12moe 0:1c121c73ab08 602 }
el12moe 0:1c121c73ab08 603 }
el12moe 0:1c121c73ab08 604 }
el12moe 0:1c121c73ab08 605
el12moe 0:1c121c73ab08 606 void reed1(void){
el12moe 0:1c121c73ab08 607 if( readAddress == xbee1){
el12moe 0:1c121c73ab08 608 if (readValue == 0){
el12moe 0:1c121c73ab08 609 //counter1++;
el12moe 0:1c121c73ab08 610 // count1();
el12moe 0:1c121c73ab08 611 b2();
el12moe 0:1c121c73ab08 612 }
el12moe 0:1c121c73ab08 613 else if(readValue == 16){
el12moe 0:1c121c73ab08 614 counter1 = 0;
el12moe 0:1c121c73ab08 615 // myled = 1;
el12moe 0:1c121c73ab08 616 b1();
el12moe 0:1c121c73ab08 617 }
el12moe 0:1c121c73ab08 618 }
el12moe 0:1c121c73ab08 619 }
el12moe 0:1c121c73ab08 620 //room 2
el12moe 0:1c121c73ab08 621 void reed2(void){
el12moe 0:1c121c73ab08 622 if ( readAddress == xbee3){
el12moe 0:1c121c73ab08 623 if (readValue == 0){
el12moe 0:1c121c73ab08 624 //counter3++;
el12moe 0:1c121c73ab08 625 //count3();
el12moe 0:1c121c73ab08 626 b2();
el12moe 0:1c121c73ab08 627 }
el12moe 0:1c121c73ab08 628 else if(readValue == 16){
el12moe 0:1c121c73ab08 629 //counter3 = 0;
el12moe 0:1c121c73ab08 630 // m3led = 1;
el12moe 0:1c121c73ab08 631 b1();
el12moe 0:1c121c73ab08 632 }
el12moe 0:1c121c73ab08 633 }
el12moe 0:1c121c73ab08 634 }
el12moe 0:1c121c73ab08 635
el12moe 0:1c121c73ab08 636 void count1(void){
el12moe 0:1c121c73ab08 637 if(counter1==10){
el12moe 0:1c121c73ab08 638 myled = 0;
el12moe 0:1c121c73ab08 639 counter1 = 0;
el12moe 0:1c121c73ab08 640 }
el12moe 0:1c121c73ab08 641 }
el12moe 0:1c121c73ab08 642 void count3(void){
el12moe 0:1c121c73ab08 643 if(counter3==10){
el12moe 0:1c121c73ab08 644 m3led = 0;
el12moe 0:1c121c73ab08 645 counter1 = 0;
el12moe 0:1c121c73ab08 646 }
el12moe 0:1c121c73ab08 647 }
el12moe 0:1c121c73ab08 648
el12moe 0:1c121c73ab08 649 //lights count
el12moe 0:1c121c73ab08 650 void count2(void){
el12moe 0:1c121c73ab08 651 if(counter2==150){
el12moe 0:1c121c73ab08 652 lights.setRGBStrip1(0,0,0);
el12moe 0:1c121c73ab08 653 counter2 = 0;
el12moe 0:1c121c73ab08 654 }
el12moe 0:1c121c73ab08 655 }
el12moe 0:1c121c73ab08 656
el12moe 0:1c121c73ab08 657 void count4(void){
el12moe 0:1c121c73ab08 658 if(counter4==150){
el12moe 0:1c121c73ab08 659 lights.setRGBStrip2(0,0,0);
el12moe 0:1c121c73ab08 660 counter2 = 0;
el12moe 0:1c121c73ab08 661 }
el12moe 0:1c121c73ab08 662 }
el12moe 0:1c121c73ab08 663
el12moe 0:1c121c73ab08 664 void b1(void){
el12moe 0:1c121c73ab08 665 for (int i=0; i<=1; i++) {
el12moe 0:1c121c73ab08 666 buzzer.period(1/(frequency[i])); // set PWM period
el12moe 0:1c121c73ab08 667 buzzer=0; // set duty cycle
el12moe 0:1c121c73ab08 668 //wait(0.1*beat[i]); // hold for beat period
el12moe 0:1c121c73ab08 669 // myled = 1;
el12moe 0:1c121c73ab08 670
el12moe 0:1c121c73ab08 671 }
el12moe 0:1c121c73ab08 672 }
el12moe 0:1c121c73ab08 673
el12moe 0:1c121c73ab08 674 void b2(void){
el12moe 0:1c121c73ab08 675 for (int i=0; i<=1; i++) {
el12moe 0:1c121c73ab08 676 buzzer.period(1/(frequency[i])); // set PWM period
el12moe 0:1c121c73ab08 677 buzzer=0.9; // set duty cycle
el12moe 0:1c121c73ab08 678 //wait(0.1*beat[i]); // hold for beat period
el12moe 0:1c121c73ab08 679 // myled = 1;
el12moe 0:1c121c73ab08 680
el12moe 0:1c121c73ab08 681 }
el12moe 0:1c121c73ab08 682 }
el12moe 0:1c121c73ab08 683
el12moe 0:1c121c73ab08 684 void normal_mode(void){
el12moe 0:1c121c73ab08 685 // light2();
el12moe 0:1c121c73ab08 686 light1();
el12moe 0:1c121c73ab08 687 reed1();
el12moe 0:1c121c73ab08 688 //reed2();
el12moe 0:1c121c73ab08 689 }
el12moe 0:1c121c73ab08 690
el12moe 0:1c121c73ab08 691 void normal_mode2(void){
el12moe 0:1c121c73ab08 692 light2();
el12moe 0:1c121c73ab08 693 //light1();
el12moe 0:1c121c73ab08 694 //reed1();
el12moe 0:1c121c73ab08 695 reed2();
el12moe 0:1c121c73ab08 696 }
el12moe 0:1c121c73ab08 697
el12moe 0:1c121c73ab08 698
el12moe 0:1c121c73ab08 699 // Alarm Dependencies
el12moe 0:1c121c73ab08 700 void alarmP1(void){
el12moe 0:1c121c73ab08 701 if ( readAddress == xbee2){
el12moe 0:1c121c73ab08 702 if (readValue == 0){
el12moe 0:1c121c73ab08 703 counter2++;
el12moe 0:1c121c73ab08 704 count2();
el12moe 0:1c121c73ab08 705 }
el12moe 0:1c121c73ab08 706 else if(readValue == 16){
el12moe 0:1c121c73ab08 707 counter2 = 0;
el12moe 0:1c121c73ab08 708 lights.setRGBStrip1(127,127,127);
el12moe 0:1c121c73ab08 709 b2();
el12moe 0:1c121c73ab08 710 // wait(2);//mled = 1;
el12moe 0:1c121c73ab08 711 }
el12moe 0:1c121c73ab08 712 }
el12moe 0:1c121c73ab08 713 }
el12moe 0:1c121c73ab08 714 //room 2
el12moe 0:1c121c73ab08 715 void alarmP2(void){
el12moe 0:1c121c73ab08 716 if ( readAddress == xbee4){
el12moe 0:1c121c73ab08 717 if (readValue == 0){
el12moe 0:1c121c73ab08 718 counter4++;
el12moe 0:1c121c73ab08 719 count4();
el12moe 0:1c121c73ab08 720 }
el12moe 0:1c121c73ab08 721
el12moe 0:1c121c73ab08 722 else if(readValue == 16){
el12moe 0:1c121c73ab08 723 counter4 = 0;
el12moe 0:1c121c73ab08 724 lights.setRGBStrip2(127,127,127);
el12moe 0:1c121c73ab08 725 b2();
el12moe 0:1c121c73ab08 726 }
el12moe 0:1c121c73ab08 727 }
el12moe 0:1c121c73ab08 728 }
el12moe 0:1c121c73ab08 729
el12moe 0:1c121c73ab08 730 void alarmR1(void){
el12moe 0:1c121c73ab08 731 if( readAddress == xbee1){
el12moe 0:1c121c73ab08 732 if (readValue == 0){
el12moe 0:1c121c73ab08 733 //counter1++;
el12moe 0:1c121c73ab08 734 // count1();
el12moe 0:1c121c73ab08 735 b2();
el12moe 0:1c121c73ab08 736 }
el12moe 0:1c121c73ab08 737 else if(readValue == 16){
el12moe 0:1c121c73ab08 738 counter1 = 0;
el12moe 0:1c121c73ab08 739 // myled = 1;
el12moe 0:1c121c73ab08 740 //b1();
el12moe 0:1c121c73ab08 741 }
el12moe 0:1c121c73ab08 742 }
el12moe 0:1c121c73ab08 743 }
el12moe 0:1c121c73ab08 744 //room 2
el12moe 0:1c121c73ab08 745 void alarmR2(void){
el12moe 0:1c121c73ab08 746 if ( readAddress == xbee3){
el12moe 0:1c121c73ab08 747 if (readValue == 0){
el12moe 0:1c121c73ab08 748 //counter3++;
el12moe 0:1c121c73ab08 749 //count3();
el12moe 0:1c121c73ab08 750 b2();
el12moe 0:1c121c73ab08 751 }
el12moe 0:1c121c73ab08 752 else if(readValue == 16){
el12moe 0:1c121c73ab08 753 //counter3 = 0;
el12moe 0:1c121c73ab08 754 // m3led = 1;
el12moe 0:1c121c73ab08 755 // b1();
el12moe 0:1c121c73ab08 756 }
el12moe 0:1c121c73ab08 757 }
el12moe 0:1c121c73ab08 758 }