hi all my question is in the programming to give a specific pin a name what code would i use? something like this?
#define left_sensor PD0
#define right_sensor PD2
#define right_servo PD3
#define left_servo PD4
or what? sorry if this question has been asked before but i did search and i am a complete novice to programming in all languages :(
thanks in advance,
It depends a lot on how you manipulate that port. I use defines, and specific code to set/clear the pins:
#define LCD_RESET_H (PORTB |= 0x04)
#define LCD_RESET_L (PORTB &= ~0x04)
to set the line low.
To test the state of a line (on port c):
if (( PINC & 0x01) == 0x01)
// Do something
But I'm comfortable with shifting bits, masking, etc in my head. Other programmers prefer writing code in a way that hides these details.
For that matter you can do this:
#define left_sensor (PIND & 0x01)
and in code:
if ( left_sensor )
// do when on
// do when off