#include // Import the Orbicraft Construction Set control library /* * Declare the msg variable as the Message data type * Message comprises a structure that contains IDs and transferred message content */ Message msg; /* * Declare the bus variable as the OrbicraftBus data type * OrbicraftBus is a class describing interaction between Arduino and Orbicraft construction set bus */ OrbicraftBus bus; // Declare the msgSize variable to hold the size of the received message uint16_t msgSize = 0; void setup() { Serial1.begin(9600); // Define data transfer rate over Serial1 (Check Serial2.begin(9600)) } void loop() { msgSize = bus.takeMessage(msg); // Try to read the message using the takeMessage method if (msgSize > 0){ //If there is a messageā€¦ switch (msg.id){//Process in a particular manner depending on message ID // Consider the case with ID 1 case 0x01: turnOnLed(); // Call the function for turning the LED on and off break; } } } void turnOnLed(void){ digitalWrite(LED_BUILTIN, HIGH); //Turn on the built-in LED delay(3000); //Wait 3 seconds digitalWrite (LED_BUILTIN, LOW); //Turn off the built-in LED } /* * The following block of code must always be appended to the program. * The function is called automatically and is necessary for message processing. */ void serialEvent2() { bus.serialEventProcess(); }