Category Archives: Arduino

Sending IR signal with Arduino

Pre requisite I assume you have already know how to receive IR signal with arduino. If not, you may read this. You need Download Arduino-IRremote-master from git hub, move to library folder under arduino. Also make sure you are using Arduino 1.0.5, latest beta 2.x not working with this IR library. sku_266569_2 I got my IR emitter module from 37-in-1 sensor module kit at This kit includes a IR emitter and IR receiver, along with many other sensors and controller, but without the mp3 remote controller. At the time of writing, have a new product pack where it comes with a mp3 remote controller, infrared receiver module and an extra infrared emitter module (for sending). The price is only usd 5.80. Construct the circuit It is very simple, just connect your emitter module, the  – pin to GND (ground), S pin to pin 3 on arduino. Leave the center pin unconnected. The following code will send the signal in NEC hex format of value ‘0xFF18E7′, which is equal to button 2 of the mp3 controller. To test it You will need 2 arduino board to test run it. One board for the sending, another for the receiving. Like this photo shows: 20131208_170614 p/s: I added a LED on the receiving board to acknowledge my transmission successful. My sender board is an identical Arduino Uno but with an Ethernet shield on top of it. Notice how i place my emitter and receiver module facing each other openly, without blocking. How about both on the same board? I tried to put both sending and receiving module together on one Arduino board, hopping the sending signal can be received by the same board simultaneously, but failed. It seems like due to the single threaded nature of Arduino processor, we cant do these 2 things at the same time. Googling reveal similar questions without answer: Please let me know if you found ways to do this 😉

Receive IR value with Arduino

You need Download Arduino-IRremote-master from git hub, move to library folder under arduino. Also make sure you are using Arduino 1.0.5, latest beta 2.x not working with this IR library. I am using infrared receiver module manufactured by keyes, come together with an IR mp3 remote control and a nomral LED, purchase from at usd4. At the time of writing, have a new product pack where it comes with a slightly different mp3 remote controller, same infrared receiver module and an extra infrared emitter module (for sending). The price is only usd5.8. Validate IR remote control is working Human can’t see IR light with naked eye. How can we validate the remote control is actually functioning? Fortunately, you can check infra-red with a smart phone camera. Latest iphone have IR filter so it will fail, but I tested on samsung galaxy s3 and works. 20131208_001119 20131208_001241 The IR receiver According to spec, the receiver sensor adopt HX1838, high sensitivity; Working voltage: 5V; Testing distance: 5~8m; Construct the circuit The circuit is very simple. sketch.modified 20131208_133548 Once you have IRremote library installed, your will beable to get the example thru arduino ide interface. Open File->Examples->IRremote->IRRecvDemo I enhanced it by adding a function decodeSignal to transform IR value into meaningful value like button 1, 2, 3, power, mute…  

Reading multiple digital Input

Reading multiple digital input is not much different than reading single digital input. First, construct this circuit. sketch_bb Then, use this little piece of coding: Done! Note: You must resistor with push button or else it wont works. t Some Photos: WP_20131201_18_01_03_Pro

Control real devices using relay

What is a relay For beginner, Arduino is about processing input from sensor and output to LED, servo, buzzer and etc. What if you like to control the real electrical devices at your house, let say a desktop light or a Kettle? Then, you will need a relay. In short, a relay is an electrically operated switch. Most relays use an electromagnet to operate a switching mechanism mechanically. Where to get one I do most of my shopping at A decent relay cost as low as USD2.40 and it is free shipping! (The only problem is it takes quite some time to reach my doorstep). There are many type of relays available out there. You must get the right one to works. Get a 5V one due to your arduino board power output is usually 5v or 3.3v. If you got a 9v relay like this one, then you will need to connect the power source from an external 9v battery. 5V relay 20131124_180951 Notice the word down there: SRD-05VDC-SL-C. This is a 5v DC relay which you can connect to your arduino board directly for power source to control. 12v Relay 20131124_181020 20131124_181006 These are the 12V relay which required external power source to control. How to connect Normally, a relay has 6 pins, 3 on the A side (IN, VCC, GND) , 3 on the B side  (NO, COM, NC) , as shown in the picture below. A side connect to your arduino board, while the B side connect to the ‘real devices’. sku_149805_2 For testing, we always start connecting the A side. VCC to your 5V power output pin, GND to GND pin, while IN to your Digital Output pin. Like this circuit: relay start circuit Then, load the following code to test: You have done it correctly when you hear the clicking sounds. For those relay module that come with built in LED, it’s easier to tell it works or not. Connecting the ‘real device’ You have to be very careful when connecting a relay as you are dealing with real AC power source most of the time. You could burnt your arduino board or worst yourself if connected wrongly. For the learning and safety, I will use an external 6v battery source to represent the power supply and LED for the lights/electrical device. The diagram below shows how you connect the B side: dancinglights_step1b The full circuit would be: relay overview Note: connect a resistor to your LED as 6V battery could be too large for it to handle. Your LED on/off is now control by your relay. Chinese References Most products sellings on sourced from china and so their components have chinese writing character. It’s not too hard to read them. The following table helps:
  • NO – 常开 – where you connect with + of light bulb
  • COM – 公共端 – where you plugged + power source in
  • NC – 常关 – seldom use
Have Fun! Some Photos  20131124_180335 20131124_180642 20131124_180731 20131124_180729