La troisième partie (je suis un peu gêné ::))
/* Chrono START/STOP/LAPS
- Develop by S.Barbeau March 2010
// 3 PART ---- Troisième partie ------------ */// ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
// ++++ To read LAP TIME in EEPROM ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
// ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
if(buttonState2 == HIGH && lastButtonState2 == LOW && out == HIGH){ // Check for button2 if press to display / Get Data from eprom
blinking = false; // turn off blinking, all timing done
previousMillis1 = 0; // to able to restart after reading
startTime = 0 ; // start time for stop watch
addr = 0; //Starting adress for Eprom's Data
// read byte from the EEPROM
lcd.clear();
lap = 1;
while (out == HIGH) {
buttonState1 = digitalRead(buttonPin1); // read the button 1 state and store
delay(40);
buttonState2 = digitalRead(buttonPin2); // read the button2 state and store
delay(40);
if(buttonState1 ==HIGH && lap >1){
lap --;
delay(10);
buttonState1 = LOW;
}
if(buttonState2 == HIGH && lap < nbrenr/3){
lap++;
delay(10);
buttonState2 == LOW;
}
lcd.setCursor(0,0);
lcd.print("LAPs ");
lcd.print(lap);
lcd.print(": ");lcd.setCursor(8,0);
val = EEPROM.read((lap*3)-3);
if (val <10) { //If less then 10 seconds display need ajustement
lcd.print("0"); // Add a zero for clean presentation
}
lcd.print(val,DEC);
lcd.print(":");lcd.setCursor(11,0);
val = EEPROM.read((lap*3)-2);
if (val <10) { //If less then 10 seconds display need ajustement
lcd.print("0"); // Add a zero for clean presentation
}
lcd.print(val,DEC);
lcd.print(".");lcd.setCursor(14,0);
val = EEPROM.read((lap*3)-1);
lcd.print(val,DEC);if (buttonState1 == HIGH && buttonState2 == HIGH){
out=LOW;
}
Serial.print("Out ");
Serial.println(out,BIN);
// buttonState = digitalRead(buttonPin); // read the button 0 state and store
buttonState1 = digitalRead(buttonPin1); // read the button 1 state and store
delay(5);
buttonState2 = digitalRead(buttonPin2); // read the button2 state and store
delay(5);
}
out = HIGH;
nbrenr == 0;
lcd.clear(); // Clear LCD
lcd.print(" T-TIME:"); // Preset display description
lcd.setCursor(0,1);
lcd.print("LAPTIME:"); // print Legend of display information
}
else{
lastButtonState = buttonState; // store buttonState in lastButtonState, to compare next time
lastButtonState1 = buttonState1; // store buttonState in lastButtonState, to compare next time
lastButtonState2 = buttonState2; // store buttonState in lastButtonState, to compare next time
}
// Display of time since Start ///////
if (blinking == true){ // ---------Display continus time ---------------- //
elapsedTime = millis() - startTime; // store elapsed time
lcd.setCursor(8,0); // Set cursor position on LCD
if (minutot1 <10) {
lcd.print("0");
}
lcd.print(minutot1); // Display minutes
lcd.setCursor(10,0); // Set cursor position on LCD
lcd.print(":");
lcd.setCursor(11,0); // Set cursor position on LCD
if (secotot1 <10) {
lcd.print("0");
}
lcd.print(secotot1); // display Seconds
lcd.setCursor(13,0); // Set cursor position on LCD
lcd.print(".");
lcd.setCursor(14,0); // Set cursor position on LCD
if (centitot1<10) {
lcd.print("0");
}
lcd.print(centitot1); // Display Hundred
}
centitot1 = (elapsedTime%1000)/10 ; //centieme to display
secotot1 = (elapsedTime/1000)%60 ; // second to display
minutot1 = (elapsedTime/1000)/60 ; // minute to display
}