Pages: [1]   Go Down
Author Topic: decimal to binary  (Read 616 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Jr. Member
**
Karma: 0
Posts: 76
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

hi guys


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

Massachusetts, USA
Offline Offline
Tesla Member
***
Karma: 212
Posts: 8967
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

By 'decimal' do you mean a number like 23 or a string of digits like "23"?
Logged

Send Bitcoin tips to: 1L3CTDoTgrXNA5WyF77uWqt4gUdye9mezN
Send Litecoin tips to : LVtpaq6JgJAZwvnVq3ftVeHafWkcpmuR1e

Offline Offline
Jr. Member
**
Karma: 0
Posts: 76
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

an integer like 23
Logged

California
Offline Offline
Faraday Member
**
Karma: 92
Posts: 3442
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.

I feel like you've asked this before and we already answered it.
Logged

Global Moderator
Netherlands
Offline Offline
Shannon Member
*****
Karma: 224
Posts: 13917
In theory there is no difference between theory and practice, however in practice there are many...
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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)
Logged

Rob Tillaart

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

Global Moderator
UK
Offline Offline
Brattain Member
*****
Karma: 309
Posts: 26528
I don't think you connected the grounds, Dave.
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
how can we convert decimal to binary and output it serially through a pin???
(Is there something wrong with your "?" key?)

Code:
Serial.print (23, BIN);
would seem to me to fit the specification.
Logged

"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.

Pages: [1]   Go Up
Jump to: