I have been working on this for hours and have no idea where the issue is…
So I have the following code…which when I type a letter into the Serial Monitor I get the binary code for that letter on my LCD Screen…
#include <Adafruit_CharacterOLED.h>
Adafruit_CharacterOLED lcd(6, 7, 8, 9, 10, 11, 12);
void setup()
{
// Print a message to the LCD.
Serial.begin(9600);
lcd.begin(16, 2);
}
void loop() {
char TestData;
if(Serial.available() )
{
TestData = Serial.read();
lcd.setCursor(0, 0);
lcd.print (TestData, BIN); // echo the incoming character to the LCD
}
}
The issue I am having is, how do I then convert the text from either BIN or HEX or some other ASCII code to literal TEXT…
I have tried leaving the lcd.print
as simply lcdprint (TestData)
because then it should return just the VAL
of the input but it does not, it gives me a few weird symbols and then turns off…Like something is wrong
I also need to then figure out Char Arrays but Ill get to that once I figure out how to display a freakin LETTER
EDIT:
https://vimeo.com/61851351 This is video of what of comparison of lcd.print (TestData, BIN);
vs lcd.print (TestData);
Per the last comment the follow works as expected:
#include <Adafruit_CharacterOLED.h>
Adafruit_CharacterOLED lcd(6, 7, 8, 9, 10, 11, 12);
void setup()
{
// Print a message to the LCD.
Serial.begin(9600);
lcd.begin(16, 2);
lcd.setCursor(0, 0);
char TestData='X';
lcd.print(TestData);
}
void loop() {
char TestData;
if(Serial.available() )
{
TestData = Serial.read();
lcd.setCursor(8, 0);
lcd.print (TestData, BIN); // echo the incoming character to the LCD
}
lcd.setCursor(0, 1);
int charcode = 65;
lcd.print(charcode);
}
Best Answer
To recap what was done to partially solve the problem:
lcd.print("Hello, World");
worked OK insetup()
print(char);
in setup: that worked fine. The conclusion from this was that something was going wrong in theloop()
delay(1000);
inside loop(): now the characters showed up correctly on the OLED display.This suggests that
Serial.available()
was always returning non-zero for some reason, so that is something that still needs to be looked at. Most likely the characters coming in from the serial port were spaces since most of the time nothing was visible on the OLED display.