Category Archives: Arduino

Bi-Color LEDs with Arduino

A few years ago I bought some bi-color or dual-color LEDs. These are LEDs that have only 2 leads like regular LEDs, but can display 2 colors.

An LED is a type of diode, so it only allows electricity to flow one way through it. But when that electricity is flowing, it lights up.

The bi-color LEDs are essentially 2 of these in one package in opposite directions.

With an Arduino, you normally connect one end to ground and the other end to a digital pin and just write a HIGH to that pin to light the LED.

I wasn’t sure at first how to use the bi-color LEDs with the Arduino, but it turns out it is simple. All you have to do is connect each end to a digital pin and write LOW to one and HIGH to the other. Reverse them and it lights in the other color.

This works because writing LOW sets the pin to 0V just like writing HIGH sets it to 5V. This means that one at LOW and one at HIGH creates a voltage drop across the LED, lighting it up.

Turns out it is nice and easy.

Arudino and 1-wire

For my birthday this year, my wife got me the Arduino Start Kit from Adafruit Industries.

If you aren’t familiar with Arduino, it is a great open source platform for doing small electronics projects. The start kit I got has a Arudino Duemilanove, which is the latest basic version of the platform. The Duemilanove has a small processor on it that can be easily programmed over USB, and a lot of input and output pins to play with.

After getting the kit set up and my prototyping board soldered together, I decided that my first project would get seeing if I could get some old 1-wire temperature sensors working. A few years ago, I got a sample of 5 of these sensors but was never able to get them working with my homemade serial adapters. The sensors I got are the DS1820 from Dallas Semiconductor. These are old and have now been replaced by the DS18S20, but they work the same.

Turns out that the Arduino community had already done all the hard work at getting these working, so it only took me a few minutes to get it set up.

Hardware: Each of these sensors has 3 legs: power, ground, and data. If you are only using a few sensors that are close to the power supply, you can instead use parasitic power as I did. This reduces the number of wires to the sensor needed to 2, data and ground. To do this, I shorted the power and ground pins and wired them to ground. I then attached the center data pin to one of the digital IO pins of the Arduino.


Here you can see the Arduino with the sensor connected on the prototype shield from the starter kit.


This is a close up of the connections. The brown wire connects the power and ground pins. The black wire connects these to ground. The yellow wire is connected to digital I/O pin 2 on the Arduino.

Software: The Dallas Temperature Control Library is a library that allows simple control of the 1-wire temperature sensors. All you have to do is download it, put it in your Arduino libraries folder, and open the Simple example.

The example sets up the library and reads the current temperature from the first sensor, printing it out to the serial monitor.

After years of having these sensors sitting around in a drawer, it only took me a few minutes to get them working. Now I just need a larger project to use these in.