Category Archives: Tutorials

RFID(RDM630) and Arduino

RFID is in use all around us. If you have ever chipped your pet with an ID tag or take a look to the plastic tag in your key ring you use to enter your building, you have used RIFD. “Radio-frequency identification (RFID) is the use of an object (typically referred to as an RFID tag) applied to or incorporated into a product, animal, or person for the purpose of identification and tracking using radio waves.” Read more.

You can read RFID tags Using a RFID reader and an Arduino board. Below you can find the schematic for Connecting a RDM630serial RFID reader to an Arduino board.

RDM630 and Arduino

Pinout for RDM630

Here is the sample code that reads RFID tags from RDM630 serial RFID reader and prints them on the serial  port. You can see the results by clicking “Serial Monitor” in Arduino program. The LED blinks when the reader reads a tag.

12V Lamp on Arduino with a reed relay

Intro

Arduino has a limited current sinking/sourcing capability (less than 40 mili Amps) on its pins. Whenever you intend to switch a device which needs high current or high voltage (like a lamp or a motor) an intermediate circuit is needed. In the simplest case this intermediate circuit is a relay.

Relays

Relay acts as a normal switch, but is triggered with a magnet rather than a handle. Here we use a special kind of relay called reed relay. Such relays come in vacuum enclosures and have excellent performance in terms of being an ideal switch. Whenever driving coils there should be a diode connected across the coil in reverse bias, so it will damp the back EMF produced. However, the relay we are using has this diode across its coils internally, so we don’t need to worry about it.

Circuit

Make the circuit below:

Select the Blink sketch (File>Examples>Digital>Blink) from your Arduino software and upload it to your board. The Lamp on the bread and the LED on your Arduino board should light up at the same time.

More info

Note that similar to any other load, relays draw current. This current can be more than what an Arduino can provide. In such cases you cannot connect the relay directly to an Arduino output. Use a transistor for the relay and a diode to protect against back EMF. Here is an example how to drive such a relay with a transistor.

An easier approach for driving high current/voltage relays is to use a relay driver such as ULN2003 or ULN2803. Here is a sample schematic how to do so (taken from this rocket project).

Arduino and Processing, Potentiometer

This is an updated version of the Potentiometer post from here.

To build the electronic circuit you need the following parts:

  • a 10kΩ potentiometer(You can use any potentiometer < 100kΩ ),
  • a 1kΩ resistor,
  • and a couple of wires.

A potentiometer is a variable resistor. Between the two outer pins you will always measure the (maximum) value of the resistor, while the variable resistance is measure between the middle and an outer pin. That’s where we connect a wire to measure the voltage. The pull-down resistor avoids a short circuit when the variable resistance is set to zero. The circuit on your breadboard should look something like this:

Working circuit on breadboard

If everything is set up right, you can connect the board to USB port of your computer. The power LED should light up the next step is to export the program, which reads the state of the switch to the board. Open the ap_ReadAnalog.pde file in Arduino set the right serial port (from the menu Tools->Serial Port), compile the program, and then click on the Upload icon () to send the program to the board.To check if everything works fine so far, turn the potentiometer to both extremes: the LED should light up/turn off when the potentiometer reaches (approximately) its middle position. If that works fine, you can then download and unzip pa_Potentiometer.zip and open the file pa_Potentiometer.pde in Processing. Then you will have to set the right serial port as described before.

Now, you can run your Processing program. A new window will open and you should see something like this:

Output of the program

As you turn the potentiometer the vertical bar should move as it indicates the value read from the serial port.

Arduino and Processing,Piezo Element

This is an updated version of the Piezo Element post from here.

To build the electronic circuit you need the following parts:

  • a piezo element,
  • a 1MΩ resistor,
  • and a couple of wires.

The schematic for the circuit looks like this:

Working circuit on breadboard

If everything is set up right, you can connect the board to the USB port of your computer.  The power LED should light up and the next step is to export the programm which reads the state of the switch to the board. Open the ap_ReadPiezoKnock.pde file in Arduino, set the right serial port and baudrate, compile the programm, and then press the reset button on your board and click on the export icon to send the program to the board.

To check if everything works fine so far, see if the control LED lights up when the switch is on ON-position. Now, you can download and unzip pa_PiezoKnock.zip and open the file pa_PiezoKnock.pde in Processing. Then you will have to set the right serial port as described before.

Now, you can run your Processing programm. A new window will open and you should see something like this:

Output of the program

Arduino and Processing, LDR

This is an updated version of the LDR post from here.

To build the electronic circuit you need the following parts:

  • a LDR light sensor,
  • a 1kΩ resistor,
  • and a couple of wires.

A LDR light sensor is a variable resistor. Notice, that in this case we use a pull-up resistor (which means that it is located before the sensor). Still, we measure the voltage ‘between’ this resistor and the light sensor. The circuit on your breadboard should look something like this:

Working circuit on breadboard

If everything is set up right, you can connect the board to USB port of your computer. The power LED should light up the next step is to export the program, which reads the state of the switch to the board. Open the ap_ReadAnalog.pde file in Arduino set the right serial port (from the menu Tools->Serial Port) and baudrate (in the code), compile the program, and then click on the Upload icon () to send the program to the board.To check if everything works fine so far, see if the control LED goes off when you cover the sensor with you hand. If it’s turned off you might have to expose it to more light to pass the threshold value and cause the LED to light up. Now, you can download and unzip pa_LDR.zip and open the file pa_LDR.pde in Processing.Then you will have to set the right serial port as described before.

Run your Processing program. A new window will open and you should see something like this:

Program Output

The maximum size of the pulsating circle depends from the quantity of light that hits the sensor. More light will increase the size of the circle, less light will make it smaller.

Arduino and Processing, Switch

This is an updated version of the Switch post from here.

To build the electronic circuit you need the following parts:

  • a switch,
  • a 1kΩ resistor,
  • and a couple of wires.

The schematic for the circuit looks like this:

Switches have three pins. In one position the switch closes the connection between the middle pin an outer pin while the opposite position establishes a connection between the middle pin and the other outer pin. Therefore, we connect 5V to one of the outer pins and the 1kΩ resistor to the middle pin and ground. We will measure ‘between’ the middle pin and the resistor and therefore have a wire leading from there to pin 7 of the Arduino board. The circuit on your breadboard should look something like this:

Working circuit on breadboard

If everything is set up right, you can connect the board to the USB  port of your computer. The power LED should light up and the next step is to export the program which reads the state of the switch to the board. Open the ap_ReadDigital.pde file in Arduino set the right serial port (from the menu Tools->Serial Port), compile the program, and then click on the Upload icon () to send the program to the board. To check if everything works fine so far, see if the control LED lights up when the switch is in ON-position. If that’s the case, you can then download and unzip pa_Switch.zip and open the file pa_Switch.pde in Processing.

List of serial ports in MS Windows and Mac OS X

Now, you can run your Processing program. A new window will open and you should see something like this:

Output of the program

From the middle a red (or blue) bar will start growing to the right (or left), depending on the position of the switch. If you change the position of the switch, the other bar will start growing and when both bars are of equal size they will both turn green. Play around a little bit and you will see that rhythmic switching will maintain the bar green, isn’t that great?