Show Posts
Pages: [1]
1  Using Arduino / Programming Questions / Re: what's means about "PINB |= 1<<5" on: November 17, 2012, 03:42:11 pm
thank for your answer firstly.

as you said :Writing a logic 1 to a bit in the PINx register of many atmegas results in the corresponding output toggling its state.

how to understand "output toggling its state"?  below understanding is right or not?
the PINB13 keeps output mode, the LEDPIN_TOGGLE marco reverse the value in the PINB13?
2  Using Arduino / Programming Questions / (solved)what's means about "PINB |= 1<<5" on: November 17, 2012, 02:51:55 pm
when I read the code in multiwii source (got from ''). there exist such code in the def.h file:
 #define LEDPIN_PINMODE             pinMode (13, OUTPUT);
  #define LEDPIN_TOGGLE              PINB |= 1<<5;     //switch LEDPIN state (digital PIN 13)
  #define LEDPIN_OFF                 PORTB &= ~(1<<5);
at them same time, there exist below statements in MultiWii_1_9.pde file:
 for (r=0;r<repeat;r++) {
    for(i=0;i<num;i++) {
      LEDPIN_TOGGLE; //switch LEDPIN state

my question is: the PB13 is output mode, why the LEDPIN_TOGGLE macro is valid?
thank you.
Pages: [1]