digitalWrite()

The most commonly used function on arduino is digitalWrite(), the function used to pull an IO pin high or low. Lets start by taking a look at how we do this on an AVR.

First set the pin to an output as shown in the pinMode() tutorial.

The following code turns pin 5 of port b high:

PORTB |= (1<<PORTB5);

And to turn the output low:

PORTB &= ~(1<<PORTB5);

Simple!