//***********Protocol 12c*************** //MAIN BOARD //Original Code: Luis Alberto Hernández | Fab Lab Queretaro //Update Code: José Manuel Díaz | Fab Lab Anáhuac Puebla //Fab Academy 2022 //SAMD 11C14A #include void setup() { Serial.begin(115200);//begin serial monitor at 155'20 baud Wire.begin(); // join i2c bus (address, optional for Main Board) pinMode(2,OUTPUT);//sets the Built in led as an output pinMode(5,OUTPUT);//GREEN pinMode(8,OUTPUT);//RED pinMode(9,OUTPUT); //BLUE }//close void setup void loop() { while (Serial.available()) { //while the serial monitor is "avaliable" open char c = Serial.read();//read the value typed on the serial monitor and store it on a character variable called "c" //---------------------------------------------ALL OFF--------------- if(c=='O') {//if the variable "c" is equal to the character "O" Wire.beginTransmission(4);//then open comunication to the node on adress "4" Wire.write('O');// write the value "H" to the message to send Wire.endTransmission();//finish transmition of the message Serial.println("Writing to address 4!ALLOF");//print on the serial monitor were have the message sent to }//close first if //------------------------------------------------GREEN--------------- if(c=='G') {//if the variable "c" is equal to the character "G" Wire.beginTransmission(4);//then open comunication to the node on adress "4" Wire.write('G');// write the value "G" to the message to send Wire.endTransmission();//finish transmition of the message Serial.println("Writing to address 4!GREEN");//print on the serial monitor were have the message sent to }//close first if //------------------------------------------------RED--------------- if(c=='R') {//if the variable "c" is equal to the character "R" Wire.beginTransmission(4);//then open comunication to the node on adress "4" Wire.write('R');// write the value "H" to the message to send Wire.endTransmission();//finish transmition of the message Serial.println("Writing to address 4!RED");//print on the serial monitor were have the message sent to }//close first if //-----------------------------------------------BLUE--------------- if(c=='B') {//if the variable "c" is equal to the character "B" Wire.beginTransmission(4);//then open comunication to the node on adress "4" Wire.write('B');// write the value "B" to the message to send Wire.endTransmission();//finish transmition of the message Serial.println("Writing to address 4!BLUE");//print on the serial monitor were have the message sent to }//close first if //------------------------------------- LED PIN#2 HIGH--------------- if(c=='H') {//if the variable "c" is equal to the character "H" Wire.beginTransmission(4);//then open comunication to the node on adress "4" Wire.write('H');// write the value "H" to the message to send Wire.endTransmission();//finish transmition of the message Serial.println("Writing to address 4!Turn On Pin#2");//print on the serial monitor were have the message sent to }//close first if //-------------------------------------- LED PIN#2 LOW--------------- else if(c=='L') {//otherwise check if the value is the charater "L" Wire.beginTransmission(4);//again begin transmision of a message to addres "4" Wire.write('L');//write the character "L" Wire.endTransmission();//finish transmision of the message Serial.println("Writing to address 4! Turn Off Pin #2");//write on the serial monitor were just sent the message }//close second if }//close while }//close void loop