Read from digitalRead()

Hi!

I'm doing a project and i had a huge problem I wish you could help me.
The problem is:

I receive from pin 8 of the arduino a message like "hello"

that pin have been defined correctly in the setup.

In the loop i have this:

char val;
val=digitalRead(rxpin);
Serial.write(val);

This write a "hello" but I just want to write a simple character, just one, like 'h' or 'o', I tried doing that:

char val;
val=digitalRead(rxpin);
Serial.write(val[1]); -- It stills write "hello"

How i could do to write just one character of this "hello"?

Thank you to read my problem!

subirana21:
val=digitalRead(rxpin);
Serial.write(val);

This write a "hello" but I just want to write a simple character, just one, like 'h' or 'o', I tried doing that:

your reading a char using digitalRead()?

normally digitalRead() returns high or low.

I know that digitalRead() return a HIGH or LOW, but i could read the "hello" message, and i don't know how to write just a character

I receive from pin 8 of the arduino a message like "hello"

That's a neat trick :slight_smile:

It's a digital pin. Under normal circumstances you won't find a uart attached to it.

So, any solution to read from a pin the string "hello"??

Yes, use SoftwareSerial.

SoftwareSerial? i don't find it in Arduino libraries, where i can find it? and how it works? Thank you!

subirana21:
SoftwareSerial? i don't find it in Arduino libraries, where i can find it? and how it works? Thank you!

you're not looking hard enough.

It took me way less time than the 90 seconds you spent on it.

subirana21:
SoftwareSerial? i don't find it in Arduino libraries, where i can find it? and how it works? Thank you!

Think this through, WHY do you want to read it on pin 8. Why not use the Serial port instead?

Also how are you going to put "hello" on pin 8 in the first place?

How about posting the full code that allows you to get that strange message from pin 8? Then maybe we could understand what is going on and give some useful advice.

And use code tags so

the code looks like this

...R