NEW: Learning electronics? Ask your questions on the new Electronics Questions & Answers site hosted by CircuitLab.
Support Forum » Need help, is there a problem with my DIP switch?
July 15, 2012 by TheFed |
Im sorry that i've double posted this but i really dont know under which category it falls. (multiple i guess) So i finished my dip_arithmetic project and decided to expand it a little to try out my new-found knowledge of electronics. Here's my idea: I decided that i would try represent each digit from one number with LED's (the binary ones, so like 101 would be: red-LEDoff-green), and then use the DIP switch to alternate between the two different numbers (the ones you add up). Here's what I did: So I attached a LED into PB1, PB2 and PB3 Then i wired my DIP switch (which has 8 switches instead of 6, like in the manual) so that additionally to: DP1 -> MCU pin 23 DP2 -> MCU pin 24 DP3 -> MCU pin 25 DP4 -> MCU pin 26 DP5 -> MCU pin 27 DP6 -> MCU pin 28 I had DP7 -> MCU pin 18 and of course wired it to the GND Here's my code, and its the first C code i've written by myself so there's bound to be some awefull mistakes. ============================================================================= // dip_arithmetic.c // for NerdKits with ATmega168 // hevans@mit.edu
=============================================================================
So, thats it. Now what happens to me is that when i change from one number to the other, the LED change too, but then after a while they change back and then back again and so forth. Also if i push on the DIP switch it tends to work properly. I have rewritten my code and tried different approaches but the same thing keeps happening. So is my DIP switch partly broken or have i made some mistake in the code or in my circuit? (1 through 6 work fine). |
---|---|
July 15, 2012 by TheFed |
Also im going away for a week so i cant reply then. |
July 15, 2012 by TheFed |
But please do post questions, advise or solutions! ;) |
July 15, 2012 by pcbolt |
Hi Fedde - You may have to enable the pull-up resistor for PB4. |
July 15, 2012 by Rick_S |
No reason to double post ... check your other post for some info. |
July 15, 2012 by TheFed |
Im sorry that i double posted, and when i realised it should be under support i posted it there but i couldnt delete the other one but whatever, thanks a lot for the quick reply; Im new but it shows me the kind of community behind Nerdkits. And yes enabling the Pull up resitor was all i needed to do. |
Please log in to post a reply.
Did you know that a square wave sounds different than a sine wave? Learn more...
|