Some of the pins have two or three different functions, you have to check the datasheet and figure out at what function is set the pin on start up. Then you need to enable the function that you want by setting
certain bits to zero or one. Again check the datasheet.
If you check the header file "iom.h", you'll see that PINB0 is defined as the constant 0. So, your condition is never true. So, you cannot use the 1st method. I've attached the header file but I changed the extension to .txt so that you can see for yourself.
// structure to allow bit field operations, name conversions: PORTA.0 -> PORT_A.b0 PORTB.7 -> PORT_B.b7typedefstruct{uint8_t b0:1;uint8_t b1:1;uint8_t b2:1;uint8_t b3:1;uint8_t b4:1;uint8_t b5:1;uint8_t b6:1;uint8_t b7:1;} bits;// define all the ports of your microcontroller#define PORT_A (* (volatile bits *) &PORTA)#define PIN_A (* (volatile bits *) &PINA)#define DDR_A (* (volatile bits *) &DDRA)#define PORT_B (* (volatile bits *) &PORTB)#define PIN_B (* (volatile bits *) &PINB)#define DDR_B (* (volatile bits *) &DDRB)// ...define any other available ports// then you can use like this to write or read specific bits
PORT_A.b0=1;// write value to PORTA bit 0
PIN_B.b4=0;// write value to PINB bit 4
The names used (PORT_A, PIN_A etc) can be changed but you have to use a name that is not defined.
You can also change b0, b1 etc to any other name