Club robotique de Sophia-Antipolis

Accueil > ... > Forum 2053

Une interface IHM pour Arduino

1er juillet 2013, 15:53, par Yousaf

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 ?

Un message, un commentaire ?

modération a priori

Attention, votre message n’apparaîtra qu’après avoir été relu et approuvé.

Qui êtes-vous ?

Pour afficher votre trombine avec votre message, enregistrez-la d’abord sur gravatar.com (gratuit et indolore) et n’oubliez pas d’indiquer votre adresse e-mail ici.

Ajoutez votre commentaire ici

Ce champ accepte les raccourcis SPIP {{gras}} {italique} -*liste [texte->url] <quote> <code> et le code HTML <q> <del> <ins>. Pour créer des paragraphes, laissez simplement des lignes vides.