Skip to content
Snippets Groups Projects
Commit 7fbe6d30 authored by hichbra's avatar hichbra
Browse files

Ajout capteur temperature dans le programme de test

parent d947fe05
Branches
No related merge requests found
#define PORT_HALL A0 #define PORT_HALL A0
#define PORT_FSR A2 #define PORT_FSR A2
#define PORT_TEMP A1
#define INTERVALLE 1000
unsigned long temps_precedent ;
//--------------------------------------------------
int hallAnalogique ; // La lecture analogique du gaussmetre int hallAnalogique ; // La lecture analogique du gaussmetre
int gauss; // Valeur convertie en gauss int gauss; // Valeur convertie en gauss
...@@ -10,10 +15,15 @@ int fsrVoltage; // La lecture analogique convertie en tension ...@@ -10,10 +15,15 @@ int fsrVoltage; // La lecture analogique convertie en tension
unsigned long fsrResistance; // La tension convertie en resistance unsigned long fsrResistance; // La tension convertie en resistance
unsigned long fsrConductance; unsigned long fsrConductance;
long newton; // La resistance convertie en force (Newton) long newton; // La resistance convertie en force (Newton)
//-------------------------------------------------- //--------------------------------------------------
int tempAnalogique ; // La lecture analogique du capteur de temperature
float tempVoltage ; // La lecture analogique convertie en tension
float temperature ; // Temperature
void setup(){ void setup(){
Serial.begin(9600); Serial.begin(9600);
temps_precedent = millis();
} }
void loop(){ void loop(){
...@@ -36,7 +46,7 @@ void loop(){ ...@@ -36,7 +46,7 @@ void loop(){
//Serial.print("Lecture de la tension en mV = "); Serial.println(fsrVoltage); //Serial.print("Lecture de la tension en mV = "); Serial.println(fsrVoltage);
if (fsrVoltage == 0) { if (fsrVoltage == 0) {
Serial.println("Aucune pression"); //Serial.println("Aucune pression");
newton = 0 ; newton = 0 ;
} else { } else {
// La tension = Vcc * R / (R + FSR) où R = 10K et Vcc = 5V // La tension = Vcc * R / (R + FSR) où R = 10K et Vcc = 5V
...@@ -55,16 +65,27 @@ void loop(){ ...@@ -55,16 +65,27 @@ void loop(){
//Serial.print("Force en Newtons: "); Serial.println(fsrForce); //Serial.print("Force en Newtons: "); Serial.println(fsrForce);
} }
// ------------------------------------- Lecture et calcul de la Température ----------------------------------------------
tempAnalogique = analogRead(PORT_TEMP);
tempVoltage = (tempAnalogique/1024.0)*5.0;
temperature = (tempVoltage - 0.5)*100;
// ------------------------------------- Affichage des résultats ---------------------------------------------- // ------------------------------------- Affichage des résultats ----------------------------------------------
Serial.println("---------------------------------------------------"); if(millis()-temps_precedent >= INTERVALLE) {
Serial.println("---------------------------------------------------");
// Affiche la valeur en Gauss
Serial.print("=> champ magnétique = "); Serial.print(gauss); Serial.println(" Gauss");
// Affiche la valeur en Gauss // Affiche la valeur du capteur de force (Tension/Newton)
Serial.print("=> champ magnétique = "); Serial.print(gauss); Serial.println(" Gauss"); Serial.print("=> Force Analogique = "); Serial.print(fsrAnalogique); Serial.print(" || Force en Newtons: "); Serial.println(newton);
// Affiche la valeur du capteur de force (Tension/Newton) // Affiche la Température
Serial.print("=> Force Analogique = "); Serial.print(fsrAnalogique); Serial.print(" || Force en Newtons: "); Serial.println(newton); Serial.print("=> Temperature Analogique = "); Serial.print(tempAnalogique); Serial.print(" || Temperature : "); Serial.println(temperature);
// attendre 100 millisecondes temps_precedent = millis();
delay(1000); }
delay(50);
} }
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment