Enable RFID UID output and tidy car mass input
This commit is contained in:
+13
-20
@@ -21,28 +21,21 @@ bool seatBelts = false;
|
||||
void setup() {
|
||||
Serial.begin(9600);
|
||||
|
||||
// -----------------------------------------------------------------
|
||||
// 1. Ask the user for the car mass (kg) via the Serial monitor.
|
||||
// We block only until a valid number is received – this is OK
|
||||
// because it happens once at startup.
|
||||
// -----------------------------------------------------------------
|
||||
Serial.println(F("Enter car mass in kg (e.g. 1200):"));
|
||||
while (true) {
|
||||
// Wait until something is typed
|
||||
if (Serial.available() > 0) {
|
||||
float mass = Serial.parseFloat(); // reads the number
|
||||
if (mass > 0) { // basic sanity check
|
||||
engine.setCarMass(mass);
|
||||
Serial.print(F("Car mass set to "));
|
||||
Serial.print(mass);
|
||||
Serial.println(F(" kg"));
|
||||
break;
|
||||
} else {
|
||||
Serial.println(F("Invalid value – try again:"));
|
||||
}
|
||||
Serial.println(F("Enter car mass in kg (e.g. 1200):"));
|
||||
while (true) {
|
||||
if (Serial.available() > 0) {
|
||||
float mass = Serial.parseFloat();
|
||||
if (mass > 0) {
|
||||
engine.setCarMass(mass);
|
||||
Serial.print(F("Car mass set to "));
|
||||
Serial.print(mass);
|
||||
Serial.println(F(" kg"));
|
||||
break;
|
||||
} else {
|
||||
Serial.println(F("Invalid value – try again:"));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
pinMode(IN_1, OUTPUT);
|
||||
pinMode(IN_2, OUTPUT);
|
||||
|
||||
Reference in New Issue
Block a user