Code: Alles auswählen
//Deklaration der Variablen:
int ClockCounter = 0;
int MaxValue = 50;
int state = 0;
int Edge1 = 0;
unsigned long Start,Ende;
void setup() {
// put your setup code here, to run once:
Serial.begin(9600);
Start = 0;
Ende = 0;
}
void loop() {
while (ClockCounter < MaxValue) {
ClockCounter = ClockCounter +1;
if (ClockCounter = MaxValue) && (state = 1) && (Edge1 = 1) {
Edge1 = 0;
Ende = micros()
Serial.println(Ende-Start);
}
[b]else if (ClockCounter = MaxValue)&&(state = 1){
[/b] Edge1 = 1 Start = micros()
}
else if(ClockCounter = MaxValue){
ClockCounter = 0;
state = 1;
}
else{
ClockCounter = ClockCounter + 1;
}
}
}