NerdKits - electronics education for a digital generation

You are not logged in. [log in]

NEW: Learning electronics? Ask your questions on the new Electronics Questions & Answers site hosted by CircuitLab.

Support Forum » PA1? Pin 19?? WTF?

June 18, 2009
by ki
ki's Avatar

Hello,

Nerdkit is a great tool for starting at microelectronics. I added some code to my temperature sensor for flashing a red LED when the DIP-Switch is set to a temperature. (via binary addition) Works like a charm. But when I try to add the piezo buzzer to that PA1 PIN I'm a bit confused where this information comes from. A search through the ATmega168 data sheet for PA1 or PORTA has no results. You say it's at PIN 19 which is PB5 in the data sheet here.

Please enlighten me. :-)

Best regards, Kai

June 20, 2009
by ki
ki's Avatar

Magic?!

June 20, 2009
by mrobbins
(NerdKits Staff)

mrobbins's Avatar

Hi Kai,

I'm not sure which project you are referring to, but you are correct, there is no PA1 or PORTA on the ATmega168. This probably references our older kit model, the Parallel Port NerdKit, which used a slightly different microcontroller (the ATtiny26L) and did have a PA1. Does that help? Which project are you trying to do?

Mike

June 20, 2009
by ki
ki's Avatar

Wow! That's helped much. :-) I'm reffering to the musicbox project. http://www.nerdkits.com/videos/musicbox1/

Can you give me a hint on which pin I must connect the piezzo buzzer? Currently I have no free pins than 2 and 3 (when the programmer is disconnected) since I use the DIP switch (7 inputs) the temperature sensor (3 inputs) and the LCD (most of PB and PD). Maybe I need can implement my temperature configuration DIP with 6 instead of 7 inputs (binary addition) for celsius temperatures. :-)

My general guestion is if need a "special / analog" port for the piezzo.

Best regards, Kai

June 22, 2009
by hevans
(NerdKits Staff)

hevans's Avatar

Hi Ki,

If you take a look at how we wrote the code for musicbox you will find that the pin we are using is just a normal digital pin. The code turns the pin on, then waits half the period of your note before turning the pin off again. Then repeats for the duration of the note. We note in the video that this will actually produce a square wave and not a pretty sounding sin wave, but for our purposes it's good enough. So in short, you should be able to just use a normal digital output pin to produce the tones the way we did in the musicbox project.

A word of caution here. The way we implemented the musicbox, the microcontroller spends most of its time in the function that is generating the tone. This means that while you are playing a note, you can't read data from the temp sensor, or vice versa. This is probably fine if you don't have really long notes. But you do need to be aware that these things will run sequentially; that is you can be playing a note, or reading the temperature sensor, or reading your DIP pins. You will need to figure out how to cycle between these tasks to make your project work.

Let us know how it goes. I must admit I am intrigued by the prospect of a temperature reading/Dip arithmetic/sound playing machine!

Post a Reply

Please log in to post a reply.

Did you know that a microcontroller can measure an RC time constant? Learn more...