Go Down

### Topic: decimal to binary (Read 1 time)previous topic - next topic

#### pranoy

##### Dec 28, 2012, 04:24 am
hi guys

i am new to arduino so pls help
how can we convert decimal to binary and output it serially through a pin??

#### johnwasser

#1
##### Dec 28, 2012, 04:46 am
By 'decimal' do you mean a number like 23 or a string of digits like "23"?
Send Bitcoin tips to: 1G2qoGwMRXx8az71DVP1E81jShxtbSh5Hp

#### pranoy

#2
##### Dec 28, 2012, 04:47 am
an integer like 23

#### Arrch

#3
##### Dec 28, 2012, 05:13 am
Decimal and binary are simply visual representations of the data; the Arduino doesn't know the difference unless it is trying to store as the visual representation (ASCII). If you want to say, display the binary number 23 on 8 digital pins, then you would simply need to use bitRead() to extract the individual bits and set the pins accordingly.

#### robtillaart

#4
##### Dec 28, 2012, 09:41 am
Quote
how can we convert decimal to binary and output it serially through a pin??

this way - http://arduino.cc/en/Tutorial/ShiftOut -

(and yes there are dozens of other ways)
Rob Tillaart

Nederlandse sectie - http://arduino.cc/forum/index.php/board,77.0.html -
(Please do not PM for private consultancy)

#### AWOL

#5
##### Dec 28, 2012, 10:24 am
Quote
how can we convert decimal to binary and output it serially through a pin???

(Is there something wrong with your "?" key?)

Code: [Select]
`Serial.print (23, BIN);` would seem to me to fit the specification.
"Pete, it's a fool looks for logic in the chambers of the human heart." Ulysses Everett McGill.
Do not send technical questions via personal messaging - they will be ignored.
I speak for myself, not Arduino.

Go Up