Hello, in the past, I have received help from wonderful people on this forum. They helped me with my code on making an LED Sign working with bluetooth. I have since lost this file, and cannot retrieve it. However, I have a little older copy left. The only problem that it has is that, when sending a line through an HC-06 bluetooth, only the last character appears on the LED Sign. Everything else works flawlessly. I have attempted to recreate the better code, but have failed. I do not see where my issue lies. Everything uploads perfectly fine, however, as stated, only the last character of the entire message I send via an app on my phone, will appear on the LEDS.
I have attached the code in both .ino and .txt for you guys.
I would really appreciate it if you can help me.
Thank you,
Kevin.
signtest.ino (18.9 KB)
signtest.txt (18.9 KB)
Still in need of help, thanks. <3
Your recvWithEndMarker() function incorrectly sets ndx to 0 during the reading..
void recvWithEndMarker() {
static byte ndx = 0;
char endMarker = '\n';
char rc;
while (Serial1.available() > 0 && newData == false) {
rc = Serial1.read();
if (rc != endMarker) {
// ndx = 0; //error in code
// receivedChars[ndx] = '\0'; //immediately overwritten and not doing anything
receivedChars[ndx] = rc;
ndx++;
if (ndx >= numChars) {
ndx = numChars - 1;
}
}
else {
receivedChars[ndx] = '\0'; // terminate the string
ndx = 0;
newData = true;
}
}
}
Compare your code carefully with Robin2's example of recvWithEndMarker() example
void recvWithEndMarker() {
static byte ndx = 0;
char endMarker = '\n';
char rc;
while (Serial.available() > 0 && newData == false) {
rc = Serial.read();
if (rc != endMarker) {
receivedChars[ndx] = rc;
ndx++;
if (ndx >= numChars) {
ndx = numChars - 1;
}
}
else {
receivedChars[ndx] = '\0'; // terminate the string
ndx = 0;
newData = true;
}
}
}
Thank you for leading me in the right direction and ultimately helping me solve my own problem. I really do appreciate it. However, I am now getting a different problem. When I type a long list of words, it starts cutting out completely or it misspells things. For example, if i write "Hello, my name is revengedeath and this code is working pretty well and i love it to death." or whatever, it will misspell some words or completely cut out at some point. I have set the buffer length for the char's of receivedChars to 500 and 3000, but it doesn't make any difference. By the way, I'm using an Arduino Mega, if that's relevant.
Thank you.
However, I am now getting a different problem. When I type a long list of words, it starts cutting out completely or it misspells things. For example, if i write "Hello, my name is revengedeath and this code is working pretty well and i love it to death." or whatever, it will misspell some words or completely cut out at some point.
For assistance I believe that you are going to have to provide an MVCE ("Minimal, Verifiable, Complete, Example"). Your current code is just too complex and lengthy for me.