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

Título: Problema de código
Enviado 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.


Título: Re: Problema de código
Enviado por: senso em 02 de Fevereiro de 2014, 04:23
A mensagem de erro é bastante explicita, usa Serial.write !
Título: Re: Problema de código
Enviado por: Nunito em 02 de Fevereiro de 2014, 10:19
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.
Título: Re: Problema de código
Enviado por: Bernardo Lucas em 02 de Fevereiro de 2014, 21:36
Pois mas eu já usei serial.write e continua a dar BYTE keyword is no longer suported
Título: Re: Problema de código
Enviado por: ivitro em 02 de Fevereiro de 2014, 22:04
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!
Título: Re: Problema de código
Enviado por: Bernardo Lucas em 03 de Fevereiro de 2014, 12:25
Fiz umas pesquisas e consegui corrigir o erro. E a correção é:

Serial.write(1);

Ou

Serial.write(char(1));