NEW: Learning electronics? Ask your questions on the new Electronics Questions & Answers site hosted by CircuitLab.
Microcontroller Programming » How do I read what the bit is set to and the write it to the screen?
November 10, 2010 by KyleH ![]() |
I thought I would take the challenge put forth the NK sample projects and make the LCD print when the screen is on or off. I didn't know what a microcontroller was three weeks ago and know nothing of C so its been a fun learning curve. The Atmega168 Datasheet provides this sample code for reading the pin value so I tried to include it in my code shown below. I tried calling my variable I both portc and pinc to no avail. Am I on the right track here? C Code Example
My code attempt:
|
---|---|
November 10, 2010 by KyleH ![]() |
Heh I just figured out that I could simply write on when I turn it on and off when I turn it off. Still I think it would be useful to know how to store whatever I am telling it to do and then recall it as a variable and say if its on, print on, if it is off print off. COuld you provide some help on how to do that in this case? Working code in the loop looked like this:
|
November 11, 2010 by bretm ![]() |
You want
This will be either 0 or 16 depending on the state. If you want 0 or 1 you can do
In your previous example it would always be zero (if you used PINC instead of PORTC) because you always checked right after you turned it off. |
Please log in to post a reply.
Did you know that a thermometer can be made "faster" by using a bit of math? Learn more...
|