hi all.
i programming voltimeter using arduino uno , double eight-segment display. here code
this circuit:
ok, problem ut doesn't work. displays "0" in right hand side segment, , nothing in left one. right 1 turns on , off every 1 second, fine. delay later 10 ms, intermitence not noticed. first want work.
to test code tried sending values 1 , 2 in function "escribirdigito", , worked. so, guess problem data processing part of code, mean functions "sacarentera" , "sacardecimal".
basically trying convert analogread(a0) goeas 1023 0, number between 5.0 , 0.0.,
then functions "sacarentera" , "sacardecimal" extract integer , decimal parts of number , store them.-
i programming voltimeter using arduino uno , double eight-segment display. here code
code: [select]
float voltaje;
float voltajemap;
int entera;
int decimal;
boolean pina[]={1,0,1,1,0,1,1,1,1,1};
boolean pinb[]={1,1,1,1,1,0,0,1,1,1};
boolean pinc[]={1,1,0,1,1,1,1,1,1,1};
boolean pind[]={1,0,1,1,0,1,1,0,1,0};
boolean pine[]={1,0,1,0,0,0,1,0,1,0};
boolean pinf[]={1,0,0,0,1,1,1,0,1,1};
boolean ping[]={0,0,1,1,1,1,1,0,1,1};
void setup(){
pinmode(a0,input);
for(int p=6;p<14;p++){
pinmode(p,output);}
pinmode(1,output);
pinmode(2,output);
digitalwrite(13,high); //el punto de separacion de decimales, siempre prendido
}
void loop(){
voltaje=analogread(a0);
// voltajemap=map(voltaje,0,1023,0,5); la funcion map no sirve para retornar numeros fraccionarios
voltajemap=(voltaje*5)/1023;
sacarentera(voltajemap);
sacardecimal(voltajemap);
intermitar();
}
void sacarentera(float a){
entera=(int)a;
}
void sacardecimal(float b){
decimal= (int)((b-entera)*10);
}
void escribirdigito(int c){
digitalwrite(6,pina[c]);
digitalwrite(7,pinb[c]);
digitalwrite(8,pinc[c]);
digitalwrite(9,pind[c]);
digitalwrite(10,pine[c]);
digitalwrite(11,pinf[c]);
digitalwrite(12,ping[c]);
}
//esta funcion prende y apaga los pines 1 y 2 de forma alternada cada 10 ms.
void intermitar(){
digitalwrite(1,high);
digitalwrite(2,low);
escribirdigito(decimal);
delay(1000);
digitalwrite(1,low);
digitalwrite(2,high);
escribirdigito(entera);
delay(1000);
}
this circuit:
ok, problem ut doesn't work. displays "0" in right hand side segment, , nothing in left one. right 1 turns on , off every 1 second, fine. delay later 10 ms, intermitence not noticed. first want work.
to test code tried sending values 1 , 2 in function "escribirdigito", , worked. so, guess problem data processing part of code, mean functions "sacarentera" , "sacardecimal".
basically trying convert analogread(a0) goeas 1023 0, number between 5.0 , 0.0.,
then functions "sacarentera" , "sacardecimal" extract integer , decimal parts of number , store them.-
quote
my problem ut doesn't work.what instead?
Arduino Forum > Using Arduino > Programming Questions > Problem with voltimeter
arduino
Comments
Post a Comment