Pages: [1]   Go Down
Author Topic: setting digital/analog pins by binary  (Read 471 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 9
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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

Logged

California
Offline Offline
Faraday Member
**
Karma: 88
Posts: 3368
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

PORTB = 64

It's converted to binary upon compilation already.
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 9
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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

Pages: [1]   Go Up
Jump to: