LusoRobótica - Robótica em Português
Sistemas específicos => Arduino / AVR => Tópico iniciado por: Bernardo Lucas em 01 de Fevereiro de 2014, 23:56
-
Ao compilar no arduino um codigo da me um erro nesta parte do codigo:
{
Serial.print(1,BYTE);
inProgress=false;
t=0;
}
O que me dá é:
The 'BYTE' keyword is no longer supported.
As of Arduino 1.0, the 'BYTE' keyword is no longer supported.
Please use Serial.write() instead.
Como posso corrigir este problema? O arduino que estou a usar é o UNO.
-
A mensagem de erro é bastante explicita, usa Serial.write !
-
Ao compilar no arduino um codigo da me um erro nesta parte do codigo:
{
Serial.print(1,BYTE);
inProgress=false;
t=0;
}
O que me dá é:
The 'BYTE' keyword is no longer supported.
As of Arduino 1.0, the 'BYTE' keyword is no longer supported.
Please use Serial.write() instead.
Como posso corrigir este problema? O arduino que estou a usar é o UNO.
Please use Serial.write() instead.
-
Pois mas eu já usei serial.write e continua a dar BYTE keyword is no longer suported
-
Serial
write()
Description
Writes binary data to the serial port. This data is sent as a byte or series of bytes; to send the characters representing the digits of a number use the print() function instead.
Syntax
Serial.write(val)
Serial.write(str)
Serial.write(buf, len)
Arduino Mega also supports: Serial1, Serial2, Serial3 (in place of Serial)
Parameters
val: a value to send as a single byte
str: a string to send as a series of bytes
buf: an array to send as a series of bytes
len: the length of the buffer
Returns
byte
write() will return the number of bytes written, though reading that number is optional
Example
void setup(){
Serial.begin(9600);
}
void loop(){
Serial.write(45); // send a byte with the value 45
int bytesSent = Serial.write(“hello”); //send the string “hello” and return the length of the string.
}
Lê a ver se percebes!
-
Fiz umas pesquisas e consegui corrigir o erro. E a correção é:
Serial.write(1);
Ou
Serial.write(char(1));