arduino serial print structure

Solutions on MaxInterview for arduino serial print structure by the best coders in the world

showing results for - "arduino serial print structure"
Sara
18 Jun 2018
1struct Gyro_data_structure
2{
3    char command_name[6];
4    int gyro_X;
5    int gyro_Y;
6    int gyro_Z;
7};
8
9struct Gyro_data_structure Gyro_data = {"Hello", 48, 49 , 50};
10
11int size_gyro = sizeof(struct Gyro_data_structure);
12
13void setup() 
14{
15  Serial.begin(9600); // opens serial port, sets data rate to 9600 bps
16}
17
18void loop()
19{
20  send(&Gyro_data);
21  Serial.println();
22  delay(1000);
23}
24
25void send (const Gyro_data_structure* table)
26{
27  Serial.write((const char*)table, size_gyro);  // 2 bytes.
28}
29
30bool receive(Gyro_data_structure* table)
31{
32  return (Serial.readBytes((char*)table, sizeof(Gyro_data_structure)) == sizeof(Gyro_data_structure));
33}
34