hi everyone.
first of all, i'm new on arduino , @ programing, i've learned on internet, it's not 50% good.
i bought voice recognition module on aliexpress.com geeetch. dificult programing use answer module gives arduino uno.
exemple, of modules return arduino "result:11" me necessary creat string (string voice = (serial.readstring()). creating string can't use "switch()...case", needed use "if()...else". , using "if" code works, not want, , when execute last comand, executes 1, 2, 3, 4 , then, 5
what should do?
first of all, i'm new on arduino , @ programing, i've learned on internet, it's not 50% good.
i bought voice recognition module on aliexpress.com geeetch. dificult programing use answer module gives arduino uno.
exemple, of modules return arduino "result:11" me necessary creat string (string voice = (serial.readstring()). creating string can't use "switch()...case", needed use "if()...else". , using "if" code works, not want, , when execute last comand, executes 1, 2, 3, 4 , then, 5
what should do?
code: [select]
const int azul = a4; //leds azul
const int vermelho = a2; //leds vermelhos
const int verde = a5; //leds verdes
const int releluz = 4; //rele da luz
const int lasers = 6; //lasers
void setup() {
serial.begin(9600);
delay(1000);
serial.write(0xaa);
serial.write(0x36);
delay(1000);
serial.write(0xaa);
serial.write(0x21);
pinmode (releluz, output);
pinmode (lasers, output);
pinmode (vermelho, output);
pinmode (verde, output);
pinmode (azul, output);
}
void loop()
{
inicio: delay(1000);
while(serial.available())
{
string com = string(serial.read(), hex);
string arduino, on, vermelho = "526573756c743a3131da";
string luzes, off, verde = "526573756c743a3132da";
string vento, led, azul = "526573756c743a3133da";
string laser, mais, pulsar= "526573756c743a3134da";
string desligar, menos, branco= "526573756c743a3135da";
serial.print (com);
if (com.startswith(arduino))
{
digitalwrite (vermelho,1);
digitalwrite (verde,0);
digitalwrite (azul ,0);
goto inicio;
}
else {goto inicio;};
break;
}
while(serial.available())
{
string com = string(serial.read(), hex);
string arduino, on, vermelho = "526573756c743a3131da";
string luzes, off, verde = "526573756c743a3132da";
string vento, led, azul = "526573756c743a3133da";
string laser, mais, pulsar= "526573756c743a3134da";
string desligar, menos, branco= "526573756c743a3135da";
serial.print (com);
if (com.startswith(luzes))
{
digitalwrite (vermelho, 0);
digitalwrite (verde, 1);
//digitalwrite (azul , high);
analogwrite ( azul, 0);
digitalwrite (lasers, low);
goto inicio;
}
//else {goto inicio;};
break;
}
while(serial.available())
{
string com = string(serial.read(), hex);
string arduino, on, vermelho = "526573756c743a3131da";
string luzes, off, verde = "526573756c743a3132da";
string vento, led, azul = "526573756c743a3133da";
string laser, mais, pulsar= "526573756c743a3134da";
string desligar, menos, branco= "526573756c743a3135da";
serial.print (com);
if (com.startswith(laser))
{
digitalwrite (vermelho, 0);
digitalwrite (verde, 0);
digitalwrite (azul , 1);
digitalwrite (lasers, high);
digitalwrite (releluz, low);
goto inicio;
}
//else {goto inicio;};
break;
}
while(serial.available())
{
string com = string(serial.read(), hex);
string arduino, on, vermelho = "526573756c743a3131da";
string luzes, off, verde = "526573756c743a3132da";
string vento, led, azul = "526573756c743a3133da";
string laser, mais, pulsar= "526573756c743a3134da";
string desligar, menos, branco= "526573756c743a3135da";
serial.print (com);
if (com.startswith(vento))
{
digitalwrite (vermelho, 1);
digitalwrite (verde, 0);
digitalwrite (azul , 1);
goto inicio;
}
//else {goto inicio;};
break;
}
while(serial.available())
{
string com = string(serial.read(), hex);
string arduino, on, vermelho = "526573756c743a3131da";
string luzes, off, verde = "526573756c743a3132da";
string vento, led, azul = "526573756c743a3133da";
string laser, mais, pulsar= "526573756c743a3134da";
string desligar, menos, branco= "526573756c743a3135da";
serial.print (com);
if (com.startswith(desligar))
{
digitalwrite (lasers, low);
digitalwrite (releluz, 0);
digitalwrite (vermelho, low);
digitalwrite (verde, low);
digitalwrite (azul , low);
goto inicio;
}
else { };
break;
}
}
quote
but me necessary creat stringit not.
code: [select]
string luzes, off, verde = "526573756c743a3132da";
if (com.startswith(luzes))
what value think in luzes @ point? answer other nothing wrong.
you should have 1 block of code read serial port. one!
get rid of stupid goto statement. loop() called reason!
Arduino Forum > Using Arduino > Programming Questions > Voice Recognition Module
arduino
Comments
Post a Comment