Advertisement
RuiViana

LCD_I2C

Jul 17th, 2015
333
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.40 KB | None | 0 0
  1. #include <LiquidCrystal_I2C.h>
  2. #include <Wire.h>
  3. LiquidCrystal_I2C lcd(0x27,16,2); // set the LCD address to 0x27 for a 16 chars and 2 line display
  4. volatile int NbTopsFan; //measuring the rising edges of the signal
  5. long Calc;
  6. int hallsensor = 2; //The pin location of the sensor
  7.  
  8. void rpm () //This is the function that the interupt calls
  9. {
  10. NbTopsFan++; //This function measures the rising and falling edge of the
  11. }
  12. // The setup() method runs once, when the sketch starts
  13. void setup() //
  14. {
  15. pinMode(hallsensor, INPUT); //initializes digital pin 2 as an input
  16. lcd.begin();
  17. // Print a message to the LCD.
  18. lcd.backlight();
  19. lcd.setCursor( 4, 1);
  20. lcd.print("SUBSEA 7");
  21. lcd.setCursor( 1, 0);
  22. lcd.print("I-Tech Brazil");
  23. delay(5000);
  24. lcd.clear();
  25. attachInterrupt(0,rpm, RISING); //and the interrupt is attached
  26. }
  27. // the loop() method runs over and over again,
  28. // as long as the Arduino has power
  29.  
  30. void loop ()
  31. {
  32. NbTopsFan = 5; //Set NbTops to 0 ready for calculations
  33. sei(); //Enables interrupts
  34. delay (1000); //Wait 1 second
  35. cli(); //Disable interrupts
  36. Calc = (NbTopsFan * 60 / 5.5); //(Pulse frequency x 60) / 5.5Q, = flow rate
  37.  
  38. lcd.setCursor( 12, 1);
  39. lcd.print(Calc,1);
  40. delay (2000); //Wait 1 second
  41. lcd.setCursor(0, 1);
  42. lcd.print("L/hour\r\n ");
  43. delay (2000); //Wait 1 second
  44. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement