NEW: Learning electronics? Ask your questions on the new Electronics Questions & Answers site hosted by CircuitLab.
Basic Electronics » Simple I/O circuit
September 23, 2012 by wadaltmon |
Hello, I am looking to construct a simple I/O circuit using a SPST input at PC1 and an LED output at PC0. What I want to do is simply have the LED on when the button is pushed, and the LED off when the button is not being pushed (I am aware it is possible without a microcontroller, but I want to get this basic code down for a more complicated project later). My current code is as follows:
However, I cannot get this code to accomplish what I want it to. What kind of mistake am I making, and how can I change my code to accomplish the simple task I mentioned? Thanks, Dalton |
---|---|
September 23, 2012 by Noter |
Where's the while() loop? And there is nothing to return to anyway so you can declare main as a void and leave out the return. |
September 23, 2012 by wadaltmon |
Wow... when I was editing to post the code, I took out the while loop. Whoops. Anyway, I decided to modify the code that I have:
Yet, still, it doesn't work. I see nothing wrong with it, really. |
September 23, 2012 by wadaltmon |
Nevermind guys, I figured it out. Just had to switch the input of the SPST to ground, and then put the cathode of the LED in the output pin, and the anode in my VCC rail. Hopefully this helps someone with the same problem as me in the future. |
Please log in to post a reply.
Did you know that an analog comparator can tell when one voltage input crosses another? Learn more...
|