Instructables

Self-contained 16-Digit display - Arduino & Attiny85

Featured
Picture of Self-contained 16-Digit display - Arduino & Attiny85
Ever wanted a 7-segment display for around the house? Here's your chance to make one!
It can even be interactive based on the programming.

Parts:
($7.60) 16 Digit TM1640 based display
Dealextreme.com SKU: 104311
http://www.dealextreme.com/p/jy-mcu-16x-digital-tube-yellow-led-module-104311

($2.50) Atmel ATtiny85
Digikey PN: ATTINY85-20PU-ND

($1.73) Extra long female header pins
Digikey PN: SAM1209-12-ND
  -  I got longer sections, as I plan to use these for other projects. ($8.75) Digikey PN: SAM1198-50-ND for 40-Pin headers.

($0.13) 8-pin IC socket
Digikey PN: A100204-ND
NOTE: I suggest you experiment with a different 8-pin socket. This one requires quite a bit of force to insert and remove your chip. It's easy to bend the ATtiny's pins when doing this.
Although you should have no reason to remove the ATtiny85 after you've got the final breadboard. The chip can be used and programmed in-circuit.

($1.50) Perfboard / Veroboard / valley of holes. Individual solder pads.
Sparkfun PN: PRT-08808
  -  I opted for a bigger ($12) piece from Digikey, as I wanted it for other projects. (Digikey PN: V2012-ND)

Total: $13.46 - You'll have some extra long header pins for use with other projects. These header pins are perfect for Arduino shields.

You will also need:
-Soldering iron
-Solder
-ATmega328 based Arduino. I used an Official Arduino UNO R3.
(You can alternatively use another ISP for the ATtiny85)
-5v Switching power supply if you want to use the display as a standalone device.
-Breadboard (optional) - You can program the ATtiny in the completed circuit/holder with wires directly to the arduino.

Step 1: A note on soldering.

Picture of A note on soldering.
Before we start, I want to say that this is my first EVER attempt to solder on a piece of perfboard/veroboard.
I've soldered wires together a handful of times before though.

Although the connections seem small, just take your time and try to steady your hand! You'll be fine.
If I can do it, so can you!

Step 2: Step 1: Arduino software, libraries.

Picture of Step 1: Arduino software, libraries.
1. Download Arduino v1.0
2. Download Arduino v0023
You can get both of these from Arduino.cc

3. Extract both to separate folders on your desktop.

4. Download and install the TM1638/TM1640 library from here:
http://code.google.com/p/tm1638-library/

5. Place it with your other arduino libraries **ON ARDUINO v1.0**
Google if you do not know how to install a Arduino library.

6. Install ATtiny45 / ATtiny85 support in **Arduino v0023**

   - Download: attiny45_85.zip
    http://hlt.media.mit.edu/wp-content/uploads/2011/06/attiny45_85.zip

   - Locate your Arduino sketchbook folder (you can find its location in the preferences dialog in the Arduino software)
   - Create a new sub-folder called “hardware” in the sketchbook folder.
   - Copy the attiny45_85 folder from the attiny45_85.zip to the hardware folder.
   - Restart the Arduino development environment.

Step 3: Program Arduino-as-ISP to your Arduino

Picture of Program Arduino-as-ISP to your Arduino
1. Start up your copy of Arduino v0023
2. Under the Examples menu item, choose ArduinoISP option
3. Program the arduino with this sketch

Note: I had to perform this step in Windows XP. Something about Mac OSX refreshing the connection gave me trouble.

Step 4: Wire up your Arduino to program the ATtiny85

Picture of Wire up your Arduino to program the ATtiny85
F45XIBQGXHJ57UK.MEDIUM.jpg
Follow the wiring/pin diagrams here:
http://hlt.media.mit.edu/?p=1229

This site is also good reference:
http://provideyourown.com/2011/arduino-program-attiny/

The connections are:
    ATtiny Pin 2 to Arduino Pin 13 (or SCK of another programmer)
    ATtiny Pin 1 to Arduino Pin 12 (or MISO of another programmer)
    ATtiny Pin 0 to Arduino Pin 11 (or MOSI of another programmer)
    ATtiny Reset Pin to Arduino Pin 10 (or RESET of another programmer)

You can also wire up LEDs to show your programmers status. Use 1K ohm resistors between the LEDs and Vcc.
Arduino Pin 9: Heartbeat - shows the programmer is running
Arduino Pin 8: Error - Lights up if something goes wrong (use red if that makes sense)
Arduino Pin 7: Programming - In communication with the slave (use green if you like)

Connect a 120ohm resistor between the arduino Reset pin and +5v. This will prevent the arduino from resetting before it can program the ATtiny85.
Some have had success with a 10uF capacitor between the arduino Reset pin and Ground.

Step 5: Burn your program onto the ATtiny85.

Picture of Burn your program onto the ATtiny85.
1. Load the example TM1640 sketch in your Arduino v1.0 software.
2. Change your output pins to 0 and 1 respectively.

If you want to use premade code, see the attached Arduino sketch. It's a modified version of the TM1640 example sketch.

Note: You might notice that in my example code, i've divided the millis() function by 16. This is because the millis() function was written for the Arduino, that runs at 16Mhz, whereas the ATtiny85 is running at 1Mhz. If you don't do this, the time will run 16x too fast!

3a. (original method, not recommended)
In your arduino menu:
  -Change the board to "ATtiny85 (1Mhz)"
  -Change the Programmer to "Arduino As ISP"

3b. (optional, recommended)
Configure your ATtiny85 to run at 8Mhz!
  -Change the board to "ATtiny85 (8Mhz)"
  -Change the Programmer to "Arduino As ISP"
  -Click "Burn Bootloader"

Running the ATtiny85 @ 8Mhz seems to fix the division problem with the millis() function. It keeps proper time without the division by 16.
 

4. Burn the sketch. You should see the green LED light up, and the RX/TX leds blink rapidly.
If all goes well you should see the green LED go out and the status led continue pulsing.

Note: I had to perform this step in Windows XP. Something about Mac OSX refreshing the connection gave me trouble.


You should now have a programmed ATtiny 85! Test it out by connecting the chip to Vcc and ground. Connect the TM1640 to Vcc and ground, and connect the Data and Clock pins to Pins 5 and 6 respectively on the Attiny85.

Don't worry if you get the data and clock pins backwards for the TM1640, you can just switch them with no damage done.


Note: The ATtiny85 can be programmed right on a breadboard. It can also be programmed in the circuit we will build. (as pictured)


Step 6: Make a versatile interface for the ATtiny . Build the perfboard circuit.

Picture of Make a versatile interface for the ATtiny . Build the perfboard circuit.
photo5Sized.jpg
photo6Sized.jpg
Now that you've got the code on the ATtiny85, it's time to put your chip into a mini-circuit!

1. Trim your perfboard to have 6x4 useable holes.
2. Solder your 8-Pin IC holder to the perfboard.
3. Cut two 4-pin sections out of your long header strip. Note, you'll have to cut along one of the adjacent pins. Each cut you make, you will loose one pin.
4. Solder your two sets of header pins to the perfboard.
It is easier to solder the header pins if you use some male-male header pins, and mount the circuit you're building to a breadboard.
5. Connect each IC holder pin to a long header pin with a line of solder.
6. Check your connections with a test probe or multimeter on continuity mode to insure you haven't bridged any of the IC holder pins.


I plan to use this setup not only for this display, but for future prototyping with the ATtiny13 and ATtiny85.
It's much easier to work with and has only a slightly larger footprint (vs the chip by itself).

Step 7: Final setup and notes. And a video!

Picture of Final setup and notes. And a video!
photo3Sized.jpg
photo8Sized.jpg

===Connecting your ATtiny===
-Instead of using the supplied TM1640 cable, I made my own.
Using some female-female wires from Dealextreme (SKU 55454) and some heatshrink. I could have definitely spliced these cables shorter for this application.
(www.dealextreme.com/p/single-port-female-to-female-jumper-wire-set-50-pack-20cm-length-55454)

-I connect the TM1640 to the male part of the headers, and an external 5v power supply to the female part of the headers.



===Reprogram your ATtiny easily!===
- The ATtiny85 can be programmed without removing it from our new perfboard. It only takes up two additional holes on a breadboard VS the chip by itself. It's also much easier to grab and work with compared to the bare chip.



===Interface with your ATtiny = More inputs/outputs!===
-There are THREE (3) additional pins available on the ATtiny85 for use as data inputs to control the display. These can also be used as outputs to other devices.
-The ATtiny85 is also able to use it's RESET pin for communication, but that's beyond the scope of this instructable.
I'll be writing another in the future to detail this process.



===Project ideas===
-Could be used in a car with the proper voltage regulator. Remember running voltage for most cars is ~14.4v
  The ATtiny85 and the TM1640 display operate on 5v.
-Could be wired directly to a USB cable for power (+5v)




Here's a clip of the ATtiny running arduino code for the display, before I built the perfboard setup.
Shows how grounding the RESET pin will restart the sketch.
 
Remove these adsRemove these ads by Signing Up
Foxtrot702 years ago
I do not have an Arduino board but I have breadboarded an Atmel328 chip and use a USBtinyISP. I am using Arduino-1.0 I can download bootloader to the chip but, can not download ArduinoISP. Any ideas?
Panici (author)  Foxtrot702 years ago
Try using Arduino v0023 to download ArduinoISP onto your chip.
See step 3 for more detail.

Good luck!
I went to Arduino 22 and was able to upload ArduinoISP to the Atmel328 chip. When I try to upload my program to ATTiny85 chip I get the following error: "Serial: was not declared in this scope. Any ideas?
Panici (author)  Foxtrot702 years ago
After you've got ArduinoISP on your chip, load your program using the newest version. I believe it's v1.0
I went thru the steps to DL Arduino v1.0 and added the Tiny.zip file from github, I then selected File>Sketchbook>My Program; Tools>Board >ATtiny85 ( with internal 8 MHz clock), then Programmer>Arduino as ISP, then selected verify and then the following error msg appeared see Attachment. If iot doesn't appear basically it says :

Create process=3. The system can not find path.

What do I need to do from here?
Panici (author)  Foxtrot702 years ago
You missed this part I think.

3b.
Configure your ATtiny85 to run at 8Mhz!
-Change the board to "ATtiny85 (8Mhz)"
-Change the Programmer to "Arduino As ISP"
-Click "Burn Bootloader"
I went back thru and re-installed Arduino-22 and followed your steps in 3b and got the following,

avrdude: stk500_getsync ( ) : not in sync: resp=0x00

avrdude: stk500_disable ( ) : protocol error, expect=0x14, resp=0x51

Any suggestions?
Panici (author)  Foxtrot702 years ago
Were you able to find a solution?
Yes I did. In this case all I needed to do was select ATtiny85w/USBtinyISP and the directly upload the program. There appears to be not enough room for "Bootloader" on the ATtiny85. Program runs well however, I have noticed an additional thing I would like to do. My program it is basically 2 LEDs that flash in different modes with a mode select pushbutton. When I power off/on the circuit I must re-select the mode I had previously running. I can think of possible two methods to correct this: First Method - Add information in program I think in the non-volital area, Second Method - Add a memory super capacitor with a blocking diode to the circuit for the ATtiny85. In regard to the first method do you know of any examples I can view? I have no training in programming so this is a very intense activity for me. The second method is very doable for me as I have the physical room on the circuit board is to add the components.

Regards
Mike
Panici (author)  Foxtrot702 years ago
It's got to be something with that USBtinyISP.

I have no experience with that so I can't really help. Post on Arduino.cc forums and they may be able to assist.
I designed a shield to program AtTiny processors with Arduino´s. It´s available here: http://flytron.com/open-source-hardwares/162-tinyshield-all-in-one-avr-programmer-shield-for-arduino.html

Step 4 will be much easier with it.

It also emulates an STK-500 and can burn bootloaders on ATmega168/328 processors.
Panici (author)  CrashingDutchman2 years ago
Good stuff. I've built an 8-Pin attiny programming shield myself.

If I need to program the larger chips, it's just a few wires.
Great job! I've been stuck trying to program an ATTiny for several days with no luck. I have a shield from Randofo, I tried a perf board, I used a 10uF cap, a 120 ohm resistor--no luck. I reloaded the software on a MacBook Air and a MacBook Pro--no luck. Was getting ready to try a PC when I saw your instructable. The combination of v0023 and attiny45_85.zip works!
Panici (author)  MikeTheMaker2 years ago
Glad you got it working!

It took me a bit of trial and error to figure it out.

I've actually just make a shield today that lets me program any 8-Pin ATtiny.
It's got jumpers for the 120ohm resistor or 10uF cap, or no RESET modification at all.

Also, dip switches to disconnect the data lines from the arduino. That way they can run seperate code, the arduino can be reprogrammed with the attiny attached, and you can isolate the attiny (except for ground and power) to prototype right on top of the Arduino.
wirenut19802 years ago
Great project! It's easy and simple what more could you ask for. In case you might be interested I have a source that has the same brand and specs on the ATtiny but almost half the cost! http://www.mouser.com/Semiconductors/MCU-MPU-DSP-DSC-SoC-Processors/Microcontrollers-MCU/_/N-6hpeg?P=1z0wa9b&Keyword=attiny85&FS=True
Panici (author)  wirenut19802 years ago
Thanks wirenut! I've already got a few ideas to improve upon this design. Thinking of making an enclosure as well.

Mouser is great, but their shipping is $12 more then Digikey.