# serial binary data

I would like to write a script that enables me to display a number (base 10) on an lcd by reading a serial binary data output from a 74HC14 hex inverter. How can I go about this?

Thats a Schmitt trigger input inverter

What format is the serial binary data in?

The serial data is 0 or 5 volt random digital (0 and 1) clocked at 0.1 sec, do I need to create a buffer from this stream and read?

10 baud? What is transmitting data that slow? A submarine? A space probe out past Pluto?

It sounds like you need to read up on the basic principles of asynchronous serial. Mostly you need to look for a starting transition (the start bit) and start a timer. The timer is used to then look at the digital value in the centre of the assumed following bits.

The Arduino serial might work at 10 baud. I haven't looked at the datasheet to check. Otherwise it's pretty easy to do the timing yourself using the millis() function for that slow speed.

Of course the word "Serial" might not represent what you're trying to do. You might be looking at the time of the data transitions, like counting grains of rice or something. That's not "serial" at all.

It is a random number generator, and an RC timing circuit determines the baud rate - 10K resistor and a 1uF capacitor = 0.1 Sec clock

you may find the circuit here:

http://makezine.com/projects/really-really-random-number-generator/

I would like to read and output to an LCD.

OK, so it's not serial data. There's no start and stop bits.

I assume you're only using the front end of that Make project and aren't using the shift register? Then just create an Arduino sketch to read on a defined time period (like 0.1 sec) and assemble the data into bytes there.

``````const int INPUT_PIN = 13; //Random bit generator is connected to Arduino pin 13.
const unsigned long TIME_PERIOD = 100; //milliseconds - the time between each sample
const int BITS_TO_OUTPUT = 8; //we may want to change to 16-bit ints in the future?
void setup() {
// put your setup code here, to run once:
Serial.begin(9600);
}

void outputResult(byte b) {
//print out the result byte
//this may be changed in the future to go to an LCD
//but for now we use the serial monitor
Serial.println(b, DEC); //print in base 10
}

void loop() {
// put your main code here, to run repeatedly:
static unsigned long LastSampleTime = 0;
static byte Output = 0;
static byte BitPosition = 0;
if(millis()-LastSampleTime >= TIME_PERIOD) {
//find out what the input is doing
//add that to the correct position of the output
//uses binary-or (|) to just change one bit
if(In==HIGH) Output = Output | bit(BitPosition);
BitPosition++;
if(BitPosition >= BITS_TO_OUTPUT) {
//we've finished this byte - send it out
outputResult(Output);
//now reset for the next byte
Output = 0;
BitPosition = 0;
} //else not finished for this byte yet
LastSampleTime += TIME_PERIOD;
} //else it's not time to sample the input

//other code can go here.
}
``````

Huzzah! It works! Thank you MorganS!

I guess I had the wrong definition of what is serial data...

I have much to learn before sending a probe to pluto.

encrypted_toast: Huzzah! It works! Thank you MorganS!

Wow, that was quick.

Huzzah for MorganS!