"Solutions high water alarm system" Easy Arduino-based development

For a long time, "some office air conditioning no drainage system, can only take a bucket of water, frequently cause problems of stealing" presented against him come.

Material: Arduino development board, a water level sensor, a high buzzer, several Dupont line.

Principle: The water level sensor is disposed in the tub proper position, the program is designed, when the water level reaches a certain height, a high level signal to the buzzer, the buzzer sounds, to remind.

code:

int OutPutPin = 8; // define the output pin
void Setup () {
Serial.begin (9600); // initialize the baud rate
pinMode (OutPutPin, OUTPUT); // this pin is defined as the output mode
digitalWrite (OutPutPin, LOW ); // initialize output pin low
}

Loop void () {
int value = analogRead (A0); // read port A0 analog value
Serial.print ( "Rain ="); // print characters = Rain
Serial.println (value); // Print analog value
if (value <300) // if the analog value is less than 300, the pin 8 output is high; otherwise, output pin 8 is low
{digitalWrite (OutPutPin, hIGH);}
the else {digitalWrite (OutPutPin, the lOW );}
delay (1000); // 1 second delay
}

 

Thinking:

It can be derived from the program code, the high level trigger buzzer. Data for the analog level sensor, a contact surface when a certain level, the analog value is reduced, so that the alarm.

This solution may be applied to a water level alarm, and post may be the actual situation, WiFi access module, data networking can be achieved, the remote alarm.

Guess you like

Origin www.cnblogs.com/fqhy/p/11333059.html