NEW: Learning electronics? Ask your questions on the new Electronics Questions & Answers site hosted by CircuitLab.
Support Forum » Cannot Make Music with the MicroController
May 28, 2010 by nerdguy |
Just received the nerdkit and went through the manual. Now I'm trying the "Make Music with the MicroController" project. Copied the musicbox1.c source code and created a makefile. Tried to compile the C code from the command window and the output is:
There appears to be some undefined variables like PORTA, PA7, PINA, etc. Where are these variables being defined? I don't see them in the header files (I didn't look at all of them though). |
---|---|
May 28, 2010 by bretm |
That program was written for a different microcontroller. It needs some modifications to work with the Atmega168, which doesn't have an "A" port. |
May 29, 2010 by nerdguy |
Is it a simple change? Suppose I change the code so it all references PORTC? Has anyone gotten this to work? |
May 29, 2010 by mrobbins (NerdKits Staff) |
Hi nerdguy, You're exactly right. Yes, you can change all of the references to pins PA1 (the buzzer) and PA7 (the button), as well as registers PORTA, PINA, DDRA, to reference some other pins that do actually exist on the ATmega168. You would also want to remove the "OSCCAL = 176;" line from the main function -- this simply isn't relevant to the ATmega168 when we're using an external crystal. Finally, this project was designed when we were shipping kits with a 2-row, 24-character wide LCD. With the current 4-row, 20-character-wide LCD, you may want to adjust how and where the text is displayed. I can also point you to another forum post where another member posted their code regarding this project. I haven't personally looked at it but perhaps it will be useful in combination with the above information. Hope that helps! Mike |
May 31, 2010 by nerdguy |
mrobbins, Thanks for you reply and for confirming my guesses. I replaced all references for "A" to "C", changed the CPU definition and got rid of the push button code (haven't gotten to that project yet) to start the music. This got the LCD working correctly. Had to shorten the lines from 25 chars to 20 chars. I got the speaker working by switching the leads. Evidently, the speaker can be connected only one way for it to work correctly. This was not documented anywhere. (This is probably obvious to you but not to an inexperienced hardware person like me.) Anyway, like I said before, I just got the nerdkit and went through the "nerdkits guide". Now I'm trying to go through the projects on your website. No doubt, I'll have other questions. |
January 01, 2011 by BStory |
It's so nice to find my question already asked :) For me the remedy for the code was to redirect the lcd.h include and the delay.h include to ../libnerdkits/lcd.h and ../libnerdkits/delay.h (Maybe the reason for the "nothing to be done for 'all'" error?)
Instead of:
Then as mentioned above, I did away with PORTA/PINA references and used B instead. Still working out what is going on in the play_tone function and getting the button to start the thing but hey at least I know it works lol. |
January 08, 2011 by hariharan |
I compiled my program initialload.c and i got "Make: nothing to be done for intialload.c" What did i do wrong? |
January 09, 2011 by keithka |
hariharan: if you're still having trouble, please show us what's in your makefile. |
March 28, 2011 by hariharan |
i tried to modify the code for the music box, but it does not work, why? the code:
|
March 28, 2011 by hevans (NerdKits Staff) |
Hi Hari, If you let us know what errors you are getting we would be glad to help you figure out why you are getting those errors, but more importantly we can start helping you figure out how to interpret the errors you are getting so you can start learning how to troubleshoot these problems for yourself. Humberto |
Please log in to post a reply.
Did you know that you can make a spooky Halloween Jack-O-Lantern with a microcontroller? Learn more...
|