#include <LiquidCrystal.h>
// Define the pins for the LCD display
LiquidCrystal lcd(13, 12, 5, 4, 3, 2);
// Define the pins for the fuel injectors
const int injector1 = 6;
const int injector2 = 7;
const int injector3 = 8;
const int injector4 = 9;
const int injector5 = 10;
const int injector6 = 11;
// Define the pin for the pressure sensor
const int pressureSensor = A0;
// Define the pressure conversion factor
const float pressureConversion = 0.0048828125;
// Define the modes
const int mode1 = A1;
const int mode2 = A2;
const int mode3 = A3;
// Define the current mode
int currentMode = mode1;
void setup() {
// Initialize the LCD display
lcd.begin(16, 2);
// Set the injector pins as outputs
pinMode(injector1, OUTPUT);
pinMode(injector2, OUTPUT);
pinMode(injector3, OUTPUT);
pinMode(injector4, OUTPUT);
pinMode(injector5, OUTPUT);
pinMode(injector6, OUTPUT);
// Set the pressure sensor pin as input
pinMode(pressureSensor, INPUT);
}
void loop() {
// Read the pressure sensor value
int pressureValue = analogRead(pressureSensor);
// Convert the pressure value to PSI
float pressurePSI = pressureValue * pressureConversion;
// Display the current mode on the LCD display
lcd.setCursor(0, 0);
lcd.print("Mode: ");
lcd.print(currentMode);
// Check the current mode and control the fuel injectors accordingly
if (currentMode == mode1) {
digitalWrite(injector1, HIGH);
digitalWrite(injector2, HIGH);
digitalWrite(injector3, HIGH);
digitalWrite(injector4, HIGH);
digitalWrite(injector5, LOW);
digitalWrite(injector6, LOW);
} else if (currentMode == mode2) {
digitalWrite(injector1, HIGH);
digitalWrite(injector2, HIGH);
digitalWrite(injector3, HIGH);
digitalWrite(injector4, HIGH);
digitalWrite(injector5, HIGH);
digitalWrite(injector6, HIGH);
} else if (currentMode == mode3) {
// Display the pressure value on the LCD display
lcd.setCursor(0, 1);
lcd.print("Pressure: ");
lcd.print(pressurePSI);
}
// Check for button presses to change the mode
if (analogRead(A1)) == 1028) {
currentMode = mode1;
} else if (analogRead(A2)) == 1028) {
currentMode = mode2;
} else if (analogRead(A3)) == 1028) {
currentMode = mode3;
}
// Delay for a short period to avoid button bounce
delay(50);
}