microrobotics

Untitled

Jul 27th, 2021
1,315
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. volatile double waterFlow;
  2. void setup() {
  3.   Serial.begin(9600);  //baudrate
  4.   waterFlow = 0;
  5.   attachInterrupt(0, pulse, RISING);  //DIGITAL Pin 2: Interrupt 0
  6. }
  7. void loop() {
  8.   Serial.print("waterFlow:");
  9.   Serial.print(waterFlow);
  10.   Serial.println("   L");
  11.   delay(500);
  12. }
  13.  
  14. void pulse()   //measure the quantity of square wave
  15. {
  16.   waterFlow += 1.0 / 5880.0;
  17. }
  18.  
RAW Paste Data