// transmitter.pde #include // http://www.open.com.au/mikem/arduino/VirtualWire-1.4.zip int switchPin1 = 9; // switch connected to digital pin 2 int switchValue1; // a variable to keep track of when switch is pressed int switchPin2 = 10; // switch connected to digital pin 2 int switchValue2; // a variable to keep track of when switch is pressed void setup() { pinMode(switchPin1, INPUT); // sets the switchPin to be an input digitalWrite(switchPin1, HIGH); // sets the default (unpressed) state of switchPin to HIGH pinMode(switchPin2, INPUT); // sets the switchPin to be an input digitalWrite(switchPin2, HIGH); // sets the default (unpressed) state of switchPin to HIGH vw_setup(2000); // Bits per sec } void loop() { ////// check switch1 ////// const char *mymessage1 = "B"; // check to see if the switch1 is pressed switchValue1 = digitalRead(switchPin1); if(switchValue1 == LOW) { mymessage1 = "Y"; } else { mymessage1 = "N"; } digitalWrite(13, true); // turn on LED to show transmitting vw_send((uint8_t *)mymessage1, strlen(mymessage1)); // transmit message vw_wait_tx(); // Wait until the whole message is gone digitalWrite(13, false); //turn off LED to show tranmitting is done ////// check switch2 ////// const char *mymessage2 = "C"; // check to see if the switch2 is pressed switchValue2 = digitalRead(switchPin2); if(switchValue2 == LOW) { mymessage2 = "Z"; } else { mymessage2 = "O"; } digitalWrite(13, true); // turn on LED to show transmitting vw_send((uint8_t *)mymessage2, strlen(mymessage2)); // transmit message vw_wait_tx(); // Wait until the whole message is gone digitalWrite(13, false); // turn off LED to show transmitting is done // I still need to do some more research as to how often it can check the state // of the switch . . . how often can it transmitt? baud rate limits? delay(200); }