Hallo Leute,
ich stehe vor einem Problem.
Ich will bei per tastendruck mein Programm stoppen.
Beim 1. Tastendruck soll die Methode injectEye aufgerufen werden und beim 2. Tastendruck soll das Programm gestoppt werden.
Ich hoffe Ihr könnt mir dabei helfen.
Mfg
Hier mein Code:
#include "TimerOne.h"
volatile int gatepin =13;
volatile int inpin = 2;
int reading;
int previous = LOW;
boolean button = LOW;
int count=0;
int taster_val=0;
int oldval=0;
int tastertmp =0;
void setup()
{
Serial.begin(9600);
pinMode(inpin, INPUT);
pinMode(gatepin,OUTPUT);
Timer1.initialize();
Timer1.setPeriod(8388480);
//Timer1.attachInterrupt(ventil);
attachInterrupt(digitalPinToInterrupt(inpin), ventil, RISING);
}
void loop()
{
}
void ventil() {
if (button == HIGH){
button = LOW;
digitalWrite(gatepin, LOW);
}
if (button == LOW) {
button = HIGH;
injectEye();
tastertmp = 1;
}
}
void injectEye() {
while(true){
count++;
if(count==1){
digitalWrite(gatepin, LOW);
//Timer1.setPeriod(188480);
Serial.println("count=1");
delay(1000000);
}
if(count==2){
digitalWrite(gatepin, HIGH);
Serial.println("count=2");
count=0;
delay(10000);
//Timer1.setPeriod(8388480);
}
}
}
}