invalid use of void expresion in FlexiTimer2 library
hello, first post asking in forum patient if dont correctly
well, im trying make robot evades obstacles , uses interrupts in order distances.
ive used flexitimer2 run void function each 5ms, problem whe try verify program says me there error in use of flexitimer.
i copy code below, please can tell error , how solve it, ive been loking dont know do.
thank you
well, im trying make robot evades obstacles , uses interrupts in order distances.
ive used flexitimer2 run void function each 5ms, problem whe try verify program says me there error in use of flexitimer.
code: [select]
flexitimer2::set(1, 1.0/1000, rastreodistanciamin());
i copy code below, please can tell error , how solve it, ive been loking dont know do.
thank you
code: [select]
#include <flexitimer2.h>
#include <servo.h>
//motor a
int ena = 7;
int in1=6;
int in2 = 5;
//motor b
int in3=11;
int in4=10;
int enb=9;
servo cabeza;
//hc-sr04 device
int echo = 13;
int triger = 12;
//it use hc-sr04 determine , return distance in front of him
int calculodistancia(){
volatile int tiempo;
volatile int distancia;
digitalwrite(triger,low); /* por cuestión de estabilización del sensor*/
delaymicroseconds(5);
digitalwrite(triger, high); /* envío del pulso ultrasónico*/
delaymicroseconds(10);
tiempo=pulsein(echo, high); /* función para medir la longitud del pulso entrante. mide el tiempo que transcurrido entre el envío
del pulso ultrasónico y cuando el sensor recibe el rebote, es decir: desde que el pin 12 empieza recibir el rebote, high, hasta que
deja de hacerlo, low, la longitud del pulso entrante*/
distancia= int(tiempo/58); /*fórmula para calcular la distancia obteniendo un valor entero*/
/*monitorización en centímetros por el monitor serial*/
return distancia;
}
//it compare distance calculated value given in order 1 lower
int distanciaminima (int distanciamin){
int distanciaactual = calculodistancia();
if (distanciaactual < distanciamin){
distanciamin = distanciaactual;
}
return distanciamin;
}
/*
it "look" around in angle 45 135 degrees in order search distance
lower tha 10cm. if finds one, order robot turn right or left in
order evade it
*/
void rastreodistanciamin(){
int distanciamin = 999;
int grados = 0;
for (int = 45; i<=135; i++){
cabeza.write(i);
delaymicroseconds(100);
distanciaminima(distanciamin);
if(distanciamin<10){
grados = i;
}
}
if (grados >10){
if (grados >90){
derecha(5); //gira la derecha si el obstaculo está la izquierda
}
if(grados<90){
izquierda(5); //gira la izquierda si el obstaculo está la derecha
}
}
}
void setup(){
//motor a
pinmode(ena,output);
pinmode(in1,output);
pinmode(in2,output);
//motorb
pinmode(in3,output);
pinmode(in4,output);
pinmode(enb,output);
//hc-sr04
pinmode(echo,input);
pinmode(triger,output);
//servo
cabeza.attach(8);
cabeza.write(90);
//new timer interrupt
flexitimer2::set(1, 1.0/1000, rastreodistanciamin()); //here error invalid use of void expression
flexitimer2::start();
}
void loop(){
avanzar();
}
void avanzar (){ //control both motors in order go forward
digitalwrite(ena,high);
digitalwrite(in1,low);
digitalwrite(in2,high);
digitalwrite(enb,high);
digitalwrite(in3,high);
digitalwrite(in4,low);
}
void derecha (int t){ //control both motors in order turn right during t ms
digitalwrite(ena,high);
digitalwrite(in1,low);
digitalwrite(in2,high);
digitalwrite(enb,high);
digitalwrite(in3,high);
digitalwrite(in4,high);
delay(t);
}
void izquierda (int t){ //control both motors in order turn left during t ms
digitalwrite(ena,high);
digitalwrite(in1,high);
digitalwrite(in2,high);
digitalwrite(enb,high);
digitalwrite(in3,high);
digitalwrite(in4,low);
delay(t);
}
void retroceso (int t){ //control both motors in order go during t ms
digitalwrite(ena,high);
digitalwrite(in1,high);
digitalwrite(in2,low);
digitalwrite(enb,high);
digitalwrite(in3,low);
digitalwrite(in4,high);
delay(t);
}
void parada(int t){ //control both motors in order stop during t ms
digitalwrite(ena,high);
digitalwrite(in1,high);
digitalwrite(in2,high);
digitalwrite(enb,high);
digitalwrite(in3,high);
digitalwrite(in4,high);
delay(t);
}
`
Arduino Forum > Using Arduino > Programming Questions > invalid use of void expresion in FlexiTimer2 library
arduino
Comments
Post a Comment