You are currently viewing ARDUINO BASED WIRELESS LED ACTIVATION
ARDUINO BASED WIRELESS LED ACTIVATION

ARDUINO BASED WIRELESS LED ACTIVATION

ARDUINO BASED WIRELESS LED ACTIVATION

In this mini-project, you’ll create two identical assemblies, each consisting of an Arduino and XBee, along with a button and a LED. When you press the button on one assembly, the LED on the other one lights up, and vice versa.

Figure 1: Control LEDs with XBee-equipped Arduinos.

Parts Required:

You’ll be making two assemblies, so you need two of everything!

  1. Arduinos (x2)
  2. XBees (x2)
  3. Breakout boards (x2)
  4. Pushbuttons (x2)
  5. Breadboards (x2)
  6. LEDs (x2)
  7. Jumpers

Project Description:

Follow these steps to assemble the XBee test platform: 

1. Solder the breakout boards:

Solder up your XBee breakout boards if you haven’t already. Depending on your kit, this could mean simply soldering in some header pins. 

On other kits, however, you must solder in LEDs, capacitors, and so on. 

2. Connect the XBees to the breakout boards:

Attach the XBees to their respective breakout boards. This typically involves simply plugging in the XBees’ pins to the appropriate holes in the breakout board. Just follow the directions that accompany your kit. 

3. Attach to breadboards:

Plug the breakout boards and XBees into the breadboards. You can see where to place it in Figure 2.

PIN IT
Figure 2: This diagram shows you how to create these XBee test modules.

4. Attach the pushbuttons, LEDs, and jumpers:

Attach these items as follows (also shown in Figure 2): 

A. GND on the XBee goes to GND on the breadboard. Connect the GND bus of the breadboard to the GND port of the Arduino. 

B. +5V on the XBee goes to 5V on the Arduino. 

C. TX on the XBee goes to RX on the Arduino. 

D. RX on the XBee goes to TX on the Arduino. 

E. Connect a button to pin 8 on the Arduino; the other end connects to the GND bus. 

You should end up with two identical units, and if you upload the Arduino code to both of them, they should work identically. Even cooler, the way the networks are set up, you could actually create three or more of these assemblies and they’ll all work the way you would expect. Press the button on one, and the LEDs on all the others will light up! It’s not super practical, to be sure, but it shows how easily you can set up an XBee network.

Wireless LED Code:

Upload the following code to both Arduinos. Remember, both modules are identical, down to the software. 

#include <Wire.h> 

const int buttonPin = 8; 

const int ledPin = 13; 

int buttonState = 0; 

void setup() 

Serial.begin(9600); 

pinMode(ledPin, OUTPUT); 

pinMode(buttonPin, INPUT_PULLUP); 

void process_incoming_command(char cmd) 

int speed = 0; 

switch (cmd) 

case ‘1’: 

case 1: 

digitalWrite(ledPin, LOW); 

break; 

case ‘0’: 

case 0: 

digitalWrite(ledPin, HIGH); 

break; 

void loop() { 

if (Serial.available() >= 2) 

char start = Serial.read(); 

if (start != ‘*’) 

return; 

char cmd = Serial.read(); 

process_incoming_command(cmd); 

buttonState = digitalRead(buttonPin); 

if (buttonState == HIGH) { 

Serial.write(‘*’); 

Serial.write(1); 

else { 

Serial.write(‘*’); 

Serial.write(0); 

delay(50); //limit how fast we update 

}

Download Project Code Click Here

Also read,

Aanchal Gupta

Welcome to my website! I'm Aanchal Gupta, an expert in Electrical Technology, and I'm excited to share my knowledge and insights with you. With a strong educational background and practical experience, I aim to provide valuable information and solutions related to the field of electrical engineering. I hold a Bachelor of Engineering (BE) degree in Electrical Engineering, which has equipped me with a solid foundation in the principles and applications of electrical technology. Throughout my academic journey, I focused on developing a deep understanding of various electrical systems, circuits, and power distribution networks.

Leave a Reply