Hello, I connected the swiches to Port C and Config PortC = Input. The programm shall show me a binary and decimal number to detect which switch is pressed down. Dim deci as integer Dim binar as byte 'configuration of the display: I did not write it down here, because the display is working correctly. do upperline lcd deci lowerline lcd binar loop If you see a mistake, I thank you for any help
Frank wrote: > The programm shall show me a binary and decimal number to detect which > switch is pressed down. Then you schould read the input port inside your loop. > Dim deci as integer > Dim binar as byte I'm sure, the name of a variable has no influence, how it was displayed. Peter
ok, but if I add "deci = portc" and "binar = portc" into the loop, the display shows only a "0" and does not change, when I press a switch.
Hi Frank, your problem is verry simple. If you want to write a byte value to PORTC you have to configure the data direction (DDRC=0xFF) as output and write data to PORT register. But if your PORT is configured as input (DDRC=0x00)the PORT register will enable/disable the internal pull up resistor. If you want to read in external values you have to read pin register (PINC). Summary: 1. data output DDRC = 0xFF, write data to PORTC 2. data input DDRC = 0x00, PORTC = 0x00(pull up resistors disabled), read data from PINC Your loop should be: "deci = PINC" and "binar = PINC" Greetings Alexander
Please log in before posting. Registration is free and takes only a minute.
Existing account
Do you have a Google/GoogleMail account? No registration required!
Log in with Google account
Log in with Google account
No account? Register here.