arduino serial lcd only if serial msg start with ";" - Page 1
Forum section: electronics / general

author: xal3xhx
author_rank: Newbie
timestamp: November 21, 2014, 10:28:13 pm
content: i'm working on a project with a ITEADUINO BT. It is an arduino with built in Bluetooth. I have it setup to wireless receive serial input. So just like if I had it plugged into the computer and sending data over serial with serial monitor. I want to be able to print text to a LCD from the serial but only if the text starts with a set symbol like ":" or ";" and than print what is after that without the symbol. For example I want to send ":hello!" on the serial monitor and the LCD should read "hello!" I also want it to store it in memory so when power is dis-connected and plugged back in the LCD will print the same thing you set it to before you unplugged it. If needed I could also use a SD shield to store data if that's easier. I also need to do this with many parts of the code so ":" would print to the LCD and ";" would change another thing. I am hope this is possible and not to hard to do. i don't know what to do or were to start.

author: Bukurat
author_rank: Regular Contributor
timestamp: November 22, 2014, 01:46:39 am
content: It appears to me that you know when you want but not how to write the code to make it happen.How much experience have you had writing code? Do you want a pseudocode example or an arduino sketch?If you have a fixed set of characters that act as commands when they appear at the beginning of a string, one way would be to strip the first character out of the string and run it through a case statement. If it matches the characters in the case statement do whatever. If it doesn't, do the default, repeat.

author: dannyf
author_rank: Super Contributor
timestamp: November 22, 2014, 02:02:37 am
content: QuoteIt is indeed possible and not hard to do if you know what to do.QuoteThen, it may not be possible / very difficult for you to do.If I were you, I would start from something far simpler and go from there.

author: xal3xhx
author_rank: Newbie
timestamp: November 22, 2014, 02:34:34 am
content: Quote from: Bukurat on November 22, 2014, 01:46:39 amI have basic knowledge of code (if, else, ext) but not that good. I'm trying to learn more. If u can i would like a arduino sketch example plz.

author: MuTeD
author_rank: Contributor
timestamp: November 24, 2014, 02:21:33 pm
content: What you are asking for is fairly easy. However I won't just hand you the C code, what will you learn out of that? Basically what it comes down to is reading char, checking if it is : or ; (with an of or switch case) and then just printing char[1:end]. Could you provide examples of what you tried? Did you Google similar problems? You can easily google how to write stuff to flash. I won't hand you the solution but if you run into a specific issue, I'll gladly help =).

author: MuTeD
author_rank: Contributor
timestamp: November 24, 2014, 02:27:34 pm
content: Sorry for the double post. But I think in your case you should try getting some experience programming in C first. A very nice guide ishttp://beej.us/guide/bgc/but I'm sure there are lots of others. I believe it is useful go through a C tutorial first and understand the language before programming embedded devices. This will also help for debugging later (identifying if it is a software or hardware problem). You can easily practice programming C on a normal PC without an Arduino. In fact it might be useful to write your program on a PC first and then porting it onto the Arduino.

author: xal3xhx
author_rank: Newbie
timestamp: November 25, 2014, 12:42:43 am
content: Quote from: MuTeD on November 24, 2014, 02:21:33 pmI looked online and did some research and got the serial being stored in a char and working with a if statement but cant get it to print it to the lcd and i dont know how to clear the char.Code:#include <LiquidCrystal.h>LiquidCrystal lcd(12, 11, 5, 4, 3, 2);char inData;char inChar;byte index = 0;void setup(){lcd.begin(16, 2);Serial.begin(9600);}void loop(){while(Serial.available() > 0){if(index < 19){inChar = Serial.read();inData = inChar;index++;inData = '\0';}if(inData == ':') {lcd.print(inData);}inData == 0;}}