It all started at 8 a.m. when I had a call from a friend to build a simple handy wireless device. The idea was simple. Two devices talking by wireless range of 60 meter at least sending two different signals: right or left. The receiver device had 2 LEDs (each delegating right or left) that light up when the other one presses one of the push buttons.

I searched the web for 433Mhz antenna and found out I could use a simple 17.5cm wire. I installed and wired up my Arduino UNO for testing and connected 2 RFs to seprated UNOs to test it in action.
So this is what I wrote, compiled and uploaded using Arduino IDE for receiver device:

/*
Rx MODULE CONNECTIONS:
PIN DESCRIPTION ARDUINO PIN
1 GND GND
2 RX DATA D2
3 RX DATA N/A
4 VCC (5V) VCC
*/
/*Include the VirtualWire library */
/* Digital IO pin that will be used for receiving data from the receiver */
const int RX_DIO_Pin = 2;
const int RIGHT_Pin = 5;
const int LEFT_Pin = 6;
void setup()
{
pinMode(13, OUTPUT);
Serial.begin(9600);
pinMode(RIGHT_Pin, OUTPUT);
pinMode(LEFT_Pin, OUTPUT);
/* Initialises the DIO pin used to receive data from the Rx module */
vw_set_rx_pin(RX_DIO_Pin);
/* Receive at 2000 bits per second */
vw_setup(2000);
/* Enable the receiver */
vw_rx_start();
}
/* Main program */
void loop()
{
/* Set the receive buffer size to 2 bytes */
uint8_t Buffer_Size = 2;
/* Holds the recived data */
unsigned int Data;
/* The receive buffer */
uint8_t RxBuffer[Buffer_Size];
/* Has a message been received? */
if (vw_get_message(RxBuffer, &Buffer_Size)) // Non-blocking
{
/* If so, then turn on the LED connected to DIO 13
to indicate this */
digitalWrite(13, HIGH);
/* Store the received high and low byte data */
Data = RxBuffer[0] << 8 | RxBuffer[1];
/* Output this data to the UART */
Serial.print("Analogue pin A0: ");
Serial.println(Data);
if(Data == 0){
digitalWrite(RIGHT_Pin, HIGH);
} else if (Data == 1) {
digitalWrite(LEFT_Pin, HIGH);
}
/* Turn off the LED on pin 13 to indicate that the
data has now been received */
delay(500);
digitalWrite(13, LOW);
digitalWrite(RIGHT_Pin, LOW);
digitalWrite(LEFT_Pin, LOW);
}
}
And the sender device using 2 push buttons connected to resistors just like Arduino doc suggests:

/*
Tx MODULE CONNECTIONS:
PIN DESCRIPTION ARDUINO PIN
1 GND GND
2 VCC (3.5-12V) VCC
3 TX DATA D3
*/
int right;
int left;
/*Include the VirtualWire library */
/* Digital IO pin that will be used for sending data to the transmitter */
const int TX_DIO_Pin = 3;
const int RIGHT_PIN = 8;
const int LEFT_PIN = 9;
void setup()
{
pinMode(RIGHT_PIN, INPUT);
pinMode(LEFT_PIN, INPUT);
Serial.begin(9600);
Serial.println("Device is ready");
pinMode(13, OUTPUT);
/* Initialises the DIO pin used to send data to the Tx module */
vw_set_tx_pin(TX_DIO_Pin);
/* Set the transmit logic level (LOW = transmit for this
version of module)*/
vw_set_ptt_inverted(true);
/* Transmit at 2000 bits per second */
vw_setup(2000); // Bits per sec
}
void loop()
{
right = digitalRead(RIGHT_PIN); //read state of the PIR
left = digitalRead(LEFT_PIN); //read state of the PIR
if (right == HIGH || left == HIGH) {
/* Temporarily holds the value read from analogue input A0 */
unsigned int Data;
if (right == HIGH) {
Data = 0;
Serial.println("Pushed right");
}
if(left == HIGH) {
Serial.println("Pushed left");
Data = 1;
}
/* The transmit buffer that will hold the data to be
transmitted. */
byte TxBuffer[2];
/* ...and store it as high and low bytes in the transmit
buffer */
TxBuffer[0] = Data >> 8;
TxBuffer[1] = Data;
/* Turn on the LED on pin 13 to indicate that we are about
to transmit data */
digitalWrite(13, HIGH);
/* Send the data (2 bytes) */
vw_send((byte *)TxBuffer, 2);
/* Wait until the data has been sent */
vw_wait_tx();
/* Turn off the LED on pin 13 to indicate that we have
now sent the data */
digitalWrite(13, LOW);
/* Do nothing for a second. Lower this delay to send
data quicker */
delay(1000);
}
}
As I was finishing the sample product for my friend he actually came to visit me and he was surprised that it was done already! He's a developer just like me and asked me how could he do stuff like this. I was proud to introduce him Arduino platform and telling him how he could actually write javascript for code and use all the I/O modules to communicate. He soon bought one and now created a watering plant device connected to and iOS app using wifi/GSM.
We both don't intent to build these IoT gadgets for profit but for fun, making us feel like we're making Terminator robots. But what really makes us keep building these cool ugly devices is how much we learned during the process about electronic and stuff. I mean I had no idea what relays are till trying to turn on a 220V lamp with a 5V arduino using my laptop.

Learning is fun so the electronics.