NEW: Learning electronics? Ask your questions on the new Electronics Questions & Answers site hosted by CircuitLab.
Microcontroller Programming » residue left in off position (bitwise arithmetic example)
January 03, 2013 by Vreni |
Hello, i tried to change the bitwise arithmetic programme, i left shift the number a8 by pc5(=z1 in the code). So if switch 8 (connected to PC5) is set i get 32 that is correct but in case i switch it off i get a 02. The same happens when i do that for a7<<pc4 my variable z2 will show 16 (correct) but in the off position it shows 06. I thought that maybe in PINC are still some values set so i added an & condition but nothing improved. Please find the section of the code below : while(1) {
Thanks a lot for your help. Best regards, Verena |
---|---|
January 03, 2013 by pcbolt |
Hi Verena - I think your code is fine but the problem is when you output to the LCD. First when you output 32 you use 2 character spaces then when you print a single 0, it doesn't overwrite the previous 2 (from 32). Which explains why 06 remains after a 16. If you do this.....
....for each of the LCD lines it should clear up the problem. |
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...
|