Advertisement
Guest User

Pickup Winder Code

a guest
Nov 17th, 2018
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.21 KB | None | 0 0
  1. // include the library code:
  2. #include <LiquidCrystal.h>
  3.  
  4. //Varibles used for calculations
  5. volatile int NbTopsFan;
  6. int Calc;
  7. unsigned int Count;
  8.  
  9. //The pin location of the sensor
  10. int hallsensor = 2; typedef struct{
  11.  
  12. //Defines the structure for multiple fans and
  13. //their dividers
  14. char fantype;
  15. unsigned int fandiv; }fanspec;
  16.  
  17. //Definitions of the fans
  18. //This is the varible used to select the fan and its divider,
  19. //set 1 for unipole hall effect sensor
  20. //and 2 for bipole hall effect sensor
  21. fanspec fanspace[3]={{0,1},{1,2},{2,8}}; char fan = 2;
  22.  
  23. void rpm ()
  24. //This is the function that the interupt calls
  25. { NbTopsFan++; Count++;}
  26.  
  27. //This is the setup function where the serial port is initialised,
  28. //and the interrupt is attached
  29. // initialize the library with the numbers of the interface pins
  30. LiquidCrystal lcd(7, 8, 9, 10, 11, 12);
  31. void setup() {
  32. // set up the LCD's number of columns and rows:
  33. lcd.begin(16, 2);
  34. pinMode(hallsensor, INPUT);
  35. Serial.begin(9600);
  36. attachInterrupt(0, rpm, RISING);
  37. }
  38.  
  39. void loop() {
  40. //Set NbTops to 0 ready for calculations
  41. {
  42. //Enables interrupts
  43. sei();
  44.  
  45. lcd.setCursor(0,0);
  46. lcd.print(Count/4);
  47. lcd.print(" turns");
  48. delay(1000);
  49.  
  50. }
  51. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement