digitalWrite()

what i want to know is how do i control wheather it sets the bit to 5v or 3.3v

By the type of board you buy. A 5V board gets 5V on the pin. A 3.3V board gets 3.3V on the pin.