Go Down

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

tonysnail

Hi!

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?


Cheers!

Carl


Arrch

PORTB = 64

It's converted to binary upon compilation already.

tonysnail

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

Go Up
 


Please enter a valid email to subscribe

Confirm your email address

We need to confirm your email address.
To complete the subscription, please click the link in the email we just sent you.

Thank you for subscribing!

Arduino
via Egeo 16
Torino, 10131
Italy