first, im sorry if englsh bad
i use arduino meg+reed switch sensor count rainfall.. resolution 0.2 mm.. use code :
after 3 hours, value of sensor reset,back 0 , start count.
and @ 24:00/00:00 ,, arduino calculate sensor value 24 hours...
can me.?? function should use..??
i use arduino meg+reed switch sensor count rainfall.. resolution 0.2 mm.. use code :
quote
const int reed = 4; //output reed switch di pin 9i count rainfall every 3 hours , display serial monitor.. 00:00 , 03:00 , .......etc
int val = 0; //nilai arus pada reed switch
int old_val = 0; //nilai dari reed switch yang lama
float reedcount = 0; //this variable hold count of switching
void setup(){
serial.begin(9600);
pinmode (reed, input_pullup); //mengaktivasi pull pada internal resistor
}
void loop(){
val = digitalread(reed); //baca status pada reed switch
if ((val == low) && (old_val == high)){ //cek jika terjadi perubahan status pada reed switch
delay(10); // delay put in deal "bouncing" in switch.
reedcount = reedcount + 0.2; //add 1 count of bucket tips
old_val = val; //make old value equal current value
serial.print("hujan = ");
serial.print (reedcount); //output count serial monitor
serial.println(" mm");
}
else {
old_val = val; //if status hasn't changed nothing
}
}
after 3 hours, value of sensor reset,back 0 , start count.
and @ 24:00/00:00 ,, arduino calculate sensor value 24 hours...
can me.?? function should use..??
code: [select]
float reedcount = 0;
are expecting reed switch open , close fractional number of times?
Arduino Forum > Using Arduino > Programming Questions > reset value sensor
arduino
Comments
Post a Comment