You Are Here: Home » AVR ATmega Projects » 4-key keyboard using ATtiny85

4-key keyboard using ATtiny85




Introduction:

A good while back, I made the 1-key-keyboard project. Ever since it has always been in the back of my mind that the ATTiny microcontroller, which I used in this project, had still 3 IO ports which were unused. Only recently I’ve found the time to expand my old project in the most obvious way possible; by adding 3 more buttons to these IO ports and thereby creating a 4-key-keyboard, without having to add any other hardware than these 3 extra buttons.

4-key keyboard

Although this project can still easily be built on a stripboard, I chose this time to etch my own (single sided) PCB and to use an old USB cable to interface with the computer, instead of the makeshift USB-plug as used in my previous project.

The hardware:

1x Atmel ATTiny45-20PU or ATTiny85-20PU microcontroller
• 1x 8-pin DIL socket (optional but highly recommended)
• 2x Diodes (0.5W) (ordinary 1N4148 will do the job)
• 2x 68 ohm resistors
• 1x 1.5K resistor
• 1x 0.1 uF capacitor (note: can be higher capacity, I also used 1uF and in the example circuit from obdev they use 4u7)
• 4x push-button
• 1x usb cable with the standard usb-A plug
• 1x etched circuit board (or use stripboard as alternative)

And a programmer for the ATTiny45/ATTiny85 microcontroller. For this project a programmer supporting High Voltage Serial Programming (HVSP) is highly recommended, since we enable the ‘reset disable’ fuse. I’ll explain this in more detail later on.

The schematics:

4-key keyboard schematic

The circuit-board:

In the .zip file of this project, there’s a .pdf which can be used for photo-chemical etching of the circuit-board. EAGLE files are also included.

The component layout on the circuit board:

The firmware:

I tried to add useful comments to the sourcecode of this project, so I suggest to have a look at it to see the precise details.

At a high-level, this project implements V-USB (previously called AVR-USB) from Objective Development, which I use to emulate a USB keyboard.

Contrary to my 1-key-keyboard project, I now used the standard report descriptor for a USB keyboard, which has a 8-byte report buffer. This may be a bit of a overkill, since I only use 4 of these bytes in this project (1 for each button) but it does allow for easy expansion of functionality in the future.

Another difference with my old project is the fact the way key-presses are emulated. in the old version, two different keys were emulated on press and release of the button. Now every button simulates just 1 key, but with its individual key-down and key-up event, which is exactly the same as a normal keyboard operates.

In the standard firmware, key presses are emulated for the keyboard-keys 1 to 4. Though this can easily be changed.

 

For more detail: 4-key keyboard using ATtiny85

Leave a Comment

You must be logged in to post a comment.

Read previous post:
RSS Reader
RSS Reader using ATmega8 microcontroller

I spent part of an afternoon developing a hardware RSS reader (most of my time was spent on the python...

Close
Scroll to top