本文整理汇总了C++中HardwareSerial::println方法的典型用法代码示例。如果您正苦于以下问题:C++ HardwareSerial::println方法的具体用法?C++ HardwareSerial::println怎么用?C++ HardwareSerial::println使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类HardwareSerial
的用法示例。
在下文中一共展示了HardwareSerial::println方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: parseRequest
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;
}
}
示例2: loop
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);
}
示例3: setup
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!");
}
示例4: cmdSerSend
/***
* 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;
}
}
}
}
示例5: ajuste_pinos
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.");
}
}
示例6: execute
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);
}
示例7: loop
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();
}
}
示例8: loop
void loop() {
if (debugSerial && debugLoopTime) Serial.println(lastLoopTime);
atualizaSensors(deltaT);
// *********************** loop timing control **************************
deltaT = calcDeltaT();
}
示例9: setup
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);
}
示例10: createDataArray
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();
// }
}
示例11: create_gps_file
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);
}
示例12: handleExcessiveRequest
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;
}
示例13: executa
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] );
}
示例14: loop2
void loop2()
{
vw_wait_rx();
if (vw_get_message(buf, &buflen)) // Non-blocking
{
int port=parse();
switchState(port);
Serial.print(port);
Serial.println();
}
}
示例15: setup
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 ================="));
}
}