Arduino colaborativo/Tutorial Arduino - Lição 7/Software/Fluxograma
Aspeto
String c, string;
int variavel = 0;
void setup()
{
Serial.begin(9600);
pinMode(13, OUTPUT); //LED
pinMode(4, INPUT); //botao
pinMode(2, INPUT);
attachInterrupt(0, interrupt , RISING);
}
void loop()
{
if(Serial.available() > 0) string = "";
while(Serial.available() > 0)
{
c = (byte)Serial.read();
if(c == ":")
{
break;
}else
{
string += c; // string = string + c;
}
delay(1);
}
if(string == "L")
{
analogWrite(A4, 255);
analogWrite(A5, 255);
}
if(string =="O")
{
analogWrite(A4, 0);
analogWrite(A5, 0);
}
if(string =="X")
{
analogWrite(A4, 0);
analogWrite(A5, 0);
}
if(string == "A")
{
analogWrite(A5, 255);
}
if(string == "B")
{
analogWrite(A5, 0);
}
if(string == "C")
{
analogWrite(A4, 255);
}
if(string =="D")
{
analogWrite(A4, 0);
}
Serial.println(variavel);
delay(1500);
}
void interrupt (){
Serial.print("B1");
variavel++;
}