adicionados leituras seriais com protocolo de 2 bytes

parent 52e7468e
......@@ -188,24 +188,36 @@ void config_basal_unipolar()
//Função principal:
int main()
{
int data;
int data1;
int data2;
pinMode( 22 , OUTPUT ); //define saída 22 do Arduino para indicação com LED de protocolos ligados/desligados
digitalWrite( 22, LOW);
Serial.begin(9600); //inicia comunicação serial
sei(); //reativa interrupts
while(1)
{
data=Serial.read(); //lê dados recebidos na serial
if(data == 'p')
{
digitalWrite( 22 , HIGH );
config_basal_unipolar();
}
else if(data == 'd')
{
digitalWrite( 22, LOW);
config_desativado();
}
while(Serial.available()<2);
data1=Serial.read(); //lê dados recebidos na serial
data2=Serial.read();
Serial.println(data1);
Serial.println(data2);
if(data1 == 'p')
{
digitalWrite( 22 , HIGH );
if(data2 == 'b')
{
config_basal_unipolar();
}
}
else if(data1 == 'd')
{
if(data2 == 'd')
{
digitalWrite( 22, LOW);
config_desativado();
}
}
}
return 0;
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment