SHARE
TWEET

ASDASDASD

a guest Jan 22nd, 2020 71 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <FreqMeasure.h>
  2. #include <LiquidCrystal.h>
  3.  
  4. LiquidCrystal lcd(12, 11, 5, 4, 3, 2);
  5. void setup() {
  6.   Serial.begin(115200);
  7.   FreqMeasure.begin();
  8.   lcd.begin(16, 2);
  9. }
  10.  
  11. double rpm1;
  12. double velocidade;
  13. int c2=0;
  14. double sum=0;
  15. int count=0;
  16. int n = 8; //Ciclos por rotação
  17. void loop() {
  18.   if (FreqMeasure.available()) {
  19.     // average several reading together
  20.     sum = sum + FreqMeasure.read();
  21.     count = count + 1;
  22.     if (count > 24) {
  23.       c2++;
  24.       float frequency = FreqMeasure.countToFrequency(sum / count);
  25.       //Serial.print(frequency);
  26.       //Serial.print(" ");
  27.      
  28.       Serial.println(frequency*60/n);
  29.       sum = 0;
  30.       count = 0;
  31.       rpm1 = frequency*60/n;
  32.       velocidade = 3.6 * (rpm1 * (0.5334/2) * 0.10472);
  33.      
  34.     lcd.clear();
  35.     //Posiciona o cursor na coluna 3, linha 0;
  36.     lcd.setCursor(0, 0);
  37.     //Envia o texto entre aspas para o LCD
  38.     lcd.print(rpm1);
  39.     lcd.setCursor(3, 1);
  40.     lcd.print(velocidade);
  41.     lcd.setCursor(9, 1);
  42.     lcd.print("KM/H");
  43.     }
  44.   }
  45. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Top