void setup() { Wire.begin(); if (debugSerial){ Serial.begin(115200); Serial.println(F("=================== SETUP =================")); } // initialize device if (debugSerial && debugMPU6050) Serial.println(F("Initializing I2C devices...")); accelgyro.initialize(); // verify connection if (debugSerial && debugMPU6050) { Serial.println("Testing device connections..."); boolean OK = accelgyro.testConnection() ; ( OK )? Serial.println(F("MPU6050 connection successful")): Serial.println(F("MPU6050 connection failed")); } if (debugSerial){ Serial.println(F("=============== FIM SETUP =================")); } }
void parseRequest(const char* line) { readingRequest = false; int code = parseNumber(line); switch(code) { case POSITION: //return position Serial.write('X'); Serial.write( ((double)axis[0].position) / PULSES_PER_MM); Serial.write('Y'); Serial.write( ((double)axis[1].position) / PULSES_PER_MM); Serial.write('Z'); Serial.println( ((double)axis[2].position) / PULSES_PER_MM); break; case DESTINATION: //return destination Serial.write('X'); Serial.write( ((double)axis[0].expected) / PULSES_PER_MM); Serial.write('Y'); Serial.write( ((double)axis[1].expected) / PULSES_PER_MM); Serial.write('Z'); Serial.println( ((double)axis[2].expected) / PULSES_PER_MM); break; case PAUSE: serialSleepDelegate(); break; case CONTINUE: serialWakeDelegate(); break; } }
void loop() { sendMsg = ""; recvMsg = ""; while (Serial.available()) { sendMsg += (char)Serial.read(); delay(2); } if(sendMsg.length() > 0) { mySerial1.println(sendMsg); Serial.print("I send: "); Serial.println(sendMsg); } while (mySerial2.available()) { recvMsg += (char)mySerial2.read(); delay(2); } if(recvMsg.length() > 0) { Serial.print("I recv: "); Serial.println(recvMsg); } //delay(20); }
void setup() { Serial.begin(115200); nss.begin(9600); pinMode(10, OUTPUT); pinMode(GREEN_LED, OUTPUT); pinMode(RED_LED, OUTPUT); Serial.println("Iniciando..."); if (!SD.begin()) Serial.println("SD Erro!"); }
/*** * SerSend [hard | soft] [port] * * After this command, each character sent is mirrored to the chosen serial * port until the NULL character (0x00) is sent (also mirrored) */ void cmdSerSend(char **argV) { boolean isSoftSerial = (strcasecmp(argV[1], "soft") == 0); int currPort = strtol(argV[2], NULL, 10); Serial.println(doneString); if (currPort < 1 || currPort > ((isSoftSerial)? SOFT_SER_MAX_PORTS : HARD_SER_MAX_PORTS)) { return; } if (isSoftSerial) { #ifdef USE_SOFTWARE_SERIAL softSerDescs[currPort-1].txMsgLen = 0; #endif } // mirror the hardware serial and the software serial while (true) { if (Serial.available()) { char c = Serial.read(); if (isSoftSerial) { #ifdef USE_SOFTWARE_SERIAL softSerDescs[currPort-1].txMsg[softSerDescs[currPort-1].txMsgLen++] = c; #endif } else { #if HARD_SER_MAX_PORTS > 0 hardSerHandler[currPort-1]->write(c); #else return; #endif } if (c == '\0') { // acknowledge Serial.println(doneString); delay(10); #ifdef USE_SOFTWARE_SERIAL if (isSoftSerial) { // send the message, and remember the answer for (int i = 0; i < softSerDescs[currPort-1].txMsgLen; i++) { softSerDescs[currPort-1].handler->write(softSerDescs[currPort-1].txMsg[i]); } softSerDescs[currPort-1].rxMsgLen = 0; while (!Serial.available()) { if (softSerDescs[currPort-1].handler->available() && softSerDescs[currPort-1].rxMsgLen < SOFT_SER_MSG_SIZE) { softSerDescs[currPort-1].rxMsg[softSerDescs[currPort-1].rxMsgLen++] = softSerDescs[currPort-1].handler->read(); } } } #endif return; } } } }
void Node::ajuste_pinos(){ if (sizeof(this->comandos) > 0 ){ if(this->_debug) Serial.println("Ajustando pinagem: "); for (int i = 0; i < sizeof(this->comandos)-1; i++){ pinMode(this->comandos[i].pino, OUTPUT); if(this->_debug) Serial.print(this->comandos[i].pino+" "); }; if(this->_debug) Serial.println("Fim de Ajuste."); } }
void GetDataSpace::execute (HardwareSerial& stream, McuState&) const { unsigned char* ptr = (unsigned char*)address; unsigned char value = *ptr; char response[MAX_NUMBER_LENGTH]; Utils::toDecimal (response, sizeof (response), value); stream.println (response); }
void loop() { bool newData = false; unsigned long start = millis(); while (millis() - start < 1000) { while (nss.available()) { if (gps.encode(nss.read())) newData = true; } } if (newData) { if (gps.hdop() < MAX_HDOP) signal_fixed_status(); else signal_instable_status(); if (!gps_filename) { gps_filename = create_gps_file(); } String line = create_gps_line(); gps_filename.println(line); gps_filename.flush(); Serial.println(line); } else { signal_unavailable_status(); } }
void loop() { if (debugSerial && debugLoopTime) Serial.println(lastLoopTime); atualizaSensors(deltaT); // *********************** loop timing control ************************** deltaT = calcDeltaT(); }
File create_gps_file() { int year; unsigned long age; byte month, day, hour, minute, second, hundredth; gps.crack_datetime(&year, &month, &day, &hour, &minute, &second, &hundredth, &age); String filename; filename.concat(GPS_DIR); filename.concat('/'); filename.concat(year); filename.concat('/'); filename.concat(month); filename.concat('/'); filename.concat(day); filename.concat('/'); filename.concat(hour); filename.concat(minute); filename.concat(second); filename.concat(".GPS"); char buf[filename.length() + 1]; filename.toCharArray(buf, sizeof(buf)); Serial.print("Criando arquivo... "); Serial.println(buf); return create_file(buf); }
void setup() { // Set up serial port for debugging Serial.begin(9600); while (!Serial) { ; // wait for serial port to connect. Needed for Leonardo only } // Fullfil the data array createDataArray(); // Read and set the key from the EEPROM readKey(KEYLENGTH); // Inicialization of the key time = micros(); // time start aes192_init(key, &key_init); emit = micros(); // time start Serial.print(F("Inicialisation total takes: ")); Serial.print(emit - time); Serial.println(F(" [us]")); // initialize the digital pin as an output. // Pin 13 has an LED connected on most Arduino boards: pinMode(ledPin, OUTPUT); }
void createDataArray() { Serial.println(F("Creating array of data")); time = micros(); // time start int i, j; for (i = j = 0; i < DATALENGTH; i++, j++) { if (j <= 25) plain[i] = (65 + j); else { plain[i] = char('-'); plain[i + 1] = 65; i++; j = 0; } } // emit = micros(); // time end // // Serial.print(F("Total takes: ")); // Serial.print(emit - time); // Serial.println(F(" [us]")); // // if (beVerbose) // { // Serial.println(F("Printing array data:")); // for (int i = 0; i < DATALENGTH; i++) // Serial.print(plain[i]); // Serial.println(); // } }
bool GetStack::handleExcessiveRequest (HardwareSerial& stream, McuState& state) const { if (frameCount <= state.stackSize) {return false;} char buf[COMMAND_BUF_SIZE]; char* p = Utils::strcpy (buf, COMMAND_BUF_SIZE, "ERR: GS"); Utils::toDecimal(p, COMMAND_BUF_SIZE - 7, frameCount); stream.println (buf); return true; }
void Node::executa(String mensagem){ //serializa // mensagem "C-S0-01-1" String comando[] = {mensagem.substring(0,3),mensagem.substring(5,6), mensagem.substring(8,8)}; if(this->id == comando[0]){ for(int i=0; i < sizeof(this->comandos) +1 ;i++){ if (this->comandos[i].id_objeto == comando[1]){ if(this->comandos[i].seq_ir_code == NULL){ // executa ação digitalWrite(this->comandos[i].pino,this->comandos[i].acao); if(_debug) Serial.println("enviar código infra red para o pino "+this->comandos[i].pino); }else if(_debug) Serial.println("enviar código infra red para o pino "+this->comandos[i].pino); } } }else if(_debug) Serial.println("Node::executa - comando não é para este node /n Node: "+id+"/n Destinatario: "+comando[0] ); }
void loop2() { vw_wait_rx(); if (vw_get_message(buf, &buflen)) // Non-blocking { int port=parse(); switchState(port); Serial.print(port); Serial.println(); } }
void loop(){ // update incoming values g_ServoIn.update(); Serial.print(g_values[0]); Serial.print(" - "); Serial.print(g_values[1]); Serial.print(" - "); Serial.print(g_values[2]); Serial.print(" - "); Serial.println(g_values[3]); // handle servo values here, stored in g_values }
void setup() { Serial.begin(9600); Serial.println("setup"); relays[0] = createRelay(PORT_0); relays[1] = createRelay(PORT_1); relays[2] = createRelay(PORT_2); relays[3] = createRelay(PORT_3); vw_set_rx_pin(PORT_RF); vw_setup(4000); // Bits per sec vw_rx_start(); // Start the receiver PLL running }
int calcDeltaT(){ lastLoopUsefulTime = millis()-loopStartTime; if(lastLoopUsefulTime<STD_LOOP_TIME) { delay(STD_LOOP_TIME-lastLoopUsefulTime); if (debugSerial && debugLoopTime){ Serial.print(" Esperei: "); Serial.println(STD_LOOP_TIME-lastLoopUsefulTime); } } lastLoopTime = millis() - loopStartTime; loopStartTime = millis(); return lastLoopTime; }
void GetStack::execute (HardwareSerial& stream, McuState& state) const { if (handleExcessiveRequest (stream, state)) {return;} int responseLen = MAX_STACK_FRAMES * 4 + 1; char response[responseLen]; char *p = response; for (int i = 0; i < frameCount; i++) { if (i > 0) { p = Utils::strcpy (p, (response + responseLen - p), ","); } char buf[4]; Utils::toDecimal(buf, 4, state.stack[MAX_STACK_FRAMES - state.stackSize + i]); p = Utils::strcpy (p, (response + responseLen - p), buf); } stream.println (response); }
int FreeBoardModel::writeSimple(HardwareSerial ser) { //ArduIMU output format //!!!VER:1.9,RLL:-0.52,PCH:0.06,YAW:80.24,IMUH:253,MGX:44,MGY:-254,MGZ:-257,MGH:80.11,LAT:-412937350,LON:1732472000,ALT:14,COG:116,SOG:0,FIX:1,SAT:5,TOW:22504700, ser.print("!!!VER:1.9,"); ser.print("UID:MEGA,APX:"); ser.print(autopilotState.autopilotOn); ser.print(",APS:"); ser.print(autopilotState.autopilotReference); //if autopilot on, send autopilot data if (autopilotState.autopilotOn) { ser.print(",APT:"); ser.print(getAutopilotTargetHeading()); ser.print(",APC:"); ser.print(getAutopilotCurrentHeading()); ser.print(",APR:"); ser.print(autopilotState.autopilotRudderCommand-33.0);// 0-66 in model } //if anchor alarm on, send data ser.print(",AAX:"); ser.print(config.anchorAlarmOn); ser.print(",AAR:"); ser.print(config.anchorRadius); if (config.anchorAlarmOn) { ser.print(",AAN:"); ser.print(config.anchorLat); ser.print(",AAE:"); ser.print(config.anchorLon); ser.print(",AAD:"); ser.print(getAnchorDistance()); } //if wind alarm on, send data ser.print(",WSX:"); ser.print(config.windAlarmOn); ser.print(",WSK:"); ser.print(config.windAlarmSpeed); ser.println(","); return 0; }
/* * Write out the config to serial */ int FreeboardModel::writeConfig(HardwareSerial& ser) { //ArduIMU output format //!!VER:1.9,RLL:-0.52,PCH:0.06,YAW:80.24,IMUH:253,MGX:44,MGY:-254,MGZ:-257,MGH:80.11,LAT:-412937350,LON:1732472000,ALT:14,COG:116,SOG:0,FIX:1,SAT:5,TOW:22504700, ser.print(F("!!VER:1.9,")); ser.print(F("UID:MEGA,APX:")); ser.print(F(",WZJ:")); ser.print(getWindZeroOffset()); ser.print(F(",GPS:")); ser.print(getGpsModel()); ser.print(F(",SB0:")); ser.print(getSerialBaud()); ser.print(F(",SB1:")); ser.print(getSerialBaud1()); ser.print(F(",SB2:")); ser.print(getSerialBaud2()); ser.print(F(",SB3:")); ser.print(getSerialBaud3()); ser.print(F(",STK:")); ser.print(getSeaTalk()); ser.print(F(",LU1:")); ser.print(getLvl1UpperLimit()); ser.print(F(",LL1:")); ser.print(getLvl1LowerLimit()); ser.print(F(",LU2:")); ser.print(getLvl2UpperLimit()); ser.print(F(",LL2:")); ser.print(getLvl2LowerLimit()); ser.print(F(",LU3:")); ser.print(getLvl3UpperLimit()); ser.print(F(",LL3:")); ser.print(getLvl3LowerLimit()); ser.println(F(",")); return 0; }
void loop() { // Get serial input from Processing if (Serial.available()) { char ch = Serial.read(); switch(ch){ case '0'...'9': rawSerial = rawSerial * 10 + ch - '0'; Serial.println(rawSerial); break; case 'x': //pulsewidth = map(rawSerial, 0,100, 0,180); servos[3].write(rawSerial); rawSerial = 0; break; case 'y': //pulsewidth = map(rawSerial, 0,100, 0,180); servos[3].write(rawSerial); rawSerial = 0; break; } }
/*** * The loop function is called in an endless loop */ void loop() { char c, argC; char *argV[ARGV_MAX]; int i, pin; unsigned long curMs; // Take care of blinking LED if (startBlinking == true) { curMs = millis(); if (curMs > blinkLastChangeMs + blinkingDelayMs) { blinkLastChangeMs = curMs; if (digitalRead(blinkingPin) == HIGH) { digitalWrite(blinkingPin, LOW); } else { digitalWrite(blinkingPin, HIGH); } } } #ifdef USE_PID // Take care PID-relay variables for (i = 0; i < PID_RELAY_MAX_VARS; i++) { if (pidRelayDescs[i].isOn) { pidRelayDescs[i].inputVar = analogRead(pidRelayDescs[i].pinAnalIn); pidRelayDescs[i].handler->Compute(); // turn relay on/off according to the PID output curMs = millis(); if (curMs - pidRelayDescs[i].windowStartTime > pidRelayDescs[i].windowSize) { //time to shift the Relay Window pidRelayDescs[i].windowStartTime += pidRelayDescs[i].windowSize; } if (pidRelayDescs[i].outputVar > curMs - pidRelayDescs[i].windowStartTime) { digitalWrite(pidRelayDescs[i].pinDigiOut, HIGH); } else { digitalWrite(pidRelayDescs[i].pinDigiOut, LOW); } } } #endif // Read characters from the control serial port and act upon them if (Serial.available()) { c = Serial.read(); switch (c) { case '\n': break; case '\r': // end the string and init pMsg Serial.println(""); *(pMsg++) = NULL; pMsg = msg; // parse the command line statement and break it up into space-delimited // strings. the array of strings will be saved in the argV array. i = 0; argV[i] = strtok(msg, " "); do { argV[++i] = strtok(NULL, " "); } while ((i < ARGV_MAX) && (argV[i] != NULL)); // save off the number of arguments argC = i; pin = strtol(argV[1], NULL, 10); if (strcasecmp(argV[0], "Set") == 0) { cmdSet(argV); } else if (strcasecmp(argV[0], "Reset") == 0) { cmdReset(); } else if (strcasecmp(argV[0], "BlinkPin") == 0) { cmdBlinkPin(argV); } else if (strcasecmp(argV[0], "Read") == 0) { cmdRead(argC, argV); } else if (strcasecmp(argV[0], "Write") == 0) { cmdWrite(argV); } else if (strcasecmp(argV[0], "SetPwmFreq") == 0) { cmdSetPwmFreq(argV); #ifdef USE_PID } else if (strcasecmp(argV[0], "PidRelayCreate") == 0) { cmdPidRelayCreate(argV); } else if (strcasecmp(argV[0], "PidRelaySet") == 0) { cmdPidRelaySet(argV); } else if (strcasecmp(argV[0], "PidRelayTune") == 0) { cmdPidRelayTune(argV); } else if (strcasecmp(argV[0], "PidRelayEnable") == 0) { cmdPidRelayEnable(argV); #endif } else if (strcasecmp(argV[0], "HardSerConnect") == 0) { cmdHardSerConnect(argV); } else if (strcasecmp(argV[0], "SoftSerConnect") == 0) { cmdSoftSerConnect(argV); } else if (strcasecmp(argV[0], "SerSend") == 0) { cmdSerSend(argV); } else if (strcasecmp(argV[0], "SerReceive") == 0) { cmdSerReceive(argV); #ifdef USE_WIRE } else if (strcasecmp(argV[0], "I2cWrite") == 0) { cmdI2cWrite(argC, argV); #endif } else { // Wrong command return; } // Acknowledge the command Serial.println(doneString); break; default: // Record the received character if (isprint(c) && pMsg < msg + sizeof(msg)) { *(pMsg++) = c; } break; } } }
void loop() { Serial.print(F("Before encryption of message freeMemory()= ")); Serial.print(freeRam()); Serial.println(F(" [byte]")); time = micros(); // time start // ------------------------------------------ // for (int piece = 0; piece < N_BLOCK; piece += N_BLOCK, pPlain += N_BLOCK) for (int piece = 0; piece < DATALENGTH; piece += N_BLOCK, pPlain += N_BLOCK) { // Divide message into a block of 128 bit = 16 byte // byte cipher[N_BLOCK]; // getBlockOfMsg(pPlain, cipher); // if (beVerbose) // { // Serial.println(); // Serial.println("OT:"); // for (unsigned int i = 0; i < N_BLOCK; i++) // Serial.print(char(cipher[i])); // } // time = micros(); // time start // aes192_enc(cipher, &key_init); // Encrypt message aes192_enc(pPlain, &key_init); // Encrypt message // emit = micros(); // time end // Serial.print(F("Encryption total takes: ")); // Serial.print(emit - time); // Serial.println(F(" [us]")); // if (beVerbose) // { // Serial.println(); // Serial.println("CT:"); // for (int i = 0; i < N_BLOCK; i++) // Serial.print(cipher[i]); // // Serial.println(); // Serial.println("HASH:"); // for (int i = 0; i < N_BLOCK; i++) // Serial.print(hash[i]); // } } // void hmac_md5(void* dest, void* key, uint16_t keylength_b, void* msg, uint32_t msglength_b); byte hash[16]; hmac_md5(hash, key, 192, plain, 8192); // ------------------------------------------ emit = micros(); // time start Serial.print(F("After encryption of message freeMemory()= ")); Serial.print(freeRam()); Serial.println(F(" [byte]")); Serial.print(F("Encryption total takes: ")); Serial.print(emit - time); Serial.println(F(" [us]")); Serial.println(); Serial.println(F("Light")); digitalWrite(ledPin, HIGH); // set the LED on delay(1000); Serial.println(F("Dark")); digitalWrite(ledPin, LOW); // set the LED off delay(1000); }
void BotRunner::setup() { setState(new ReadyState(this)); Serial.println("BotRunner setup complete"); }
void Ping::execute (HardwareSerial& stream, McuState&) const { stream.println ("PONG"); }
void loop() { Serial.print(F("Before encryption of message freeMemory()= ")); Serial.print(freeRam()); Serial.println(F(" [byte]")); time = micros(); // time start // ------------------------------------------ // for (int piece = 0; piece < N_BLOCK; piece += N_BLOCK, pPlain += N_BLOCK) for (int piece = 0; piece < DATALENGTH; piece += N_BLOCK, pPlain += N_BLOCK) { // Divide message into a block of 128 bit = 16 byte byte cipher[N_BLOCK]; getBlockOfMsg(pPlain, cipher); // if (beVerbose) // { // Serial.println(); // Serial.println("OT:"); // for (unsigned int i = 0; i < N_BLOCK; i++) // Serial.print(char(cipher[i])); // } // time = micros(); // time start aes256_enc(cipher, &key_init); // Encrypt message // emit = micros(); // time end // Serial.print(F("Encryption total takes: ")); // Serial.print(emit - time); // Serial.println(F(" [ms]")); // if (beVerbose) // { // Serial.println(); // Serial.println("CT:"); // for (int i = 0; i < N_BLOCK; i++) // Serial.print(cipher[i]); // } // delete [] cipher; // do not forget to free ram } // ------------------------------------------ emit = micros(); // time start Serial.print(F("After encryption of message freeMemory()= ")); Serial.print(freeRam()); Serial.println(F(" [byte]")); Serial.print(F("Encryption total takes: ")); Serial.print(emit - time); Serial.println(F(" [us]")); Serial.println(); Serial.println(F("Light")); digitalWrite(ledPin, HIGH); // set the LED on delay(1000); Serial.println(F("Dark")); digitalWrite(ledPin, LOW); // set the LED off delay(1000); }
void initSerialReader() { Serial.begin(9600); Serial.println('W'); }
void SetRegister::execute (HardwareSerial& stream, McuState& state) const { state.registers[registerIdx] = value; stream.println ("OK"); }
// // printStatus // ----------- // Print information to the Serial port // Used during developing and debugging. // Call it with the Serial port as parameter: // myWire.printStatus(Serial); // This function is not compatible with the Wire library. // When this function is not called, it does not use any memory. // void SoftwareWire::printStatus( HardwareSerial& Ser) { Ser.println(F("-------------------")); Ser.println(F("SoftwareWire Status")); Ser.println(F("-------------------")); Ser.print(F(" F_CPU = ")); Ser.println(F_CPU); Ser.print(F(" sizeof(SoftwareWire) = ")); Ser.println(sizeof(SoftwareWire)); Ser.print(F(" _transmission status = ")); Ser.println(_transmission); Ser.print(F(" _i2cdelay = ")); Ser.print(_i2cdelay); if( _i2cdelay == 0) Ser.print(F(" (free running)")); Ser.println(); Ser.print(F(" _pullups = ")); Ser.print(_pullups); if( _pullups) Ser.print(F(" (enabled)")); Ser.println(); Ser.print(F(" _timeout = ")); Ser.print(_timeout); Ser.println(F(" ms")); Ser.print(F(" SOFTWAREWIRE_BUFSIZE = ")); Ser.println(SOFTWAREWIRE_BUFSIZE); Ser.print(F(" rxBufPut = ")); Ser.println(rxBufPut); Ser.print(F(" rxBufGet = ")); Ser.println(rxBufGet); Ser.print(F(" available() = ")); Ser.println(available()); Ser.print(F(" rxBuf (hex) = ")); for(int ii=0; ii<SOFTWAREWIRE_BUFSIZE; ii++) { if(rxBuf[ii] < 16) Ser.print(F("0")); Ser.print(rxBuf[ii],HEX); Ser.print(F(" ")); } Ser.println(); Ser.print(F(" _sdaPin = ")); Ser.println(_sdaPin); Ser.print(F(" _sclPin = ")); Ser.println(_sclPin); Ser.print(F(" _sdaBitMast = 0x")); Ser.println(_sdaBitMask, HEX); Ser.print(F(" _sclBitMast = 0x")); Ser.println(_sclBitMask, HEX); Ser.print(F(" _sdaPortReg = ")); Ser.println( (uint16_t) _sdaPortReg, HEX); Ser.print(F(" _sclPortReg = ")); Ser.println( (uint16_t) _sclPortReg, HEX); Ser.print(F(" _sdaDirReg = ")); Ser.println( (uint16_t) _sdaDirReg, HEX); Ser.print(F(" _sclDirReg = ")); Ser.println( (uint16_t) _sclDirReg, HEX); Ser.print(F(" _sdaPinReg = ")); Ser.println( (uint16_t) _sdaPinReg, HEX); Ser.print(F(" _sclPinReg = ")); Ser.println( (uint16_t) _sclPinReg, HEX); Ser.print(F(" line state sda = ")); Ser.println(i2c_sda_read()); Ser.print(F(" line state scl = ")); Ser.println(i2c_scl_read()); #ifdef ENABLE_I2C_SCANNER // i2c_scanner // Taken from : http://playground.arduino.cc/Main/I2cScanner // At April 2015, it was version 5 Ser.println("\n I2C Scanner"); byte error, address; int nDevices; Ser.println(" Scanning..."); nDevices = 0; for(address=1; address<127; address++ ) { // The i2c_scanner uses the return value of // the Write.endTransmisstion to see if // a device did acknowledge to the address. beginTransmission(address); error = endTransmission(); if (error == 0) { Ser.print(" I2C device found at address 0x"); if (address<16) Ser.print("0"); Ser.print(address,HEX); Ser.println(" !"); nDevices++; } else if (error==4) { Ser.print(" Unknow error at address 0x"); if (address<16) Ser.print("0"); Ser.println(address,HEX); } } if (nDevices == 0) Ser.println(" No I2C devices found\n"); else Ser.println(" done\n"); #endif }