loading

While watching any of those Harry Potter sequels, did you ever wanted to own that magical misty wand? I don't know about you but I was seriously crazy about them. Many a time I asked my father to get one for me but he always refused and said that all those things are fake and there are no such things like a magical wand. As a child, I used to believe him. I had no other option. Few days before, while watching one of those Harry potter sequels, I thought why not to make a magic wand now and fulfill my childhood dream. I searched on the internet about this and went through various articles to find how to put electronic magic into the wand and came with this idea. The Magical Wand!

So by this magical wand you can control your home appliances. You can turn them on/off by making some simple patterns from push button present on the wand. When you will do that, the other person will think that you are turning on and off the lights by magic and thus you will become star of that night. You would be thinking how this pattern thing works? When make a certain pattern with the push button, the microcontroller inside the wand encodes that pattern and wait for you to press the buttons once more. As you press the button second time the, the wand sends the value assigned to that pattern to the receiver unit through an IR led. The receiver unit receives those IR signals and encode them to get a certain value and perform the task assigned to that value, in our case turn on an appliance (lets say a bulb). When the wand sends the IR signal, it also flashes a blue led for a fraction of a second so as to give the bond some more magical effect. But you have to make sure that your receiver unit is well connected to your switch board system and the receiver unit is not hidden deep inside otherwise your appliance will not turn on. You can customise this project according to your use by changing the code a bit. To know more on how the wand works, go to step 10. This wand is perfect for you if you want to have some fun with your friends and family members.

Coming on the circuitry,the brain of the receiver unit is Arduino nano. Reason to use this microcontroller was that it was small, compact and powerful. Being small it could be hid easily and being powerful it can perform lot of command very swiftly. With Arduino nano, a DIY relay shield consisting of three relays and a IR receiver(TSOP1736) is present inside the box. Coming on the wand, it contains an ATMEGA 328 IC which runs on a clock-speed of 8 MHz. The reason to use a 8 MHz clock speed was that I powered this IC with a voltage of 3.7V and using a 16 MHz clock-speed with 3.7V could damage the IC. Reason to use a 3.7V power supply could be found in step 8. Inside that wand, an IR led, a normal blue led, a 3.7V 18650 Li-ion cell and two tactile switches are also present.

If you have any question, you can move to FAQ section to sort them out or simply comment down below and wait for my reply.

I am entering in the wizarding contest. PLEASE vote for me if in the contest and also don't forget to follow me on instructables and subscribe to my YouTube channel. Here is the link:https://www.youtube.com/channel/UCHnIUs2HC0e6SQHtR...

Let us begin.........

Step 1: Some FAQ

A lot of you must be having some question related to the project so I decided to add this Frequently Asked Questions step so that you can get the answer of your question here only and you need not to search them on internet. If you have some more suggestion for this step, mail it to me our comment down below and I will add it in this step.

Q1: Why are we using ATMEGA 328 IC in the wand instead of any other microcontroller?

Ans: Firstly I decided to use an Arduino pro mini for the wand but I had to drop this idea because the pro mini was very wide. It was around 2cm wide and a wand with a diameter of 2cm would definitely not look good. Whereas the ATMEGA IC was very thin and can be easily accommodated inside the wand so I decided to go with ATMEGA IC instead of other Arduino microcontroller.

Q2: Why to use 3.7V Li-ion supply instead of 5V supply?

Ans: I wanted to make this wand as thin as possible. Using other batteries like 9V battery and lead acid battery would increase the diameter of the wand and also distort its shape. And also with those batteries, you need to add a 5V voltage regulator which would also decrease the space for other components. So I decided to go with 18650 Li-ion cells. They were perfect for this project and due to their cylindrical shape, the could be easily accommodated inside the wand. I used them as the handle of the bond too. But there was a problem in using them that the ATMEGA 328 IC could be damaged easily when supplied a voltage of 3.7V instead 5V. If you want you can add a 5V step up module to increase the voltage of cell from 3.7V to 5V but I sorted out this problem by decreasing the clock-speed of the IC.

Q3: Why to use a 8 MHz clock-speed instead of 16 MHz clock-speed?

Ans: Since I wanted to use a 3.7V supply instead of a 5V supply, it was necessary to use a 8MHz crystal instead of 16MHz crystal. When using 16MHz crystal on 3.7V, you are overclocking your IC which could possibly damage it. I searched on the internet and found that 8MHz clock-speed works perfect with 3.7V and would not make a problem afterwards.

Q4: Why to use IR modules instead of RF modules?

Ans: You can use RF module if you want but in this case using IR signals or module is better because when using RF modules, the transmitter of RF module would definitely be placed inside the wand and the walls of wand but disturb it signal and the signals reaching the receiver module would have a very low strength and sometimes your receiver may also not receiver signal due to low strength of the signals thus spoiling your mood. But that is not the case with IR modules. IR transmitter is as small as a led and can easily be fitted in front of the wand and the signal reaching to IR receiver would have much more strength than the RF signals. IR modules are also cheaper that RF modules.

Step 2: Fetch the Materials

Here are the parts you would be needing to make this project. I have tried to attach Amazon link of as many parts as possible. Here we go...

PARTS:

  • Arduino
  • 5V relay (The number of pieces depends on you)
  • IR transmitter and receiver
  • ATMEGA 328
  • 8 MHz crystal
  • 22 pf capacitors X 2
  • 10K ohms resistor X 3
  • 18650 (3.7 V) Li-ion battery
  • Push buttons X 2
  • RGB led
  • Wires
  • Enclosure
  • Perfboard
  • Male and Female headers
  • 12V Power adapter
  • Female connectors X 2
  • 28 Pin IC base

TOOLS:

  • Soldering iron
  • Hot glue gun
  • Scissors
  • Cutting knife
  • Pliers
  • Wire strippers

MISCELLANEOUS:

  • Newspapers
  • Paint
  • Stroke brushes
  • Paper tape

Step 3: Programing the Atmega 328 IC

You guys would be thinking that why this step came so early. It is rather come later, somewhere at the end of the whole project. The answer to your question is that, once we solder our Atmega on the PCB, it would be difficult for us to program it using an Arduino or through FTDI breakout. You need to solder the connections coming from your programmer and after programming, desolder them too. You would also be needing a new pair of crystal and ceramic disc capacitors so as to program it on breadboard, therefor it is better to program the IC in the starting rather than going through so many problem just to program the IC.

So start by placing the IC and programmer(In my case an arduino nano board) on the breadboard. Before programming,we need to attach a crystal and some capacitor to the IC whose connections are given below:

  • Short pin 9 and 10 through a 8 MHz crystal
  • Short pin 9 and ground through a 22 pf ceramic disc capacitor
  • Short pin 10 and ground through a 22 pf ceramic disc capacitor
  • Short pin 1 and vcc through a 10K resistor
  • Connect pin 22 and pin 8 to ground
  • Connect pin 7 and pin 20 to vcc

Before connecting your arduino board to IC, you need to upload a program to it named as Arduino ISP. Your can find this program in File>Examples>ArduinoISP. Connections of Arduino board with Atmega 328 is given above. Upload the code given below to your microcontroller. But before uploading, change the programmer in your arduino IDE in Tools>programmer>ArduinoISP. Also import the IRremote library to your IDE. Zip file of the library is attached with this strep. Then upload the sketch normally.

<p>/*Magic wand transmitter code<br> * Made by Dushyanta(Tinkerer's Lab)
 */
#include </p><p>int s1=7; //1st push button
int s2=8;//2nd push button
int led=10;//led </p><p>int i=0;    //initializing characters
int j=0;
int state1=0;
int state2=0;
IRsend irsend;</p><p>void setup()
{
  Serial.begin(9600);</p><p>  pinMode(s1,INPUT);
  pinMode(s2,INPUT);
  pinMode(led,OUTPUT);
  
}</p><p>void loop() {</p><p>  if(digitalRead(s1)==HIGH && state1==0)
  {
  while(digitalRead(s1)==HIGH)
  {
    if(i<=4)
    {
    i++;
    delay(500);
    }
    state1=1;
  }
  }</p><p>else</p><p>  if(digitalRead(s2)==HIGH && state2==0)
  {
  while(digitalRead(s2)==HIGH)
  {
    if(i<=4)
    {
    i++;
    delay(500);
    }
    state1=1;
  }
  }</p><p>  
  if((digitalRead(s1)==HIGH || digitalRead(s2)==HIGH)&& (state1==1 || state2==1))
  {
    if(state1==1)
    {
  if(i==1)
  irsend.sendNEC(0x34895725, 32);
  else
  if(i==4)
  irsend.sendNEC(0x56874159, 32);
  i==0;
  state1=0;
  }
  else
  if(state2==1)
  {
    if(j==1)
    irsend.sendNEC(0x15467823, 32);
    else
    if(j==4)
    irsend.sendNEC(0x65426945, 32);
    j=0;
    state2=0;
  }
  delay(50);
  digitalWrite(led,HIGH);
  delay(200);
  digitalWrite(led,LOW);
  } </p><p>}</p>

Step 4: Making a Shield for Arduino Nano Board and ATMEGA 328

As you guys can see I am using a Arduino nano as the controlling board for my receiver unit. Nano is not a perfboard friendly microcontroller so we need to make a shield for it so as to use it with perfboard. You can directly solder it on PCB but it will be a headache afterward when you will desolder it for some other project. And same is the case with Arduino pro-mini. If you are not good in soldering then please use Arduino UNO as it is much more easier to work on Arduino UNO than to work on Arduino nano.Use male and female headers to make the shield. Look on the images attached above and try to make a similar shield for your board also.

The second microcontroller that we'er gonna use in this project is the ATMEGA 328 IC. You would be thinking that why I did not chose a Arduino board like nano or pro-mini etc and decided to use a ATMEGA IC. The reason is that this IC would be mounted inside our wand. Generally a wand is 30cm in length but does not have a lot of thickness. The Arduino Pro-mini has a thickness of 2 cm and a wand can not be 2cm thick. This will spoil the whole look of the wand and anybody would detect that this is not a magic trick. Its a simple glitch. The ATMEGA IC being slim is perfect for our job. So start by soldering your 28 pin IC base to the perfboard. This IC base will help you to remove the IC from the PCB afterward. The crystal and the ceramic disc capacitor will be connected to the ATMEGA whose circuit diagram is attached above in the images. After making the circuit, I found that the circuit was still very thick so I chopped of the PCB that I left for the resistors and hooked up the push button resistors vertically so that they acquire less place and attached resistor of normal blue led and IR led to their respective led pins. I soldered the 10K resistor coming from pin one to vcc between the IC base so as to save spaces. Look on the images present of the further step to understand what I am trying to say.

Step 5: Making a Relay Shield

I wanted to control my home appliance with this wand therefor I used a relay shield. I you want to control things which work below 5V, you can directly connect them to your Arduino or a better option is that you can make a solid state relay or use a mosfet. Controlling a single appliance like a light bulb would not give a magical effect. To make the person believe that your wand is a magical wand, you need turn on and off multiple thing for which you would be needing multiple relays. Using a lot of relays would make your project messy so its better to use a relay shield for the project. Now you would be thinking that what is a relay shield? A relay shield is a cluster of multiple relays attached on one single board so as to make your project neat and clean and easy to work upon. You can buy a relay shield from the market if you want but its better you make a DIY shield if you have multiple relays lying around your place.

Relays used in my case are 5v relays which can handle the AC voltage of around 120V on 1A current cycle. Since my relays are 5V one, i can directly connect them to the Arduino board. But those using a 12V relay should not worry as there is a small circuit that you need to connect to each relay to make them your on 5V. the circuit diagram of the relay can be found above in the images. While testing my relays, I found that one of my relay was not working perfectly on 5V supply. Though it was rated to work on 5V current, it used to turn on 12V current so I decided to make a simple circuit specified by me above to make my relay work on 5V.

I also connected those green connectors to the relay so that I do not need to solder the wires coming from my mains to my relay. First power pin of each relay will go to gnd, and the other one will act as signal and will be connected to Arduino digital pin. But if you are using the above mentioned circuit, the base pin of the transistor will be your signal pin. Follow these steps to connect your relays to Arduino:

  • Connect signal pin of 1st relay to digital pin 5
  • Connect signal pin of 2nd relay to digital pin 6
  • Connect signal pin of 3rd relay to digital pin 7

Step 6: Connecting the IR Module

The signal from wand to the receiver unit is transmit through the IR signals. I could have used one of those 433MHz RF module but IR signals have much more positive aspects than those normal RF modules. Some of them are listed below:

  • For producing an IR signal, we need an IR led. Those IR led are just like normal leds and can be easily fitted in front of the wand and could easily interact with the receive4r unit. But in case of RF module, the transmitter module must be hidden inside the wand and the walls of the wand would act as a barrier to the RF signals and cause interruption
  • IR modules are much more cheaper than RF module
  • RF signals are interrupted by your home Wi-Fi and other wireless networks. But there is no such issue with IR signals.

Now I think that much data would be sufficient for you to understand why it is better to choose IR module over RF modules. Now coming back on the IR modules, all IR transmitter are almost same but IR encoder or receiver come is lot of different packings. The one used by me is TSOP1736. Be sure to check the package type of your IR receiver before making the connections. Pin diagram of TSOP1736 is given in the images above. This receiver is not jump cables friend so how have to make a small connector for it. You can do this by simply soldering the IR receiver on the PCB and the connect its pin with male headers. Here are the connections of this receiver:

  • vcc of the receiver-----vcc of Arduino
  • gnd of the receiver-----gnd of the Arduino
  • signal out of the receiver-----digital pin 10 of the receiver

As you guys know that I chopped of the PCB of my ATMEGA 328 shield where beforehand I decided to solder the resistors of my IR led and normal blue led, so we now have to solder it directly to the led. Its not a very messy job. What you have to do is you have to shorten the positive pin of each led and then connect the respective resistor to it. You need to solder a 100 ohms resistor to IR transmitter led and a 330 ohms resistor to the normal blue led. If you want, you can cover the resistor with heat shrink tube but be sure don't heat it to much otherwise it will be damaged.

Step 7: Programming the Arduino Nano

Now we are gonna program our arduino nano board. here is the code:

<p>#include <IRremote.h>;<irremote.h><br></irremote.h></p><p>int RECV_PIN = 11;</p><p>int relay1=5;
int relay2=6;
int relay3=7;</p><p>int led=13;</p><p>int state1=0;
int state2=0;
int state3=0;
int state4=0;</p><p>IRrecv irrecv(RECV_PIN);</p><p>decode_results results;</p><p>void setup()
{
  Serial.begin(9600);
  irrecv.enableIRIn(); // Start the receiver</p><p>  pinMode(relay1,OUTPUT);
  pinMode(relay2,OUTPUT);
  pinMode(relay3,OUTPUT);
  pinMode(led,OUTPUT);
  
}</p><p>void loop() {
  if (irrecv.decode(&results)) {
    Serial.println(results.value, HEX);</p><p>    if(results.value==0x34895725 && state1==0)
    {
    digitalWrite(relay1,HIGH);
    state1=1;
    }
    else
    if(results.value==0x34895725 && state1==1)
    {
      digitalWrite(relay1,LOW);
      state1=0;
    }</p><p>    else</p><p>    
    if(results.value==0x56874159 && state2==0)
    {
    digitalWrite(relay2,HIGH);
    state2=1;
    }
    else
    if(results.value==0x56874159 && state2==1)
    {
      digitalWrite(relay2,LOW);
      state2=0;
    }</p><p>    else</p><p>    
    if(results.value==0x15467823 && state3==0)
    {
    digitalWrite(relay3,HIGH);
    state3=1;
    }
    else
    if(results.value==0x15467823 && state3==1)
    {
      digitalWrite(relay3,LOW);
      state3=0;
    }</p><p>    else</p><p>     
    if(results.value==0x654269453 && state4==0)
    {
    digitalWrite(led,HIGH);
    state3=1;
    }
    else
    if(results.value==0x65426945 && state4==1)
    {
      digitalWrite(led,LOW);
      state4=0;
    }</p><p>    irrecv.resume(); // Receive the next value
  }
}</p>

Step 8: Preparing the Enclosure

Now its time to choose a enclosure for your project. Try not to use a big and bulky box as it would be difficult to hide that box. I decided to go with this little transparent box. This box was fit for this project and I could easily hide it somewhere. So start by placing all your components inside the box to see whether they fit inside it or not. If yes, move ahead but if they do not fit in, move to a larger box. Start by drilling a large hole for the wires coming from the switch board to the relay shield. Drill two small holes, one for the power jack and the other one for the IR receiver. Hot glue each and everything on its place and you are done. Since I used a transparent box, all the circuitry was visible so I decided to stick a sticker on the box to hide that all.

Step 9: Connecting Push Button and IR Led

Now are receiver unit is ready so its time to make our wand. The first step is to make all the connection because after ward whole circuitry will go inside the wand and then you would not be able to do connection or changed them so be sure to finish all electronics part right now. Here are the steps you need to follow:

  • Connect vcc of IR led to digital pin 3 and gnd to gnd
  • Connect vcc of led to digital pin 10 and gnd to gnd
  • Connect pin one of first push button to digital pin 7 and pin two to ground
  • Short digital pin 7 with vcc through a 10K resistor
  • Connect pin one of second push button to digital pin 8 and gnd to gnd
  • Short digital pin 8 with vcc through a 10K resistor
  • Connect positive of your 3.7V Li-ion cell to vcc of IC through a switch and negative directly to ground

Don't forget to use heat shrink tube between the Blue led and IR led. By the way for doing these connections, I used ribbon wire. I am using a 3.7V Li-ion cell because I want to make this wand compact. This cell would also act as a handle of the bond afterwards. You can use a 5V boost converter if you want but I want to save space and want to make wand as compact as possible so I am using a 3.7V cell. Make sure to cover the end points of the cell with tape when you are done with soldering. This would prevent short circuiting. I forgot to do so and had to face a lot of problem afterwards.

Step 10: Making the Wand

Here comes the craft work. Now we are gonna build our magical wand! I used newspaper to make this wand but you can also used PVC pipes for this. I started off by placing all the components on the newspaper sheet and started rolling it. After rolling I got a tube like structure with all the circuitry inside it. First used some normal cellofine tape to hold the newspaper on its place then covered the whole thing by some paper tape. After covering the wand with paper tape, it was ready to be painted. Took some brown color and started painting it. After painting with brown color, applied a thin layer of black acrylic color on top. After the paint was dried, again applied and thin layer of brown color to give the wand, a woody finish. After that my wand was ready. I placed my on/off switch on he bottom of the wand for a more superior grip.

Step 11: How to Use It

Now our project is complete and its time to test it. Start by connect your switch board system through wires to the relays of receiver unit. Then plug in the power cable to the power jack present on your receiver unit. It should turn on. Now switch on your wand and start using it. Go and search for some magical words from the harry potter movies. Just now the wand recognizes only two types of pattern. These are press and hold. You can add more by doing some changes in the code. For example if you push the first push button only once, the wand will get triggered. When you will push any of the two push button now, the wand will send signal to receiver unit and first relay will switch on and the bond will reset. When you will hold the first push button for 2 sec, and then again push any of the two push buttons, the wand will turn on the second relay. And same is the case with the second push button also but when you will hold the second push button for 2 sec and again press any of the two buttons, the led at digital pin 13 of your receiver unit's Arduino board will turn on as our system has only three relays. But if you want you can introduce a fourth relay and change this command to turn the fourth relay instead of led.

Step 12: The END

Hope you like the project. I you have any questions regarding the project comment down below or drop a private message.

Don't forget to follow me on instructables and subscribe to my YouTube channel named as Tinkerer's Lab. Here is the link:https://www.youtube.com/channel/UCHnIUs2HC0e6SQHtR...

Please vote for me in the contest.

NAMASTE!!

<p>That's amazing &amp; namastey... voted for you. dear.</p>
<p>Thanks sandeep for your support!</p>

About This Instructable

3,665views

62favorites

License:

Bio: An electronic hobbist and a tech-savvy. Love to know and publish good electronic projects. I use some popular micro controller like raspberry pi, arduino, linkit ... More »
More by Dushyanta :Homemade Fidget Spinner Bluetooth Controlled Sofa Lights Selfie flashlight 
Add instructable to: