# How can I program a microcontroller to read binary?

#### exiton12345

Jan 19, 2013
2
Hello friends,

I have a micro-controller and I want to read binary a digital signal (for instance 111001011).

When I program the micro-controller to read binary I want to take in account the following: I/O, CLK and GND.

The binary information should not be displayed on a screen but it should be written on a memory by this way when I want to see the binary code I can read the memory using a serial connection ... or something else...

By this way if I want to see the binary I can read the memory and see what is there.

Can anyone give am an example or at least give some references, it does not matter what type of micro-controller.

Thanks!!!!

#### GreenGiant

Feb 9, 2012
842
you are rather vague in your question

The binary signal, is it a series signal or parallel? (is it going to be a string of data to one pin or one bit of data on multiple pins?)

How fast are you going to feed it binary numbers?

What do you want to translate it to? (HEX/OCT/base 10/ASCII etc?)

How many data points are you going to want to store for later viewing?

#### sjgallagher2

Jan 27, 2013
17
If you know how long each set is gonna be, all you need is a clock, and the input stream. When the clock is high, record the current input immediately (edge triggered) as a 1 or a 0 and store in a small part of memory. After your set data length is reach cut it, save the full set of binary, and record the next.
There's not much else to say without knowing specifics: What microcontroller do you have? If you don't have one, all you need is something like a PICAXE, cheap and simple. I'll write a code that will record binary, in BASIC.

init:
let b1 = 0
let b2 = 0
let b3 = 0
let b4 = 0
goto main
end
main:
if b0 > 10 then
b1 = 1
endif
pause 100

if b0 > 10 then
b2 = 1
endif
pause 100

if b0 > 10 then
b3 = 1
endif
pause 100

if b0 > 10 then
b4 = 1
endif
pause 100

goto store

goto main

store:
if b0 = 1 then
high 2
pause 100
endif

if b1 = 1 then
high 2
pause 100
endif

if b2 = 1 then
high 2
pause 100
endif

if b3 = 1 then
high 2
pause 100
endif

that is some really choppy non-user-friendly code that is on a constant take input, send output cycle, if you want to use a button or addresses or something to retrieve data then this is the furthest thing from what you want, but you get something of an idea. Also this uses an internal kinda clock, it reads every 100 milliseconds and stores whatever is there. Preferably you will have a clock input. Is this helpful at all?

Replies
0
Views
1K
Replies
2
Views
2K
F
Replies
11
Views
2K
Wouter van Ooijen
W
Replies
8
Views
155
Replies
3
Views
246