I am using an Arduino with a cellular module as a "modem" for my computer. I send it data via txt message.
The code successfully recognizes incoming characters and takes action, however I need it to store the text message "text" in an array that I can use. The code does everything correct except generate the array. I have included the code, I have a hunch that it's something to do with either where/how the storeData function is called OR the for loop I use to store data. Please take a look! Thanks so much
import processing.serial.*;
import processing.net.*;
//Serial Variables
Serial myPort; // the serial port you're using
String portnum; // name of the serial port
String inString = ""; // the string coming in from the serial port
Hello all, I am using the following code to display incoming data from an Arduino from my Serial Port. I have tried a dozen ways to parse through this data looking for the word "Good" in order to trigger an action, however I can't figure it out.
Can someone propose a way to parse the incoming data and find "Good". Here is the format of the incoming data:
+CMT, "xxxxxxxxx"
Good
Here is the code:
import processing.serial.*;
Serial myPort; // the serial port you're using
String portnum; // name of the serial port
String outString = ""; // the string being sent out the serial port
String inString = ""; // the string coming in from the serial port
int receivedLines = 0; // how many lines have been received in the serial port
int bufferedLines = 10; // number of incoming lines to keep
void setup() {
size(600, 800); // window size
// create a font with the second font available to the system:
PFont myFont = createFont(PFont.list()[2], 14);
textFont(myFont);
// list all the serial ports:
println(Serial.list());
// based on the list of serial ports printed from the
//previous command, change the 0 to your port's number:
portnum = Serial.list()[1];
// initialize the serial port:
myPort = new Serial(this, portnum, 9600);
}
void draw() {
// clear the screen:
background(0);
// print the name of the serial port:
text("Serial port: " + portnum, 10, 20);
// Print out what you get:
text("typed: " + outString, 10, 40);
text("received:\n" + inString, 10, 80);
}
void serialEvent(Serial myPort) {
// read the next byte from the serial port:
int inByte = myPort.read();
// add it to inString:
inString += char(inByte);
if (inByte == '\r') {
// if the byte is a carriage return, print
// a newline and carriage return:
inString += '\n';
// count the number of newlines:
receivedLines++;
// if there are more than 10 lines, delete the first one: