Newbie help


I need some help with a few items I need to do.
I need to write a byte out to PortD 0..7 and use PortB 8..9 as a reset and a latch. I want to use the serial port to accept a number from 0 to 255 and -,+ to dec/inc the current value by 1.
I am at a road block right now. It's been a long time since I have written anything in C and this is the first time I have used the Arduino.
I do not see a function to write a byte out a Data Port.
What I would like to see is are some examples so I can learn from them.
Would anyone be able to help point me in the right direction? Another question I have is the use of pointers I don't see anything on that, how do you pass information from one function to anther.


Unless you really need the performance you will find it easier to use the arduino abstractions such as digitalWrite. I posted some code that will write any number of bits to consecutive arduino pins.

See the showBinary function here:

BTW, The standard arduino board does not have all 8 bits of any of the ports free so the abstractions make it easy to write 8 bits spanning two (or more) ports.

Hi Mem,

No I don’t need speed. This project is just to set 8bits and latch it.
Where can I find that code that can manipulate the bits?
Would you know of a way to enter a number and have it converted to a byte?

Can I use the normal C libraries with the Arduino?

Thanks for any help.

The code in the post I linked above can do that. Here is a variation hard coded for 8 bits.

// don't forget to set the pins to outputs before calling this

// function to write a byte to consecut pins with the lsb on the first pin  
void write8bits( byte value, int firstPin)
  for(int bit=0; bit < 8; bit++)
    boolean isBitSet =  bitRead(value, bit); // isBitSet will be true if given bit is set i[b][/b]n this channel
    digitalWrite(bit + firstPin, isBitSet);