Bonjour,
Voici le programme suivant :
const int hallPin=2 ;
const unsigned long sampleTime=1000 ;
const int maxRPM = 10200 ;
int kount2rpm ;
const int HallPin=3 ;
const unsigned long sampleTime1=1000 ;
const int maxRPM1 = 10200 ;
int kount2rpm1 ;
void setup()
pinMode(hallPin,INPUT) ;
pinMode(HallPin,INPUT) ;
Serial.begin(14400) ;
void loop()
delay(100) ;
int rpm=getRPM() ;
int rpm1=getRPM1() ;
Serial.println(kount2rpm) ;
Serial.println(kount2rpm1) ;
int getRPM()
int kount=0 ;
boolean kflag=LOW ;
unsigned long currentTime=0 ;
unsigned long startTime=millis() ;
while (currentTime<=sampleTime)
if (digitalRead(hallPin)==HIGH)
kflag=HIGH ;
if (digitalRead(hallPin)==LOW && kflag==HIGH)
kount++ ;
kflag=LOW ;
int getRPM1()
int kount1=0 ;
boolean kflag1=LOW ;
unsigned long currentTime1=0 ;
unsigned long startTime1=millis() ;
while (currentTime1<=sampleTime1)
if (digitalRead(HallPin)==HIGH)
kflag1=HIGH ;
if (digitalRead(HallPin)==LOW && kflag1==HIGH)
kount1++ ;
kflag1=LOW ;
Bonjour,
Voici le programme suivant :
const int hallPin=2 ;
const unsigned long sampleTime=1000 ;
const int maxRPM = 10200 ;
int kount2rpm ;
const int HallPin=3 ;
const unsigned long sampleTime1=1000 ;
const int maxRPM1 = 10200 ;
int kount2rpm1 ;
void setup()
pinMode(hallPin,INPUT) ;
pinMode(HallPin,INPUT) ;
Serial.begin(14400) ;
void loop()
delay(100) ;
int rpm=getRPM() ;
int rpm1=getRPM1() ;
Serial.println(kount2rpm) ;
Serial.println(kount2rpm1) ;
int getRPM()
int kount=0 ;
boolean kflag=LOW ;
unsigned long currentTime=0 ;
unsigned long startTime=millis() ;
while (currentTime<=sampleTime)
if (digitalRead(hallPin)==HIGH)
kflag=HIGH ;
if (digitalRead(hallPin)==LOW && kflag==HIGH)
kount++ ;
kflag=LOW ;
currentTime=millis()-startTime ;
kount2rpm = int(60000./float(sampleTime))*kount ;
return kount2rpm ;
int getRPM1()
int kount1=0 ;
boolean kflag1=LOW ;
unsigned long currentTime1=0 ;
unsigned long startTime1=millis() ;
while (currentTime1<=sampleTime1)
if (digitalRead(HallPin)==HIGH)
kflag1=HIGH ;
if (digitalRead(HallPin)==LOW && kflag1==HIGH)
kount1++ ;
kflag1=LOW ;
currentTime1=millis()-startTime1 ;
kount2rpm1 = int(60000./float(sampleTime1))*kount1 ;
return kount2rpm1 ;
Comment je peux voir que mon capteur fonctionne et j’obtiens une vitesse ?