KrisBarrett.com » Posts in 'Electronics' category

Audio Output Selector

Using my headphones with my computer is frustrating.  Whenever I want to use my headphones, I have to move my computer so I can access the back panel, unplug my computer speakers, and plug-in my headphones.  Okay, maybe it isn’t that difficult, but is should be easier.  How about a device that allows you to select between headphones or computer speakers? Read more »

First AVR Project

This brief tutorial demonstrates how to create projects for the AVR using AVR-GCC.  This tutorial assumes that you are using Ubuntu for your development environment.  This tutorial also assumes that you have already installed AVRDUDE.  Also, you should have a development board with at least one button and one LED.  In my case, the button is active low.

1. Install AVR-GCC:

$ sudo apt-get install gcc-avr
$ sudo apt-get install avr-libc

2. Create a new directory for your project, let’s call it blink:

$ mkdir blink
$ cd blink

3. Download the template makefile:

$ wget http://electrons.psychogenic.com/articles/Makefile.tpl
$ mv Makefile.tpl Makefile

4. Copy the template makefile to your Templates folder if desired:

$ cp Makefile ~/Templates/avr-makefile

5. Modify the configuration section of the makefile.  This is fairly easy thanks to the helpful comments included in the makefile.  I used the following configuration:

MCU=atmega128
PROGRAMMER_MCU=m128
PROJECTNAME=blink
PRJSRC=blink.c
INC=
LIBS=
OPTLEVEL=0
AVRDUDE_PROGRAMMERID=dragon_jtag
AVRDUDE_PORT=usb

6. Get blink.c:

$ wget http://www.krisbarrett.com/wp-content/uploads/2009/09/blink.c

7. Modify the #defines so that they correspond to the connections on your development board.  On my development board, the BTN is connected to PA2 and the LED is connected to PA6.

#define LED (1 << PA6)
#define BTN (1 << PA2)

8. Build the project:

$ make

9. Program the AVR using the writeflash target included in the makefile:

$ sudo make writeflash

Ensure that the program works as expected.  The LED should turn on when the button is pressed.  The LED should turn off when it is released.  Recall that this assumes your button is active low.  Congratulations, you have just created your first AVR project!

AVR Dragon Quick Start

This brief tutorial demonstrates how to read, write, and erase an AVR chip using AVR Dragon.  This tutorial assumes that you are using Ubuntu for your development environment.  This tutorial also assumes that you have an AVR development board running a demo program.  The JTAG port is used in this tutorial, but the ISP port can also be used.  Simply replace “dragon_jtag” with “dragon_isp”.

1. Install AVRDUDE:

$ sudo apt-get install avrdude

2. Read demo program from development board:

$ sudo avrdude -p m128 -c dragon_jtag -P usb -U flash:r:flash.hex:i

3. Erase development board:

$ sudo avrdude -p m128 -c dragon_jtag -P usb -e

4. Reprogram the development board:

$ sudo avrdude -p m128 -c dragon_jtag -P usb -U flash:w:flash.hex:i

Make a Custom Arduino Shield

Arduino Shield

After many months of working on my Arduino based project, I decided to finalize my project by making my own custom PCB.  At first I wanted to design a PCB that connected to the Arduino through a series of cables.  After some thought however, I realized that a shield would be better because it would eliminate the need for cables.  This tutorial assumes an understanding of Cadsoft Eagle.  For more information about Eagle, see the Eagle Tutorials section below.  Here are the steps to make your own Arduino shield: Read more »

Fast Fourier Transform

This is a project that I threw together one weekend.  The FFT is calculated using Processing. The FFT is then sent to the Freeduino via the serial port. The Freeduino displays the FFT on the dot matrix display using shift registers and a Darlington transistor array.

Improved Light Bar Controller

Improved Light Bar Controller

I made several improvements to my light bar controller.  I added a push button that pauses the controller on a desired color. I added a red LED to indicate if the controller is paused.  I also modified the light bar so that it easily plugs into the breadboard.  I did this by replacing the polarized right angle connectors with non polarized headers (one straight and one right angle).  The improved controller also uses the Bare Bones Board from the Modern Device Company instead of the Diecimila.  Below is an updated schematic of the controller. Read more »

Freedunio Bare-Bones Board

Freeduino

I just assembled the Bare-Bones Board (BBB) from the Modern Device Company. The BBB is a “low-cost, breadboard-friendly Arduino-compatible” board. The BBB is cheaper than the popular Diecimila. This is because it doesn’t have the USB to UART chip from FTDI. Instead, the board connects to a cable that contains the FTDI chip. This means that if you plan on buying multiple boards, then you only pay for the FTDI chip once. The board is also cheaper because you can buy it as a kit and build it yourself. The startup kit which includes the cable costs $33, $2 cheaper than the Diecimila. Additional kits, not including the cable, cost only $15. Read more »

Tri-Color LED Light Bar

 

I recently connected an Arduino to a Tri-Color LED Light Bar that I bought from SparkFun Electronics. I used pulse width modulation to control the brightness of each color. The individual colors combine to make the desired color. Download the code here and see the schematic below. Read more »

Project Idea: LED Coffee Table

Coffee Table

I have wanted to build a project with LEDs for a long time. This weekend I came up with an idea, an LED coffee table.

The table would have a large compartment in the center to house the electronics and either a clear or translucent top to allow the light to shine through. Ideally I would use a combination of red, green, and blue LEDs connected to a microcontroller. This would enable the table to fade in and out of different colors. However, the design could be greatly simplified by choosing a single color LED and hard-wiring it to a power source, excluding the microcontroller altogether.