Hello! I have been struggling to get my Arduino to communicate with a 4d Systems display. I have a Visi Genie Program made up to display a price, amount of product dispensed, and total cost. The code I have been writing is just trying to take an inputted number from the Serial Monitor and display it in the price portion of the display. I have already changed the inputted number into an integer variable. I just can't seem to get the object on the screen to change. I know that these displays aren't a specialty of this forum, but I thought maybe the code is the issue. Any help would be much appreciated. Thanks.
#include <genieArduino.h>
Genie genie;
#include <SoftwareSerial.h>
SoftwareSerial mySerial(2,3);
#define RESETLINE 4
const byte numChars=5;
char receivedChars[numChars];
boolean newData=false;
int price;
void setup() {
Serial.begin(9600);
while(!Serial){
;
}
mySerial.begin(9600);
genie.Begin(mySerial);
pinMode(RESETLINE, OUTPUT);
digitalWrite(RESETLINE, 1);
delay(100);
digitalWrite(RESETLINE, 0);
delay(3500);
genie.WriteContrast(7);
genie.WriteStr(0, GENIE_VERSION);
Serial.println("Charging Ready");
Serial.println("How much is it?");
}
void loop() {
recvWithEndMarker();
showNewData();
genie.WriteObject(GENIE_OBJ_LED_DIGITS,0,price);
}
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';
ndx=0;
newData=true;
}
}
}
void showNewData(){
if(newData==true){
Serial.print("New price is $0.");
price = atoi(receivedChars);
Serial.println(price);
genie.DoEvents();
newData = false;
Serial.println("Has the price changed?");
}
}