Simple Press Counter for ATtiny2313

For Adafruit customers who seek help with microcontrollers

Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.
1051100720
 
Posts: 11
Joined: Wed Apr 14, 2010 4:18 am

Simple Press Counter for ATtiny2313

Post by 1051100720 »

Dear all,

I'm so new to microcontrollers and programming them and I would be really really thankful if somebody can give me some help here.

I want to build a simple press counter using the ATtiny2313 and I am using this link (http://www.instructables.com/id/How-to- ... Ttiny2313/) as a reference because it is very similar to what I want to do.

However, I want my counter to be able to count to more than 10, for example, increment by 1 to a maximum total of about 1000. But I am not sure what type of changes I have to make to the codes to make that possible.

Can somebody please help me? I'm still very new to all this. Thank you so much for viewing and helping!

adafruit
 
Posts: 12151
Joined: Thu Apr 06, 2006 4:21 pm

Re: Simple Press Counter for ATtiny2313

Post by adafruit »

check out the Digg button project, http://www.ladyada.net/make/digg/ its probably exactly what you're looking for and the code should be easy to read

1051100720
 
Posts: 11
Joined: Wed Apr 14, 2010 4:18 am

Re: Simple Press Counter for ATtiny2313

Post by 1051100720 »

Dear adafruit,

Thanks so much for ur quick reply!

I've looked at the link you posted. Got a few questions. What if I were to use a 16x2 lcd instead of 7 segment displays? How will the codes be different then??

Thank you so much and sorry for the trouble!

User avatar
adafruit_support_bill
 
Posts: 88154
Joined: Sat Feb 07, 2009 10:11 am

Re: Simple Press Counter for ATtiny2313

Post by adafruit_support_bill »

The low-level interface to the LCD will be different than a 7-segment display. You will need to modify the display code considerably.

If you are just getting started. I'd suggest starting with a documented project. Once you get it working (getting familiar with the tools and materials in the process) then you can start modifying it into what you really want.

All of the sources for the DIGG button are available here: http://www.ladyada.net/make/digg/download.html
And you'll find good support here on the Adafruit forums.

1051100720
 
Posts: 11
Joined: Wed Apr 14, 2010 4:18 am

Re: Simple Press Counter for ATtiny2313

Post by 1051100720 »

Dear arduwino,

Thank you so much for your reply. :)

I'm really quite new to all this. But I'm trying. I'm not really familiar with the codes as this is my first time programming a microcontroller. I am however quite familiar with C. How do I go about reprogramming it to display on an lcd?

Once again, thanks so much for your help!

User avatar
adafruit_support_bill
 
Posts: 88154
Joined: Sat Feb 07, 2009 10:11 am

Re: Simple Press Counter for ATtiny2313

Post by adafruit_support_bill »

Unlike the 7-segment display which is controlled at the segment level, the LCD has a parallel command interface which controls it at the character level. The Adafruit lcd library source code would be a good reference for how this is done.

http://www.adafruit.com/blog/2009/07/10 ... l-library/

uhe
 
Posts: 178
Joined: Mon Sep 03, 2007 4:50 pm

Re: Simple Press Counter for ATtiny2313

Post by uhe »

1051100720 wrote:I am however quite familiar with C. How do I go about reprogramming it to display on an lcd?
The code from the instructable is simple enought that someone who is quite familiar with C shouldn't have any problems in understanding and modifying it (without looking at other projects like the DIGG button)!
So I assume your problem lies in step 5 Build and Burn?

1051100720
 
Posts: 11
Joined: Wed Apr 14, 2010 4:18 am

Re: Simple Press Counter for ATtiny2313

Post by 1051100720 »

Dear arduwino,

Thanks again! I will check that out. :P

Dear Uhe,

I'm not really used to the microcontroller 'slang'. :cry:

Other than that, is there any other avr compiler that you all recommend? I am currently using winavr and avrstudio but I'm having problems generating the hex file.

Thanks a lot!

uhe
 
Posts: 178
Joined: Mon Sep 03, 2007 4:50 pm

Re: Simple Press Counter for ATtiny2313

Post by uhe »

1051100720 wrote:I'm not really used to the microcontroller 'slang'. :cry:
It's not that different, you have variables in HW -> registers, you have events -> interrupts, you have man pages -> datasheets... ;)
1051100720 wrote:Other than that, is there any other avr compiler that you all recommend? I am currently using winavr and avrstudio but I'm having problems generating the hex file.
Everything I've seen is using avr-gcc, even winavr and avrstudio.
I've never used one of them, just make.

1051100720
 
Posts: 11
Joined: Wed Apr 14, 2010 4:18 am

Re: Simple Press Counter for ATtiny2313

Post by 1051100720 »

Dear Uhe,

Sorry, but I'm still learning. For example, based on the codes from http://www.instructables.com/id/How-to- ... Ttiny2313/, there's a line:

Data_Lcd(0x88);

How did the author come up with '0x88'? Does that have to be changed if I increased the 'score'?

Hehe. I'm sorry for causing so much trouble! But all your help is deeply appreciated!! :D

mtbf0
 
Posts: 1645
Joined: Sat Nov 10, 2007 12:59 am

Re: Simple Press Counter for ATtiny2313

Post by mtbf0 »

1051100720 wrote: How did the author come up with '0x88'?
she probably read the datasheet.

1051100720
 
Posts: 11
Joined: Wed Apr 14, 2010 4:18 am

Re: Simple Press Counter for ATtiny2313

Post by 1051100720 »

Dear mtbf0,

Thanks for sharing your suggestion and the datasheet! I've downloaded it but I'm not sure what I should be looking for or looking at.

BTW, I've tried burning the codes into my microcontroller. But there are only black squares on the display?

Thanks! :)

uhe
 
Posts: 178
Joined: Mon Sep 03, 2007 4:50 pm

Re: Simple Press Counter for ATtiny2313

Post by uhe »

1051100720 wrote:Thanks for sharing your suggestion and the datasheet! I've downloaded it but I'm not sure what I should be looking for or looking at.
In short: you need to read everything ;) Especially the description of the registers so that you know which value you need to write to which register.
1051100720 wrote:BTW, I've tried burning the codes into my microcontroller. But there are only black squares on the display?
And what is the question here? It's unlikely that anyone can help you without code or an error message or a description what you expect instead of black squares..

I've never used any LCD display before so i think i'm not a big help on that topic. But you got me corious :)
This afternoon I grabbed an LCD (from a retired HP server ) and had a look at the Character LCD Wiring up a character LCD to an Arduino tutorial from Ladyada.... And I had a *Hello world* in no time!

1051100720
 
Posts: 11
Joined: Wed Apr 14, 2010 4:18 am

Re: Simple Press Counter for ATtiny2313

Post by 1051100720 »

Dear Uhe,
In short: you need to read everything ;) Especially the description of the registers so that you know which value you need to write to which register.
Oh, I see! I didn't know that!Will try and relook everything. :)
And what is the question here? It's unlikely that anyone can help you without code or an error message or a description what you expect instead of black squares..
Lols, you're right! I'm sorry. I'm just so new to all this. It's actually my first time touching a microcontroller, so I'm really lost and blur. Sorry sorry. Anyway, the only error that appeared is the one below.

Image

Other than that, the codes built perfectly (i think). But when I burnt it into the microcontroller, the lcd showed something like this:http://www.windstuff.org/controller/pag ... roller.jpg

Thanks so much for actively trying to help me here! Please forgive my total 'beginner-ness'! :D

User avatar
Franklin97355
 
Posts: 23940
Joined: Mon Apr 21, 2008 2:33 pm

Re: Simple Press Counter for ATtiny2313

Post by Franklin97355 »

Most LCDs have a contrast setting and if it is too high everything will look like "black squares"

Locked
Please be positive and constructive with your questions and comments.

Return to “Microcontrollers”