CPP 243
Homework_fire_Mohamadi Guest on 20th October 2023 12:50:10 PM
  1. #define ir_pin A2
  2. #define pump 3
  3. #define alarm 4
  4.  
  5. void setup() {
  6.   pinMode(pump, OUTPUT);
  7.   pinMode(alarm, OUTPUT);
  8. }
  9.  
  10. void loop() {
  11.   int ir = analogRead(ir_pin);
  12.   if (ir > 400) {
  13.     digitalWrite(pump, HIGH);  
  14.     digitalWrite(alarm, HIGH);
  15.   }
  16.   else {
  17.     digitalWrite(pump, LOW);  
  18.     digitalWrite(alarm, LOW);  
  19.   }
  20. }

Hightechrobo bin is for source code and general debugging text.

Login or Register to edit, delete and keep track of your pastes and more.

Raw Paste

Login or Register to edit or fork this paste. It's free.