Keyboard text to binary output

Hello,

Can you please help me with the following;

Using an UNO

I want to be able to enter text, ideally in real time and have one of the digital outputs generate a binary signal.

Simply put, typing ASCII 'Hello' would output to a digital output something like ' 01101000 01100101 01101100 01101100 01101111'

Has someone written some code for this?

Thank you very much,
Jeremy.

Welcome to the forum

What have you tried so far ?

HINT : the bitRead() function, as its name suggests, allows you to read the state of a bit in a byte

What keyboard? What Arduino?

How will they be connected?

What will the output pin be connected to?

Don't you want to write some code for this?

My tip would be: use shiftOut() function.

all values are binary -- it's simply how you display them. an ASCII char represents 8 bits, 8 ASCII chars are needed to represent the same value in binary "format" as '0' and '1' ASCII characters

consider

01101000 01100101 01101100 01101100 01101111 00100000 01110111 01101111 01110010 01101100 01100100 
00110100 00010010 
// output ASCII in binary

// -----------------------------------------------------------------------------
void formatBinary (
    char  *buf,
    int    nByte )
{
    for (int n = 0; n < nByte; n++, buf++)  {
        for (unsigned b = 0; b < 8; b++)  {
            if (0x80 & *buf)
                Serial.print ("1");
            else
                Serial.print ("0");
            *buf <<= 1;
        }
        Serial.print (" ");
    }
    Serial.println ();
}


// -----------------------------------------------------------------------------
void setup (void)
{
    Serial.begin (9600);

    char s [] = "hello world";
    formatBinary (s, strlen(s));

    int  val = 0x1234;
    formatBinary ((char*) &val, sizeof(val));
}

// -----------------------------------------------------------------------------
void loop (void)
{
}

Hello, thank you so much for the reply. How would I go about using the Arduino for both ASCII to binary output and as well as binary on analog in to ASCII? Is there a way to do it within the development environment? Has anyone done it before? Surely someone has used an arduino for two way binary communications? Thank you!!


KEYBOARD (PC CONNECTED TO ARDUINO USB) ----- > BINARY OUT - TO ANALOG TRANSMITTER

ANALOG SIGNAL WITH BINARY ------ > ARDUINO ANALOG IN? DISPLAY ON PC CONNECTED VIA USB (RECEIVER).


What is an "analog transmitter"? Transmit over what medium, light?, radio?, sound? What hardware do you plan to use?

Why do you want to do this? Is it a school assignment? As asked previously, what have you tried?

USING UPPER CASE LETTERS IS A FORM OF SCREAMING, ONLINE.

of course. The Arduino uses a serial interface to download programs and print characters on the serial monitor (using ASCII format of course).

and of course, Arduinos with multiple serial interfaces (i.e. Mega) can communicate between one another.

and of course, the serial interfaces can be used with IR (infra red) LEDs and receivers to communicate, or electrical RS-485 transceivers over longer distance and between multiple (~64) devices or using WiFi

what are you hoping to do?

Hello,

I am trying to make a packet radio type of thing where I can use an arduino to send and receive data. I was hoping to be able to type on my PC keyboard connected via USB to the arduino and have it output the typed words into binary then send the using radio and vice-versa at the other end. Using a single arduino at each end that can send/receive at each end and display on the laptop screen at each end. Perhaps a couple of small dialog boxes on each laptop with transmitted words and received words. It is for a second year uni project. Thank you very much!

Please answer the questions we ask. Do you have radio hardware? Have you looked for it? Does the project "do" something, or is it just a demonstration?

Now you mention that it must send and receive. Are there any more important details you forgot to mention? As a new forum member, your post count is limited in the first 24 hours...

See how little you told us in the first post...

Have you done any research?

May I suggest you first purchase commercially available equipment and get it working. THEN duplicate that system with your Arduino project? Do you have a license that allows you to use packet radio?

I'm 100% sure OP doesn't know what that "packet radio" is.

No, but could be a way to begin learning.

Sure, yeah. It might even be found during the research. We're talking second year uni.