Hi I am new to electronics and uC, here is a tutorial I came across and play around with the code, and I find out:
My program is simply turn a LED on when button is pressed, and turn a LED off again when the button is pressed again, the program is running in a stk500.
Can someone explains it please?
full code is attached
- I don't have to set a port as input, and it can still act as an input port;
- And there is no different if I turn on internal pull-up resistor or not, my program still function as normal
My program is simply turn a LED on when button is pressed, and turn a LED off again when the button is pressed again, the program is running in a stk500.
Can someone explains it please?
Rich (BB code):
#define INPUT_PORT PORTD
#define INPUT_DDR DDRD
#define INPUT_PIN PIND
#define INPUT_BIT PD0
INPUT_DDR &= ~(_BV(INPUT_BIT)); //set as input
INPUT_PORT |= _BV(INPUT_BIT); // turn on internal pull-up resistor for the switch
Attachments
-
1.4 KB Views: 7