Not understanding bitWrite

I'm reading the tutorial for using shift registers 74HC595.

The first code sample I understood without any issue, but i'm struggling to understand the second code sample.

One of the instructions is bugging me!

I'm not able to understand what bitWrite does (and the comment on the program is not helping me...) :frowning:

// turn on the next highest bit in bitsToSend:
bitWrite(bitsToSend, whichPin, whichState);

I've already looked at the arduino reference (http://arduino.cc/en/Reference/BitWrite) but that didn't make it either...

Can anyone explain me in more detail?

Thanks!

bitwrite takes three arguments:

  1. the variable to modify
  2. the number of the bit in that variable that is to be modified
  3. what value (1 or 0) to give that bit, i.e. what we should write

In that particular example, only one of the bits is to be set depending on which ascii numeric was sent on the serial port.

Got it now, with your help!

Thanks!