Archive

Posts Tagged ‘remote control’

AVR based Etch A Sketch with Nokia 3310 LCD

January 25th, 2009

Summary

This project allows one to use a universal IR remote to control an AVR based Etch A Sketch.  For display, we use the Nokia 3310 LCD ($10 from SparkFun.com).  The Etch A Sketch functionality is simply the ability to draw in a straight line up, down, left, right.  The purpose of this project was to demonstrate the improvements to CC Dharmani’s NOkia 3310 library that allows per pixel access using a pixel buffer.  The improved version has been included in the source of this project *.  As originally written, the library worked great displaying fonts of two different sizes, clearing the screen, and drawing a boarder around the edges.  Because of the way one must talk to the screen, it did not allow raw pixel access or random drawing.  Doing so requires a local cache (buffer) of the pixels.  This way, if you want to set a single pixel, you have the old value that you set to modify and write it back.  The improvements shown here do just that.  Additionally, we also have included a small tool to allow a .pgm file to be converted to a header for a splash screen.  The additional routine to display the image is also included.

* Hopefully CC Dharmani and I will get together and put this library in a source repository to store continual improvements.

Details

For input, we use a 38kHz IR demodulating receiver.  These can be picked up for $4 at RadioShack or $0.75 on Digikey (parts list below).  Sparkfun.com also has a fancy one for $9.95.  For display, we use our handy dandy Nokia 3310 replacement LCD.  We talk to it using SPI.  The arrow keys on the remote move the cursor and draw a line as it goes.  The MENU or MUTE buttons swipe the screen.

Schematics

Schematic - atmega8 with 3310 LCD and IR sensor

Schematic - atmega8 with 3310 LCD and IR sensor

Nokia 3310 LCD Pinout

Nokia 3310 LCD Pinout

Source Code

3310_routines.c 3310_routines.h CC Darminitech’s Nokia 3310 LCD Library modified to support a local pixel buffer cache for individual pixel access.
avr-spiceduino-3310-drawing.tar.gz Entire source code and firmware and pgmtoheader program -
pgmtoheader.c Quickly hacked program to read in a 84×56 8-bits per pixel .pgm file and spit out a splash.h file for inclusion to an AVR project to display images.

Steps for making splash screens (included as header files) with pgmtoheader.c:

  • open a file that you want to display on your Nokia 3310 (black and white graphics are best) in GIMP or Photoshop
  • resize to a height of 56
  • use the thresholding tool to find a good value to use as the point between black and white.  You probably will have to slide it back and forth until you get a good image.
  • stretch/resize to 84×56
  • save as .pgm (raw not ascii)
  • open a hexeditor (I use khexedit) and hack off the header portion (or modify the code to skip over it)
  • compile pgmtoheader with ‘gcc -o pgmtoheader pgmtoheader.c’
  • run the pgmtoheader program on it with ‘./pgmtoheader /path/to/file.pgm > splash.h’
  • you can now #include “splash.h” in the 3310_routines.c and call LCD_drawSplash() to display it.

AVR Projects , , , , ,

Use an SD or MMC card on your next AVR project

January 16th, 2009

SD / MMC cards support a SPI mode.  By connecting it to an AVR’s SPI port, it can be used for general storage relatively easy.  Here I demo the use of an SD / MMC card as general storage for electronics projects. I am using it with a 1MHz Atmel AVR atmega8, standard 2GB microSD card with adapter sleeve, and using a PWM port as a cheap DAC for sound output.  I first loaded the SD card with pre-recorded sounds at 8KHz and 8-bit unsigned linear.  I then read them in real time from the SD card and write the values to the OCR so that they set the duty cycle on a PWM port.  I use a simple RC low pass filter as a cheap DAC (Digital to Analog Convertor) that is output to a speaker.

Schematics

Coming soon.

SD MMC Card Pinout

SD MMC Card Pinout

pin number name avr pin
1 CS SS
2 DATAIN MOSI
3 VSS1 GND
4 VDD 3.3v VCC
5 CLK SCK
6 VSS2 not connected
7 DATAOUT MISO
8 DAT1 not connected
9 DAT2 not connected

Source Code

I first found GPL example code at http://www.avrrepository.com/samplecode/sd_breakout/doc/main.html. It does not support writing though :-( .  Because it is GPL, I modified it so that it supported writing as well.  Here are the files modified to support writing (I haven’t had time to clean them up).

mmc_if.c

mmc_if.h

Demo Video

AVR Projects , , , , , ,