Arduino serial communication

I am using a very simple bit of code to write to a device and get the result back.
i.e. I send ?T and receive xx.xx CR NL
The code is working i.e. sending what I expect to the serial monitor but is this the best way to do?

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
#include <genieArduino.h>   //4d systems touch screen library
 char num=0;
void setup()
{
Serial1.begin(115200)
serial.begin(115200)
}
void loop()
{
Serial1.print("?T")
delay(15);
while(Serial1.available())
num=Serial1.read()
Serial.print(num);
}




serial monitor returns

25.3
25.3
24.4
etc. Which is correct but I want to send this result to a 4D systems touch screen LED DIGGITS by changing the last line to genieWriteObject(GENIE_OBJ_LED_DIGGITS,0x00,num x 100)
Hope above makes sense
Last edited on
Hopefully this documentation helps:
http://old.4dsystems.com.au/downloads/Application-Notes/4D-AN-P4018_ViSi-Genie_Writing_to_Genie_Objects_Using_an_Arduino_Host_REV1.0.pdf

I found this code on page 11:
1
2
3
4
5
//write to a LED digits
genieWriteStr(3, "Leddigits0 at \nvarious states");
for(i = 0; i < 100; i++){
genieWriteObject(GENIE_OBJ_LED_DIGITS, 0x00, i);
delay(100);}

The code above will make Leddigits0 change its state from 0 to 99.
Last edited on
Thanks for the info...Do you think the Arduino side is OK?
The reason I ask is everywhere I turn all example code seems very involved but this simple code seems to do what its supposed to?
Cheers
Are you able to send anything to the 4D systems touch screen LED DIGITS?
Yes.. been playing around today
Basically I receive 25.0 CR LF
as 50 53 46 48 10 13 so I have tried

if (num >=48 && num <=57){
num=num-48 //to only give me numbers and from 0 to 9

and then send to the LED DIGITS but I only get them one at a time i.e. 2 then 5 etc.
Do you know how to combine the 3 numbers so I just print that number?
That genieWriteObject function only writes one integer state to the leddigits a time. My guess is you will have to figure out which states display the digits 0 to 9. Then you can take the
50 53 46
and subtract '0' from them. Yes, it is legal to calculate the difference between int and char. So 50 - '0' would give the result of 2. Then using the correct state you discovered earlier for the digit 2, you would print the number. And changing the 0x00 would write to different leddigits. So instead of writing to leddigits0 (0x00) try writing also to leddigits1 (0x01).
Last edited on
atually that sounds like an good idea
so I could set up 3 led digits (1,2,3) send 2 to the first 5 to the second print a '.' and the final int to 3
I'll let you know how I get on tomorrow
Cheers
Topic archived. No new replies allowed.