Étape 8: Arduino Code
#include « MAX31855.h » #include « LiquidCrystal.h » #include « Adafruit_MAX31855.h » Innovente lcd (12, 11, 5, 4, 3, 2) ; const int turnonAudioboard = 13 ; const int audioTrigger0 = A0 ; const int audioTrigger1 = A1 ; const int audioTrigger2 = A2 ; const int audioTrigger3 = A3 ; const int audioTrigger4 = A4 ; const int fanRelay = 10 ; // const int heaterRelay = 9 ; contrôles des résistances const int countthreshold = 100 ; réinitialise les valeurs max et min toutes les 100 secondes const int startfrequency = 300 ; régler la fréquence de départ des bips const int numberofbeepsmax = 50 ; la valeur de la maximumnumber de bips possible int fancountdown = 0 ; int i ; int count = 5 ; int freq = 0 ; bips int = 0 ; int beepthreshold = -10 ; La valeur ci-dessus qui bips commencent à sonner int int audioCount0 = 0 ; int audioCount1 = 0 ; int audioCount2 = 0 ; int audioCount3 = 0 ; int audioCount4 = 0 ; int alarmpotvalue = 500 ; int tempsetpoint = 160 ; int blowersetpoint = 20 ; int bloweron = 0 ; int zeropotvalue = 0 ; int thermocoupleSOPin = 8 ; int thermocoupleCSPin = 7 ; int thermocoupleCLKPin = 6 ; variables de température : double point de consigne ; double chaleur ; double sortie ; double jonction ; MAX31855 thermocouple (thermocoupleSOPin, thermocoupleCSPin, thermocoupleCLKPin) ; void setup() { pinMode (audioTrigger0, sortie) ; digitalWrite(audioTrigger0,HIGH) ; Basse déclenche le son audio sur la carte de FX pinMode (audioTrigger1, sortie) ; digitalWrite(audioTrigger1,HIGH) ; Basse déclenche le son audio sur la carte de FX pinMode (audioTrigger2, sortie) ; digitalWrite(audioTrigger2,HIGH) ; Basse déclenche le son audio sur la carte de FX pinMode (audioTrigger3, sortie) ; digitalWrite(audioTrigger3,HIGH) ; Basse déclenche le son audio sur la carte de FX pinMode (audioTrigger4, sortie) ; digitalWrite(audioTrigger4,HIGH) ; Basse déclenche le son audio sur la carte de FX Delay(500) ; pinMode (turnonAudioboard, sortie) ; digitalWrite (turnonAudioboard, HIGH) ; pinMode (fanRelay, sortie) ; initialiser la goupille de relais du ventilateur comme sortie pinMode (heaterRelay, sortie) ; digitalWrite (fanRelay, basse) ; désactiver le relais du ventilateur. digitalWrite (heaterRelay, basse) ; ton (A5, 400, 100) ; joue un son de 400 hz pour 100 ms LCD.Begin(20,4) ; définir la dimension de l’écran lcd LCD.Clear() ; Écran à cristaux liquides clair lcd.setCursor(2,0) ; LCD.Print ("Varroa Blaster") ; Delay(2000) ; ton (A5, 400, 100) ; joue un son de 400 hz pour 100 ms lcd.setCursor(2,1) ; LCD.Print (« chèvre Industries ») ; Delay(2000) ; noTone (A5) ; Lire la température actuelle chaleur = thermocouple.readThermocouple(CELSIUS) ; chaleur = chaleur-3 ; // En cas de problème de thermocouple Si ((heat == FAULT_OPEN) || (chaleur == FAULT_SHORT_GND) || Delay(500) ; Delay(500) ; Si le pot est trop chaud : while(Heat > |
chaleur = thermocouple.readThermocouple(CELSIUS) ;
chaleur =
chaleur-3 ;
LCD.Clear() ;
lcd.setCursor(0,0) ; LCD.Print ("Veuillez patienter tout en") ;
lcd.setCursor(0,1) ; LCD.Print ("les dispositif cools") ;
lcd.setCursor(0,2) ; LCD.Print ("ci-dessous à 100");lcd.print((char)223);lcd.print("C") ;
lcd.setCursor (0,3); lcd.print ("Probe
Temp:");LCD.Print(Heat);LCD.Print((Char)223);LCD.Print("C.") ;
ton (A5, 300,
100) ; joue un son de 300 hz à 100ms
Delay(3000) ;
}
Si (chaleur < 90) //plays audio0 quand la température (chaleur) est les à 90 degrés C.
{
digitalWrite(audioTrigger0,LOW) ; Faible
le son audio sur la carte de FX
Delay(500) ;
digitalWrite(audioTrigger0,HIGH) ;
}
else {}
while(Count>0) {}
LCD.Clear() ;
lcd.setCursor(4,0) ; LCD.Print("Starting") ;
lcd.setCursor(2,1) ; LCD.Print("vapourisation") ;
lcd.setCursor(0,3) ; LCD.Print("Count:") ; lcd.setCursor(6,3) ;
LCD.Print(Count) ; lcd.setCursor(8,3) ;
LCD.Print("Temp:");LCD.Print(Heat);LCD.Print((Char)223);LCD.Print("C") ;
ton (A5, 400 100) ;
Count = count -1 ;
Delay(1000) ;
noTone (A5) ;
}
}
void loop()
{
Lire la température actuelle
chaleur = thermocouple.readThermocouple(CELSIUS) ;
chaleur = chaleur-3 ;
jonction = thermocouple.readJunction(CELSIUS) ;
En cas de problème de thermocouple
Si ((heat == FAULT_OPEN) || (chaleur == FAULT_SHORT_GND) ||
(Heat == FAULT_SHORT_VCC))
blowersetpoint = 20 ;
chaleur = 17 ; ligne temporaire pour le débogage
LCD.Clear() ;
lcd.setCursor(0,0) ; LCD.Print ("temps de souffler:") ; lcd.setCursor(10,0);lcd.print(blowersetpoint,DEC) ;
lcd.setCursor(14,0);lcd.print("Secs.") ;
lcd.setCursor(0,1) ; LCD.Print ("Temp set point:") ; lcd.setCursor(15,1) ;
LCD.Print(tempsetpoint,DEC);LCD.SetCursor(18,1);LCD.Print((Char)223);LCD.Print("C") ;
lcd.setCursor(0,2);lcd.print("Int.Temp:");lcd.print(junction);lcd.print((char)223);lcd.print("C") ;
lcd.setCursor (0,3); lcd.print (Temp:");lcd.print(heat);lcd.print((char)223);lcd.print("C") de sonde » ;
If
((Heat>100) & &(heat<105) & &(audioCount1<1)) //plays audio1 quand la température (chaleur) arrive à 100 degrés C.
{
audioCount1 = 1 ;
digitalWrite(audioTrigger1,LOW) ; Faible
le son audio sur la carte de FX
Delay(500) ; IMPORTANT, cela doit être au moins 500 !
digitalWrite(audioTrigger1,HIGH) ;
}
else {}
If
((Heat>130) & &(heat<135) & &(audioCount2<1)) //plays audio2 quand la température (chaleur) arrive à 130 ° C.
{
audioCount2 = 1 ;
digitalWrite(audioTrigger2,LOW) ; Basse déclenche le son audio sur la carte de FX
Delay(500) ;
digitalWrite(audioTrigger2,HIGH) ;
}
else {}
If
((Heat>150) & &(heat<155) & &(audioCount3<1)) //plays audio3 quand la température (chaleur) arrive à 150 ° C.
{
audioCount3 = 1 ;
digitalWrite(audioTrigger3,LOW) ; Basse déclenche le son audio sur la carte de FX
Delay(500) ;
digitalWrite(audioTrigger3,HIGH) ;
}
else {}
faire des bruits bips à accroître les fréquences
FREQ =
startfrequency ;
bips = 0 ;
beepBeepThreshold
= beepthreshold ;
while(beeps < numberofbeepsmax) {}
if(Heat >beepBeepThreshold)
ton (A5, freq, 9) ; Jouez une note de broche 1 à freq pour 9ms
bips ++ ;
beepBeepThreshold
= beepBeepThreshold + 10 ;
FREQ = freq +
200 ;
Delay(10) ;
}
noTone (A5) ;
Si (chaleur
}
d’autre
{digitalWrite (heaterRelay, LOW); bloweron = 1 ;
}
fancountdown = blowersetpoint ;
Delay(1000) ;
Maintenant, la température a été atteinte et le ventilateur doit être allumé.
Commencez tout d’abord l’audio :
Si (bloweron > 0) {}
digitalWrite(audioTrigger4,LOW) ; Basse déclenche le son audio sur la carte de FX
Delay(500) ;
digitalWrite(audioTrigger4,HIGH) ;
Delay(14000) ;
}
else {}
Allumez le ventilateur :
while(bloweron >0) {/ / bloweron a l’état de '1' et donc cette boucle est activée :
digitalWrite (fanRelay, HIGH) ;
Si (chaleur
}
d’autre
{digitalWrite (heaterRelay, basse) ;
}
Lire la température actuelle
chaleur = thermocouple.readThermocouple(CELSIUS) ;
chaleur = chaleur-3 ;
jonction = thermocouple.readJunction(CELSIUS) ;
En cas de problème de thermocouple
Si ((heat == FAULT_OPEN) || (chaleur == FAULT_SHORT_GND) ||
(Heat == FAULT_SHORT_VCC))
ton (A5, 1500, 100) ; joue un son de 1500 hz pour 100 ms
Delay(500) ;
ton (A5, 1 500 100) ; joue un son de 1500 hz pour 100 ms
Delay(500) ;
fancountdown = fancountdown -1 ;
LCD.Clear() ;
lcd.setCursor(0,0) ;
LCD.Print("Blowing:") ;
lcd.setCursor(10,0);lcd.print(fancountdown,DEC) ;
lcd.setCursor(14,0);lcd.print("Secs.") ;
lcd.setCursor(0,1) ;
LCD.Print ("Temp set point:") ; lcd.setCursor(15,1) ;
LCD.Print(tempsetpoint,DEC);LCD.SetCursor(18,1);LCD.Print((Char)223);LCD.Print("C") ;
lcd.setCursor(0,2);lcd.print("Int.Temp:");lcd.print(junction);lcd.print((char)223);lcd.print("C") ;
lcd.setCursor (0,3); lcd.print ("Probe
Temp:");LCD.Print(Heat);LCD.Print((Char)223);LCD.Print("C") ;
noTone (A5) ;
Si (fancountdown < 1) {}
Cela crée une boucle de « Fini »
tandis que (fancountdown < 1) {}
LCD.Clear() ;
Lire la température actuelle
chaleur = thermocouple.readThermocouple(CELSIUS) ;
chaleur = chaleur-3 ;
jonction = thermocouple.readJunction(CELSIUS) ;
En cas de problème de thermocouple
Si ((heat == FAULT_OPEN) || (chaleur == FAULT_SHORT_GND) ||
(Heat == FAULT_SHORT_VCC))
lcd.setCursor(0,0) ; LCD.Print("finished") ;
lcd.setCursor(10,0);lcd.print(fancountdown,DEC) ;
lcd.setCursor(13,0);lcd.print("Secs.") ;
lcd.setCursor(0,1) ; LCD.Print ("set Temp
point: ") ; lcd.setCursor(15,1) ;
LCD.Print(tempsetpoint,DEC);LCD.SetCursor(18,1);LCD.Print((Char)223);LCD.Print("C") ;
lcd.setCursor(0,2);lcd.print("Int.Temp:");lcd.print(junction);lcd.print((char)223);lcd.print("C") ;
lcd.setCursor (0,3); lcd.print ("Probe
Temp:");LCD.Print(Heat);LCD.Print((Char)223);LCD.Print("C") ;
digitalWrite (heaterRelay, basse) ;
digitalWrite (fanRelay, basse) ;
Delay(1000) ;
}
}
else {}
}
}