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 =================")); } }
int main(int argc,char **argv) { pinMode(led_pin, OUTPUT); digitalWrite(led_pin, led_off); digitalWrite(reset_pin, HIGH); pinMode(reset_pin, OUTPUT); Serial.begin(baud); // USB, communication to PC or Mac Uart.begin(baud); // UART, communication to Dorkboard for (;;) { unsigned char c, dtr; static unsigned char prev_dtr = 0; if (Serial.available()) { c = Serial.read(); Uart.write(c); digitalWrite(led_pin, led_on); led_on_time = millis(); continue; } if (Uart.available()) { c = Uart.read(); Serial.write(c); digitalWrite(led_pin, led_on); led_on_time = millis(); continue; } dtr = Serial.dtr(); if (dtr && !prev_dtr) { digitalWrite(reset_pin, LOW); delayMicroseconds(250); digitalWrite(reset_pin, HIGH); } prev_dtr = dtr; if (millis() - led_on_time > 3) { digitalWrite(led_pin, led_off); } if (Serial.baud() != baud) { baud = Serial.baud(); if (baud == 57600) { // This ugly hack is necessary for talking // to the arduino bootloader, which actually // communicates at 58824 baud (+2.1% error). // Teensyduino will configure the UART for // the closest baud rate, which is 57143 // baud (-0.8% error). Serial communication // can tolerate about 2.5% error, so the // combined error is too large. Simply // setting the baud rate to the same as // arduino's actual baud rate works. Uart.begin(58824); } else { Uart.begin(baud); } } } }
/*** * The setup function is called once at startup of the sketch */ void setup() { Serial.begin(SERIAL0_BAUD); pMsg = msg; #ifdef USE_WIRE // Connect to the I2C bus Wire.begin(); #endif // Init hardware serial ports if they exist for (int i = 0; i < HARD_SER_MAX_PORTS; i++) { switch (i + 1) { #if HARD_SER_MAX_PORTS >= 1 case 1: hardSerHandler[i] = &Serial1; break; #endif #if HARD_SER_MAX_PORTS >= 2 case 2: hardSerHandler[i] = &Serial2; break; #endif #if HARD_SER_MAX_PORTS >= 3 case 3: hardSerHandler[i] = &Serial3; break; #endif } } }
Stream* digitalPinToSerial(int pin, unsigned long baud){ #if defined(__AVR_ATmega328P__) return NULL; #elif defined(__AVR_ATmega2560__) if(pin==19 || pin==18){ Serial1.begin(baud); return &Serial1; } if(pin==17 || pin==16){ Serial2.begin(baud); return &Serial2; } if(pin==15 || pin==14){ Serial3.begin(baud); return &Serial3; } return NULL; #elif defined(__AVR_AT90USB1286__) if(pin==2 || pin==3){ UART.begin(baud); return &UART; } return NULL; #endif }
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 OpenDeviceClass::begin(HardwareSerial &serial, unsigned long baud){ serial.begin(baud); DeviceConnection *conn = new DeviceConnection(serial); begin(*conn); }
void HAL_UART_ErrorCallback(UART_HandleTypeDef *UartHandle) { error_count++; /* Reset the UART. The begin() method only takes effect if */ /* the baud rate changes, so force a change here. */ uint32_t baud = huart6.Init.BaudRate; huart6.Init.BaudRate = 0; Serial6.begin(baud); }
void setup() { Serial.begin(9600); // Affectation des servos pour chaque pattes for(int i = 0; i < 4; i++){ servos[i].attach(servoPins[i]); } }
GbGps::GbGps(uint8_t power_pin1, uint8_t power_pin2, HardwareSerial &port, uint32_t baud) : GbAbstractGps(), _gps_power_pin1(power_pin1), _gps_power_pin2(power_pin2), _gps_port(&port) { port.begin(baud); pinMode(power_pin1, OUTPUT); pinMode(power_pin2, OUTPUT); digitalWrite(power_pin1, LOW); // turn off GPS at start digitalWrite(power_pin2, LOW); // turn off GPS at start };
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!"); }
void Comm::init(int addr) { m_addr = addr; if (addr) { // slave Wire.begin(addr); } else { // master Wire.begin(); } Serial.begin(BAUDRATE); }
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 }
bool RTArduLinkHALAddHardwarePort(RTARDULINKHAL_PORT *port, long portSpeed, unsigned char hardwarePort) { HardwareSerial *hardPort; switch (hardwarePort) { case 0: #if defined(USBCON) /* Leonardo support */ hardPort = &Serial1; #else hardPort = &Serial; #endif break; case 1: #if defined(UBRR1H) hardPort = &Serial1; #else return false; #endif break; case 2: #if defined(UBRR2H) hardPort = &Serial2; #else return false; #endif break; case 3: #if defined(UBRR3H) hardPort = &Serial3; #else return false; #endif break; default: return false; } port->serialPort = hardPort; hardPort->begin(portSpeed); // start the port return true; }
int main (void) { // Read clock settings and update SystemCoreClock variable SystemCoreClockUpdate(); // Enable and setup SysTick Timer for 1 ms us_elapsed = 0; SysTick_Config(SystemCoreClock / 1000); // Turn on GPIO and IOCON blocks Chip_GPIO_Init(LPC_GPIO); Chip_IOCON_Init(LPC_IOCON); // Disable buffering on stdout setvbuf(stdout, NULL, _IONBF, 0); setvbuf(stderr, NULL, _IONBF, 0); // Initialize peripherals usb_init(); Serial.begin(115200); Debug.begin(115200); fprintf(stderr, "Coretex M3 running at %ld MHz\r\n", (long) (SystemCoreClock / 1e6)); // Load eeprom fprintf(stderr, "Opening eeprom file..."); init_eeprom(); fprintf(stderr, "Done!\r\n"); // Bind in NeoPixel display driver //machineThread.machine.pDisplay = &neoPixel; // Initialize machineThread.setup(PIN_CONFIG); firestep::threadRunner.setup(LED_PIN); // Run over and over again firestep::threadRunner.run(); return 0; }
void setup(){ Serial.begin(115200); // Initialize timer1, this is required for all features that use Timer1 // (PPMIn/PPMOut/ServoIn/ServoOut) rc::Timer1::init(); // We use pin 8-11 as Servo input pins pinMode(8, INPUT); pinMode(9, INPUT); pinMode(10, INPUT); pinMode(11, INPUT); // We use pin change interrupts to detect changes in the signal // If you're unfamiliar with how this works, please look up some // article or tutorial on the subject. // only allow pin change interrupts for PB0-3 (digital pins 8-11) PCMSK0 = (1 << PCINT0) | (1 << PCINT1) | (1 << PCINT2) | (1 << PCINT3); //PCMSK0 = (1 << PCINT2) | (1 << PCINT3) ; // enable pin change interrupt 0 PCICR = (1 << PCIE0); // start listening g_ServoIn.start(); }
void initSerialReader() { Serial.begin(9600); Serial.println('W'); }
//--------------------------------------------------------- void setup() { Serial.begin(115200); }
void setup() { Serial.begin(9600); mySerial1.begin(9600); mySerial2.begin(9600); }
void setup() { Uart.begin(38400); Uart.print("\rE\rSC\r"); }
void setup() { Tlc.init(); Tlc.update(); Uart.begin(57000); colors[0][0] = 255; // red colors[0][1] = 0; colors[0][2] = 0; colors[1][0] = 255;// orange colors[1][1] = 30; colors[1][2] = 0; colors[2][0] = 255;// yellow colors[2][1] = 75; colors[2][2] = 0; colors[3][0] = 0;// green colors[3][1] = 255; colors[3][2] = 0; colors[4][0] = 0;// aqua colors[4][1] = 255; colors[4][2] = 255; colors[5][0] = 0;// blue colors[5][1] = 0; colors[5][2] = 255; colors[6][0] = 100;// indigo colors[6][1] = 0; colors[6][2] = 255; colors[7][0] = 180;// violet colors[7][1] = 0; colors[7][2] = 255; usa[0][0] = 255; // Red usa[0][1] = 0; usa[0][2] = 0; usa[1][0] = 255; // White usa[1][1] = 255; usa[1][2] = 100; usa[2][0] = 0; // Blue usa[2][1] = 0; usa[2][2] = 255; ms[0] = 0; ms[1] = 0; ms[2] = 0; ms[3] = 0; ms[4] = 0; states[0] = 0; states[1] = 0; states[2] = 0; states[3] = 0; states[4] = 0; rows[0] = 0; rows[1] = 0; rows[2] = 0; rows[3] = 0; rows[4] = 0; ufos[0] = 0; ufos[1] = 3; ufos[2] = 6; ufos[3] = 9; ufos[4] = 12; i = 0; // JUST ADDED!!! EEPROM_readAnything(0, configuration); }
Main::Main (HardwareSerial& stream) : _stream(stream) { stream.begin (9600); }
void initializeLogging() { Serial2.begin(115200); }
void SCC_1080::rs485init(HardwareSerial &port, long rate, int pin) { //initializes the sn65hvd05 on the openaccess control shield at given baud rate port.begin(rate); // RS-485 serial port setup pinMode(pin, OUTPUT); // Set up the RS-485 TX enable pin on pin 16. }