NEW: Learning electronics? Ask your questions on the new Electronics Questions & Answers site hosted by CircuitLab.
Project Help and Ideas » GEE handheld system program help......
June 07, 2010 by Master_Programmer |
Okay, i've made a game system out of the nerdkits, and i have made a program......and i need someone to point out what all i did wrong in my program. (DOORS.C) // dip_arithmetic.c // for NerdKits with ATmega168 // hevans@mit.edu
i'm okay at using c++, but when it comes to programming an ATMEGA168, i have no clue of what i'm doing, and just need pointed "in the right direction" as some would say. :D |
---|---|
June 07, 2010 by Master_Programmer |
and yes, i modified another 2 programs to make this one......having the no clue that i do....... |
June 07, 2010 by Master_Programmer |
DOORS.c: In function 'main': DOORS.c:102: warning: 'dead' is used uninitialized in this function DOORS.c:59: warning: 'a1' may be used uninitialized in this function DOORS.c:71: warning: 'action' may be used uninitialized in this function DOORS.c:68: warning: 'level' may be used uninitialized in this function DOORS.c:67: warning: 'score' may be used uninitialized in this function was the warnings i got. the game compiles and goes to the MCU just fine, but i get a blank screen, or the dip switch does nothing either way. |
June 07, 2010 by hevans (NerdKits Staff) |
Hi Master_Programmer, I think the problem might actually be that you are not initializing your local variables at all. In general you want to make sure you have set the value of the variable before trying to use it. Although most of the time you will be lucky and they get initialized to 0, I think in this case since they are local variables on the stack they actually have a non 0 value. Since a1 and dead are both non 0 your program is just zipping around the main while loop. At least that is what I think is happening. Try setting all your local variables to 0, and let us know what happens. I also like to write "Initializing" or something similar to the the LCD towards the beginning of my code, just so I can be sure the program is running at all. Humberto |
June 07, 2010 by Master_Programmer |
thanks a lot! i'll give your idea a try, and hope it works, caus if it does, my dad will be really proud of me!!!!! |
June 07, 2010 by Master_Programmer |
OH MY GOSH!!!! OH MY GOSHOH MY GOSHOH MY GOSHOH MY GOSHOH MY GOSHOH MY GOSHOH MY GOSHOH MY GOSHOH MY GOSHOH MY GOSHOH MY GOSHOH MY GOSHOH MY GOSHOH MY GOSHOH MY GOSHOH MY GOSHOH MY GOSHOH MY GOSHOH MY GOSHOH MY GOSHOH MY GOSH it almost worked(i have a while loop messing up still) but it almost worked fully!!!!!!!!! the first game system i have ever made, and the first game for it!!!! my project is now 80% done!!!!! thank you SOOOOOOOO much hevans!!!!!!! THANK YOU!!!! hands you a happy cookie XD |
Please log in to post a reply.
Did you know that you can use printf and scanf functions to talk to your computer from your USB NerdKit? Learn more...
|