Buy an Axon, Axon II, or Axon Mote and build a great robot, while helping to support SoR.
0 Members and 1 Guest are viewing this topic.
void ioinit (void){ //1 = output, 0 = input DDRB = 0b11111111; //All outputs DDRC = 0b11111111; //All outputs DDRD = 0b11111110; //PORTD (RX on PD0)}
PORTC = 0xFF;PORTB = 0xFF;PORTD = 0xFF;PORTC = 0x00;PORTB = 0x00;PORTD = 0x00;
im assuming "DDRB = 0b11111111; DDRC = 0b11111111;" means that anything related to PB0 - PB7 and PC0 - PC7 are going to be ouput functions? And "DDRD = 0b11111110;" means PD0 - PD6 are going to be output but PD7 is going to be input?
does the "PORTB = 0xFF;" mean to set all output pins in array B(defined by "DDRB = 0b11111111;) to high?
ohhh ok, so "DDR[C - D] followed by 0b and 0s and 1s determines its role, and PORT[C - D] followed by 0x and up to 2 hex digits sets its high/low status? does the PORT[C - D] have to be followed by 0x[hex] or can it also be 0x[bin]? Basically im asking if they're interchangeable and that C will recognize them if theyre used wherever.
so if I had in my program DDRB 0b00000001, only pin B7 would be output and the rest of the B array would input right? so then could I then say in my program, PORTB 0x00000001 so that B0 - B6 stay low and B7 start outputting high(5v?) or would it have to be 0x1 for that?
DDRB = 0b11111111; // all outputsPORTB = 0b00000001; // B0 - B6 set low and B7 high
DDRB = 0xFF;PORTB = 0x01;
DDRD = 0xFF;PORT_OFF(PORTD, 4);PORT_ON(PORTD, 0);