Hey, this is my first time doing this, please be gentle. I only say this because there are some condescending unhelpful assholes floating around coding forums from what i've seen.
Anyway, please hear me out, i'll keep it as short as possible:
This is a program that allows me to communicate with a hc05 bluetooth serial terminal app on my phone (and physical module) and write anything I type on the lcd. (The following program works):
#include <LiquidCrystal.h>
const int rs = 12, en = 11, d4 = 5, d5 = 4, d6 = 3, d7 =2;
LiquidCrystal lcd(rs,en, d4, d5,d6, d7);
void setup()
{
//DONT CHANGE!!!!!!!!!!!
//16 rows 2 columns
lcd.begin(16,2);
Serial.begin(9600);
}
void loop()
{
if(Serial.available())
{
delay(100);
lcd.clear();
while(Serial.available()>0)
{
lcd.write(Serial.read());
}
}
}
I'm trying to modify this program so that I can write on both lines.In other words, if you type the alphabet, you'll see the first line ends with 'p' and the next line begins with 'q'. (I think the second line is known as (0,1)). So I wrote the following program to help me do this, and I didn't get any errors, but the lcd was totally blank after I uploaded the code and started typing. I DO NOT have an I2C (module or LCD?), which I've heard might make this kind of thing easier. My exact LCD is a 16x2,16 pin, QAPASS 1602A module and I've heard there is a thing about it's cg (or some other kind of) RAM "addresses" which makes it so that the second row might be 0,1, but also goes from 40, 41 , 42 .. 49, 4A, 4B..
I wrote the whole thing in a comment in the following code, but the rest of the comments are kind of nonsense, so you might want to ignore those.
Thank you so much for giving your time into helping me! I'll reply with more details if you need them.
So this is my problem-program (again, no errors, just a blank lcd screen):
//#include <LiquidCrystal_I2C.h>
//lcd.blink makes the cursor blink
//lcd.cursor or lcd.nocursor
#include <LiquidCrystal.h>
const int rs = 12, en = 11, d4 = 5, d5 = 4, d6 = 3, d7 =2;
LiquidCrystal lcd(rs,en, d4, d5,d6, d7);
String thing = (Serial.readString());
char* k = (Serial.read());
// []^^^^^
// pretty basic, but how do you do the whole char array for a string? is this right?
// char um[] = { '00', '01', '02', '03','04','05','06','07','08','09', '0A','0B','0C','0D','0E','0F'};
// char umm[] = { '40', '41', '42', '43','44','45','46','47','48','49', '4A','4B','4C','4D','4E','4F'};
//the goal is to assign these to my 0 - 16 , 17 -length() for loops i guess? ^^^
//abcdefghijklmnop qrstuvwxyz
// cut off at 10 to 16
//try changning to const int?
void setup()
{
//16 rows 2 columns
lcd.begin(16,2);
Serial.begin(9600);
}
void loop()
{
if(Serial.available())
{
delay(100);
lcd.clear();
while(Serial.available()>0)
{
//lcd.write(Serial.read());
// ^^okay seriously consider adding this back
if((thing.length()) > 16)
{
//______________________________________
//char k[] = serial.read |
//string thing = serial.readstring |
//______________________________________|
//lcd.clear();
//^^ maybe put this in?
for(int j =0; j<=16;j++)
{
//(set cursor 0,0?)
lcd.write(k[j]);
//lets say its 21 characters
}
for(int o = 17; o< ((thing.length())-(16)); o++)
{
//i guess not 40
lcd.setCursor(0,1);
lcd.write(k[o]);
}
}
}
}
}