SparkFun AVR Stick schematics

The SparkFun AVR Stick is a simple data logging device that instantiates itself as an HID keyboard and reports the voltages, along with a ‘timestamp,’ from two pins on an ATtiny85.

The repository is at https://github.com/sparkfun/AVR_Stick  where you can find out more details.

I like looking over the schematics for boards like this, in fact I’ll be posting more creative commons designs. Using the files from the repository you can load them into Eagle and look at the schematics and board layout, if you plan on designing your own boards at some point this can be an invaluable learning aid just seeing how professionals layout schematics neatly and how people layout boards and route them.

Avr stick

Avr stick

ZFlasher AVR android app

Zflasher is an android app that allows you to program your AVR device from your Android device. It supports the following programmers

USBasp
AVRISP mkII
USBtiny

From what I have seen these are the most popular programmers out there, so this wasn’t an issue for me.

zflasher screenshot

zflasher screenshot

One thing to note is that if you have an Android version prior to 3.1 on your device, it will need to be rooted. As part of my research on Android development this didn’t appear to be an issue as pre Android 4.0 devices are rapidly being replaced but it may affect some.

The app is now supported on Android 5 and has mcu detection capabilities, its refreshing and reassuring to see that the app is in development and new features and any bugs are being fixed

Permissions

In-app purchases
Photos/Media/Files
  • modify or delete the contents of your USB storage
  • read the contents of your USB storage
Other
  • prevent device from sleeping

Links

Download ZFlasher AVR android app on Google play

ATmega16 and MAX7219 8 x 8 matrix

This is a picture of the 8 x 8 LED matrix display I used which I connected to my ATmega16

Here are the connections

CS -> PORTD 2
DIN -> PORTD 1
CLK -> PORTD 0

MAX7219

MAX7219

Schematic

 

Code

 

#define CS_Pin PORTD.F2
#define DIN_Pin PORTD.F1
#define CLK_Pin PORTD.F0
 
unsigned const short Alphabet[156]={
0x7f, 0x88, 0x88, 0x88, 0x88, 0x7f, // A
0x6e, 0x91, 0x91, 0x91, 0x91, 0xff, // B
0x42, 0x81, 0x81, 0x81, 0x81, 0x7E, // C
0x7e, 0x81, 0x81, 0x81, 0x81, 0xff, // D
0x91, 0x91, 0x91, 0x91, 0xff, 0x81, // E
0x80, 0x90, 0x90, 0x91, 0xff, 0x81, // F
0x4e, 0x89, 0x89, 0x81, 0x81, 0x7e, // G
0xff, 0x10, 0x10, 0x10, 0x10, 0xff, // H
0x00, 0x81, 0xff, 0xff, 0x81, 0x00, // I
0x00, 0x80, 0xfe, 0x81, 0x01, 0x06, // J
0x81, 0xc3, 0x24, 0x99, 0xff, 0x81, // K
0x03, 0x01, 0x01, 0x81, 0xff, 0x81, // L
0xff, 0x60, 0x18, 0x18, 0x60, 0xff, // M
0xff, 0x06, 0x08, 0x10, 0x60, 0xff, // N
0x7e, 0x81, 0x81, 0x81, 0x81, 0x7e, // O
0x70, 0x88, 0x88, 0x89, 0xff, 0x81, // P
0x7e, 0x87, 0x89, 0x85, 0x81, 0x7e, // Q
0x61, 0x93, 0x94, 0x98, 0x98, 0xff, // R
0x4e, 0x91, 0x91, 0x91, 0x91, 0x62, // S
0xc0, 0x81, 0xff, 0xff, 0x81, 0xc0, // T
0xfe, 0x01, 0x01, 0x01, 0x01, 0xfe, // U
0xfc, 0x02, 0x01, 0x01, 0x02, 0xfc, // V
0xff, 0x02, 0x04, 0x04, 0x02, 0xff, // W
0xc3, 0x24, 0x18, 0x18, 0x24, 0xc3, // X
0xc0, 0x20, 0x1f, 0x1f, 0x20, 0xc0, // Y
0xc3, 0xa1, 0x91, 0x89, 0x85, 0xc3, // Z
};
 
void SPI_Write_Byte(unsigned short num)
{
unsigned short t, Mask, Flag;
CLK_Pin = 0;
Mask = 128;
for (t=0; t<8; t++) { Flag = num & Mask; if(Flag == 0) { DIN_Pin = 0; } else { DIN_Pin = 1; } CLK_Pin = 1; CLK_Pin = 0; Mask = Mask >> 1;
}
}
 
void MAX7219_INIT() {
 
// Set BCD decode mode
CS_Pin = 0; // CS pin is pulled LOW
SPI_Write_Byte(0x09); // Select Decode Mode register
SPI_Write_Byte(0x00); // Select BCD mode for digits DIG0-DIG7
CS_Pin = 1; // CS pin is pulled HIGH
 
// Set display brighness
CS_Pin = 0; // CS pin is pulled LOW
SPI_Write_Byte(0x0A); // Select Intensity register
SPI_Write_Byte(0x05); // Set brightness
CS_Pin = 1; // CS pin is pulled HIGH
 
// Set display refresh
CS_Pin = 0; // CS pin is pulled LOW
SPI_Write_Byte(0x0B); // Select Scan-Limit register
SPI_Write_Byte(0x07); // Select digits DIG0-DIG3
CS_Pin = 1; // CS pin is pulled HIGH
 
// Turn on the display
CS_Pin = 0; // CS pin is pulled LOW
SPI_Write_Byte(0x0C);
SPI_Write_Byte(0x01);
CS_Pin = 1; // CS pin is pulled HIGH
 
// Disable Display-Test
CS_Pin = 0; // CS pin is pulled LOW
SPI_Write_Byte(0x0F); // Select Display-Test register
SPI_Write_Byte(0x00); // Disable Display-Test
CS_Pin = 1; // CS pin is pulled HIGH
 
}
 
void Write_Byte(unsigned short myColumn, unsigned short myValue)
{
CS_Pin = 0; // select max7219.
SPI_Write_Byte(myColumn); // send myColumn value to max7219 (digit place).
SPI_Write_Byte(myValue); // send myValue value to max7219 (digit place).
CS_Pin = 1; // deselect max7219.
}
 
// This is clear matrix function.
void Clear_Matrix(void)
{
unsigned short x;
 
for(x=1;x<9;x++)
{
Write_Byte(x,0x00);
}
}
 
void Write_Char(char myChar)
{
unsigned short Column, Start_Byte;
 
// Clear the display first.
Clear_Matrix();
// The next line defines our byte, from which to start the array.
Start_Byte = (myChar - 65) * 6; // 65 represents the letter "A" in ASCII code.
// We are using only columns from 2 through 7 for displaying the character.
for(Column=2;Column<8;Column++)
{
Write_Byte(Column, Alphabet[Start_Byte++]);
}
}
 
void main()
{
unsigned int x;
DDRD=0xFF;
 
MAX7219_INIT(); // initialize max7219
do{
for(x=65;x<=90;x++) // Increment with 1, from 65 until 90.
{
Write_Char(x);
Delay_ms(1000); // This is our delay, between two consecutive character.
}
}while(1);
}

 

 

Links

MAX7219 Dot Matrix Module Display DIY kit

MAX7219 Dot matrix module display module

Atmega16 and a 7 segment display

In this example we will show you how to connect a 7 segment display to our Atmega16. You can think of a 7 segment display as 7 individual LEDs in a configuration like the picture below.

Image 1 shows the layout and image 2 shows how the segments are arranged

7 seg Blank

7 seg Blank

So by lighting certain segments you can display numbers, so for example to display the number 1 you would light segments B and C. Here are more examples

7 segment

7 segment

In this example we connect a HDSP-C3Y3 common anode display to our ATmega16, you can see the connections in the schematic below. We basically connect up segment A to PD0, segment B to PD1 and so on.

Schematic

atmega16 and 7segment

atmega16 and 7segment

Code

The code was written in mikroC pro for AVR

 

int main(void)
{
DDRD = 0xFF; // Configure port D as output
while(1)
{
 
/*
 
1 1 1 1 1 1 1 1
DP G F E D C B A
 
*/
 
PORTD = 0xC0; // Display Number 0
delay_ms(1000); // Wait for 1s
PORTD = 0xF9; // Display Number 1
delay_ms(1000); // Wait for 1s
PORTD = 0xA4; // Display Number 2
delay_ms(1000); // Wait for 1s
PORTD = 0xB0; // Display Number 3
delay_ms(1000); // Wait for 1s
PORTD = 0x99; // Display Letter 4
delay_ms(1000); // Wait for 1s
PORTD = 0x92; // Display Letter 5
delay_ms(1000); // Wait for 1s
PORTD = 0x82; // Display Letter 6
delay_ms(1000); // Wait for 1s
PORTD = 0xF8; // Display Letter 7
delay_ms(1000); // Wait for 1s
PORTD = 0x80; // Display Letter 8
delay_ms(1000); // Wait for 1s
PORTD = 0x90; // Display Letter 9
delay_ms(1000); // Wait for 1s
}
}

 

Links

 

wholesale 50pcs/lot 1bit Common Cathode/Common Anode Digital Tube 0.56″ 0.56in Red LED Digit 7 Segment

20 PCS LD-3161BG 1 Digit 0.36″ GREEN 7 SEGMENT LED DISPLAY COMMON ANODE

Atmega16 and TIL311

til311

til311

Datasheet

Til 311 datasheet

Connection

Here are the TIL311 pin

PINS 1 and 14 LED supply/Logic Supply 5v
PIN 2 Latch Data Input B PORT D pin 1
PIN 3 Latch Data Input A PORT D pin 0
PIN 4 Left DP Cathode N/C
PIN 5 Latch Strobe Input Ground
PIN 7 Ground Ground
PIN 8 Blanking Input
PIN 10 Right DP Cathode N/C
PIN 12 Latch Data Input D PORT D pin 3
PIN 13 Latch Data Input C PORT D pin 2
til311

til311

Code

 

int i;
 
void main()
{
DDRD=0xFF;
PORTD=0xFF;
 
while(1)
{
for(i = 1; i<=15; i++)
{
PORTD = i;
delay_ms(200);
}
}
}

 

Links

5 PCS Promotion TIL311 HEXADECIMAL DISPLAY WITH LOGIC