Sfoglia il codice sorgente

上传文件至 ''

Jian Song 6 anni fa
parent
commit
40549df480
1 ha cambiato i file con 18 aggiunte e 9 eliminazioni
  1. 18 9
      Toaster.ino

+ 18 - 9
Toaster.ino

@@ -9,6 +9,7 @@
 LiquidCrystal lcd(13, 12, 10, 9, 8, 7);
 #define PIN_OUTPUT 3
 #define LED 5
+volatile int Stop = 2;
 int tempsensor = 6;
 int Magnet = 11;
 int32_t frequency = 10;
@@ -21,6 +22,7 @@ unsigned long tmax = 60000;
 int D;
 void Drehschalter();
 void LCD();
+void Abbrechen();
 OneWire onewirepin(tempsensor);
 DallasTemperature sensors(&onewirepin);
 
@@ -31,7 +33,8 @@ void setup() {
   bool success = SetPinFrequencySafe(PIN_OUTPUT,frequency);
   sensors.begin();
   pinMode(Magnet, OUTPUT);
-
+  pinMode(Stop, INPUT);
+  attachInterrupt(digitalPinToInterrupt(Stop), Abbrechen, CHANGE);
 }
 
 void loop() {
@@ -46,13 +49,13 @@ void loop() {
           pwmWrite(PIN_OUTPUT, D);
           analogWrite(LED, D);
           LCD();
-          S=digitalRead(2);
-          if (S == HIGH) {
-            t=tmax;
-          }
-          if (temperature > Tmax) {
-            t=tmax;
-          }
+//          S=digitalRead(2);
+//          if (S == HIGH) {
+//            t=tmax;
+//          }
+//          if (temperature > Tmax) {
+//            t=tmax;
+//          }
       
       }
 
@@ -94,4 +97,10 @@ void LCD() {
           lcd.print("tmax=");
           lcd.print(tmax/1000);
           lcd.print("s   ");
-}
+}
+
+void Abbrechen() {
+  t = tmax;
+  return(t);
+}
+