// Example for GEVINO opto v1.5 // 18/07/2018 Giorgio Evangelista // Install "Arduino SAMD board" // Use Arduino Zero Native Port // github.com/ekstrand/ESP8266wifi // install eeprom library https://github.com/cmaglie/FlashStorage // TEST_SD #include File myFile; #include "gevino_opto_npn_io.h" #define RS485 Serial1 void setup() { testLeds(); SerialUSB.begin(115200); RS485.begin(115200); // RS485 gevino_io_setup(); // TEST_SD - Write file on SD card. SD.begin(SD_CS); myFile = SD.open("example.txt", FILE_WRITE); myFile.close(); // delay(1000); // SerialUSB.print(PORT->Group[PORTA].PINCFG.PMUXEN); } void loop() { char AlternoSerial = 0: if( In1 ) setLed; else resLed; if( In1 || In7 ) setOut1; else resOut1; if( In2 || In8 ) setOut2; else resOut2; if( In3 || In9 ) setOut3; else resOut3; if( In4 || In10 ) setOut4; else resOut4; if( In5 || In11 ) setOut5; else resOut5; if( In6 || In12 ) setOut6; else resOut6; if(SerialUSB) { static unsigned long ms; if (millis() - ms >= 1000){ ms = millis(); if( AlternoSerial ){ SerialUSB.print("I'm happy "); } SerialUSB.println(ms); set_Rs485_TxEn; RS485.print("I'm happy "); // Send at RS485 } } if( RS485.available() ) SerialUSB.write(RS485.read()); if (SERCOM0->USART.INTFLAG.bit.TXC){ //Remove Tx Enable when the last character has been sent out. res_Rs485_TxEn; SERCOM0->USART.INTFLAG.bit.TXC = 1; } }