Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // include the library code:
- #include <LiquidCrystal.h>
- //Varibles used for calculations
- volatile int NbTopsFan;
- int Calc;
- unsigned int Count;
- //The pin location of the sensor
- int hallsensor = 2; typedef struct{
- //Defines the structure for multiple fans and
- //their dividers
- char fantype;
- unsigned int fandiv; }fanspec;
- //Definitions of the fans
- //This is the varible used to select the fan and its divider,
- //set 1 for unipole hall effect sensor
- //and 2 for bipole hall effect sensor
- fanspec fanspace[3]={{0,1},{1,2},{2,8}}; char fan = 2;
- void rpm ()
- //This is the function that the interupt calls
- { NbTopsFan++; Count++;}
- //This is the setup function where the serial port is initialised,
- //and the interrupt is attached
- // initialize the library with the numbers of the interface pins
- LiquidCrystal lcd(7, 8, 9, 10, 11, 12);
- void setup() {
- // set up the LCD's number of columns and rows:
- lcd.begin(16, 2);
- pinMode(hallsensor, INPUT);
- Serial.begin(9600);
- attachInterrupt(0, rpm, RISING);
- }
- void loop() {
- //Set NbTops to 0 ready for calculations
- {
- //Enables interrupts
- sei();
- lcd.setCursor(0,0);
- lcd.print(Count/4);
- lcd.print(" turns");
- delay(1000);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement