Voting resources, early voting, and poll worker information - VOTE. ... Adafruit is open and shipping.
0

Simple Press Counter for ATtiny2313
Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.

Simple Press Counter for ATtiny2313

by 1051100720 on Wed Apr 14, 2010 4:26 am

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!
1051100720
 
Posts: 11
Joined: Wed Apr 14, 2010 4:18 am

Re: Simple Press Counter for ATtiny2313

by adafruit on Wed Apr 14, 2010 10:33 am

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

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

Re: Simple Press Counter for ATtiny2313

by 1051100720 on Thu Apr 15, 2010 4:25 am

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!
1051100720
 
Posts: 11
Joined: Wed Apr 14, 2010 4:18 am

Re: Simple Press Counter for ATtiny2313

by adafruit_support_bill on Thu Apr 15, 2010 6:48 am

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.

adafruit_support_bill
 
Posts: 78659
Joined: Sat Feb 07, 2009 10:11 am

Re: Simple Press Counter for ATtiny2313

by 1051100720 on Thu Apr 15, 2010 9:43 am

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!
1051100720
 
Posts: 11
Joined: Wed Apr 14, 2010 4:18 am

Re: Simple Press Counter for ATtiny2313

by adafruit_support_bill on Thu Apr 15, 2010 12:16 pm

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/arduino-updated-liquidcrystal-library/

adafruit_support_bill
 
Posts: 78659
Joined: Sat Feb 07, 2009 10:11 am

Re: Simple Press Counter for ATtiny2313

by uhe on Thu Apr 15, 2010 1:54 pm

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?
"I have not failed. I've just found 10,000 ways that won't work." - Thomas Edison
uhe
 
Posts: 178
Joined: Mon Sep 03, 2007 4:50 pm
Location: metric world

Re: Simple Press Counter for ATtiny2313

by 1051100720 on Thu Apr 15, 2010 3:05 pm

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!
1051100720
 
Posts: 11
Joined: Wed Apr 14, 2010 4:18 am

Re: Simple Press Counter for ATtiny2313

by uhe on Thu Apr 15, 2010 5:12 pm

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.
"I have not failed. I've just found 10,000 ways that won't work." - Thomas Edison
uhe
 
Posts: 178
Joined: Mon Sep 03, 2007 4:50 pm
Location: metric world

Re: Simple Press Counter for ATtiny2313

by 1051100720 on Fri Apr 16, 2010 1:24 am

Dear Uhe,

Sorry, but I'm still learning. For example, based on the codes from http://www.instructables.com/id/How-to-control-a-16x2-LCD-using-an-AVR-ATtiny2313/, 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
1051100720
 
Posts: 11
Joined: Wed Apr 14, 2010 4:18 am

Re: Simple Press Counter for ATtiny2313

by mtbf0 on Fri Apr 16, 2010 7:27 am

1051100720 wrote:How did the author come up with '0x88'?


she probably read the datasheet.
"i want to lead a dissipate existence, play scratchy records and enjoy my decline" - iggy pop, i need more
User avatar
mtbf0
 
Posts: 1645
Joined: Sat Nov 10, 2007 12:59 am
Location: oakland ca

Re: Simple Press Counter for ATtiny2313

by 1051100720 on Fri Apr 16, 2010 9:10 am

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! :)
1051100720
 
Posts: 11
Joined: Wed Apr 14, 2010 4:18 am

Re: Simple Press Counter for ATtiny2313

by uhe on Fri Apr 16, 2010 11:39 am

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!
"I have not failed. I've just found 10,000 ways that won't work." - Thomas Edison
uhe
 
Posts: 178
Joined: Mon Sep 03, 2007 4:50 pm
Location: metric world

Re: Simple Press Counter for ATtiny2313

by 1051100720 on Fri Apr 16, 2010 1:27 pm

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/page2/controller.jpg

Thanks so much for actively trying to help me here! Please forgive my total 'beginner-ness'! :D
1051100720
 
Posts: 11
Joined: Wed Apr 14, 2010 4:18 am

Re: Simple Press Counter for ATtiny2313

by franklin97355 on Fri Apr 16, 2010 4:52 pm

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

franklin97355
 
Posts: 21567
Joined: Mon Apr 21, 2008 2:33 pm
Location: Lacomb, OR.

Please be positive and constructive with your questions and comments.