// receiver.pde #include // http://www.open.com.au/mikem/arduino/VirtualWire-1.4.zip char inString[32]; int inCount; void setup() { pinMode(9, OUTPUT); // sets the LED pin to be an output pinMode(10, OUTPUT); // sets the LED pin to be an output ////// serial code is commented out because this application does ////// ////// not require a computer - remove comment to send to computer ////// //Serial.begin(9600); //Serial.println("setup"); vw_setup(2000); // Bits per sec vw_rx_start(); // Start the receiver PLL running } void loop() { uint8_t buf[VW_MAX_MESSAGE_LEN]; uint8_t buflen = VW_MAX_MESSAGE_LEN; inCount = 0; if (vw_get_message(buf, &buflen)) // Non-blocking { int i; digitalWrite(13, true); // turn on LED to show received good message // Message with a good checksum received, dump it. //Serial.print("Got: "); for (i = 0; i < buflen; i++) { //Serial.print(buf[i]); //Serial.print(" "); inString[inCount] = buf[i]; inCount++; } //Serial.println(""); ////// if statements comparing incoming message ////// if (strcmp(inString, "N") == 0){ digitalWrite(10, true); } if (strcmp(inString, "Y") == 0){ digitalWrite(10, false); } if (strcmp(inString, "O") == 0){ digitalWrite(9, true); } if (strcmp(inString, "Z") == 0){ digitalWrite(9, false); } digitalWrite(13, false); // turn off LED to show done } }