hard core tiny bug
i have checked, double checked, triple checked, rewrote many time same code. still, same problem occurs. thing is, it's not complicated. same code use 1 thing different value. while 1 works, , 1 doesn't. again, have double checked, triple checked values too. can genius out there me find out goes wrong here? thank much.
the problem: have 2 modes, 2 alarms flashing 5 led , beeping 1 beeper. mode 3 works is, mode 2 works too, dimmer led , dimmer beeper. suspected problem timing logic, don't think so, checked many times.
the problem: have 2 modes, 2 alarms flashing 5 led , beeping 1 beeper. mode 3 works is, mode 2 works too, dimmer led , dimmer beeper. suspected problem timing logic, don't think so, checked many times.
code: [select]
//------------------------------------------------------------------>>alarm
if( tempalarm==1 && bdsoundalarm==1) {
digitalwrite(beeperpin, fastseckey);
}
else digitalwrite(beeperpin, low);
if( tempalarm==1 && bdlightalarm==1) {
for(int x=1; x<6; x++){
digitalwrite(ledpin[x], fastseckey);
}
}
else {
for(int x=1; x<6; x++){
digitalwrite(ledpin[x], low);
}
}
if(bdfinish==1 && bdsoundalarm==1) {
digitalwrite(beeperpin, fastseckey);
}
else digitalwrite(beeperpin, low);
if(bdfinish==1 && bdlightalarm==1) {
for(int x=1; x<6; x++){
digitalwrite(ledpin[x], fastseckey);
}
}
else {
for(int x=1; x<6; x++){
digitalwrite(ledpin[x], low);
}
}
if(timerstart==1 && cdday==0 && cdhr==0 && cdmin==0 && cdsec==0 && cdsoundalarm==1) {
digitalwrite(beeperpin, fastseckey);
}
else digitalwrite(beeperpin, low);
if(timerstart==1 && cdday==0 && cdhr==0 && cdmin==0 && cdsec==0 && cdlightalarm==1) {
for(int x=1; x<6; x++){
digitalwrite(ledpin[x], fastseckey);
}
}
else {
for(int x=1; x<6; x++){
digitalwrite(ledpin[x], low);
}
}
//<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<alarm
if(bdsec>10 && shuntma<50)bdfinish=1;
else{
bdfinish=0;
}
//------------------------------------------------------------------>>time
unsigned long currentsec=millis();
if(currentsec-previoussec>1000) {
sec++;
seckey=!seckey;
previoussec=currentsec;
if(shuntma>50){
shuntmatotal=shuntmatotal+shuntma;
bdsec++;
}
if(timerstart==1) {arrowrighloc++;}
if(timerstart==1){
if(cdday==0 && cdhr==0 && cdmin==0 && cdsec==0)cdsec=cdsec;
else {
cdsec=cdsec-1;
}
}
else cdsec=cdsec;
}
//----------------------------
unsigned long currentsecsec=millis();
if(currentsecsec-previoussecsec>200) {
fastseckey=!fastseckey;
previoussecsec=currentsecsec;
}
//------------------------------------------------------------------>> sensors
// 8% difference meter arduino reading
int shuntval= analogread(shuntpin);
shuntma=shuntval*(5.0/1023.0*1000.0*0.92); //shuntma
shuntmah=shuntmatotal/3600; //shuntmah
//(21%) tempval*0.2=f degree/ (f-32)x5/9=c degree
int tempval= analogread(temppin);
tempf=tempval*0.21; // tempf
tempc=(tempf-32)*5/9; // tempc
if(tempc > tempalarmvalue) tempalarm=1;
else tempalarm=0;
//darkest 50-1010 lightest
int lightval= analogread(lightpin);
lightval=map(lightval, 50,1010,0,999);
lightlevel=constrain (lightval, 0, 999); // lightlevel
//<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< sensors
1 post code.
2 clean up code!. use auto formatter in ide
3. want , do
mark
2 clean up code!. use auto formatter in ide
3. want , do
mark
Arduino Forum > Using Arduino > Programming Questions > hard core tiny bug
arduino
Comments
Post a Comment