Go Down

Topic: setting digital/analog pins by binary (Read 1 time) previous topic - next topic



I've got a little system where one Arduino is controlling another. It does this by communicating in binary over 6 digital pins - D8 to D13 (PORTB), and then two analog pins as digital (A5, A4).

I had a clumsy setup where I was switching on each pin separately, but then I read about using PORTB = Bxxxxxxxx  (where the x's are binary).

So how can I convert a simple decimal number between 1 and, say, 64 - into a binary number I can use with the PORTB command?

And also, what is the port address for Analog pin 5 and 4?




PORTB = 64

It's converted to binary upon compilation already.


Haha! So simple I didn't think of it!  :smiley-yell:

Go Up