^ for toggling LED
How to use ^ operator
http://www.eskimo.com/~scs/cclass/int/sx4ab.html
The ^ (caret) operator performs a bitwise exclusive-OR on two integers. Each bit in the result is 1 if one, but not both, of the corresponding bits in the two input operands is 1. For example, 0x56 ^ 0x32 is 0x64:
0 ^ 0 = 0
0 ^ 1 = 1
1 ^ 0 = 1
1 ^ 1 = 0
Thus, PORTB ^= (1 << PB3) toggles the LED because if the LED is on(1) it returns 0, and it is off(0) it returns 1.
Comments are Disabled