digitalWrite()
function.
But a sketch can change several outputs all at once.
x=4
,
we can write x=B100
.There are 8 bits in a byte. They are numbered right to left so that binary digits correspond to powers of two in the same way decimal digits correspond to powers of ten.
The Atmel processor on Arduino boards has a special place in memory, Port B, that corresponds to I/O poins 8 through 13. Actually there are three locations in memory that relate to those pins. In each location, each bit corresponds to a pin. Bit 0 corresponds to pin 8, 1 to pin 9, etc.
Bits 7 and 8 aren't connected to any pins.
PORTB
. When a program writes
a value to that location, all the bits are sent to the corresponding pins. For example:
PORTB = B000111
would set the pins corresponding to bits 0, 1 and 2 of Port B to HI and light LEDs 0, 1 and 2.
pinMode()
function, a program can set up pins
8 though 13 as ouput all at once with this:
PORTB = B111111
PINB