This circuit is designed for monitoring fuel level and temperature using an Arduino Nano. It includes an OLED display for visual feedback and several LEDs to indicate different statuses. The circuit also incorporates a pushbutton and potentiometers for user input and sensor readings.
Arduino Nano
LED: Two Pin (red)
LED: Two Pin (green)
LED: Two Pin (yellow)
LED: Two Pin (orange)
Pushbutton
Resistor (330 Ohms)
Resistor (10k Ohms)
Resistor (100k Ohms)
Resistor (100 Ohms)
Potentiometer
OLED Display (128x32)
12V Battery
/*
* Arduino Sketch for Fuel Level and Temperature Monitoring
*
* This code senses the fuel level and temperature using potentiometers.
* It turns on a red LED when the fuel level is less than 5%.
* It turns on a yellow LED when the temperature is greater than 200°F.
*/
#include <Wire.h>
#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h>
// Pin definitions
const int FuelSensorPin = A0;
const int OilSensorPin = 7; // D7
const int TempSensorPin = A1;
const int BattSensorPin = A7;
const int FuelLEDPin = 2; // D2: FUEL
const int OilLEDPin = 3; // D3: OIL
const int TempLEDPin = 4; // D4: TEMP
const int BattLEDPin = 5; // D5: BATT
const int DISP_FUEL_MODE = 1;
const int DISP_OIL_MODE = 2;
const int DISP_TEMP_MODE = 3;
const int DISP_BATT_MODE = 4;
int DispMode = DISP_FUEL_MODE;
int DispCount = 0;
// Thresholds
const float FuelThreshold = 0.05; // 5%
const float OilThreshold = 0.10; // 10%
const float TempMinThreshold = 100.0; // 100°F
const float TempMaxThreshold = 200.0; // 200°F
const float VoltageMinThreshold = 12.0;
const float VoltageMaxThreshold = 14.0;
// Global Values
float fuelLevelValue = 50.0;
float oilLevelValue = 50.0;
float temperatureValue = 150.0;
float voltageValue = 12.0;
#define OLED_WIDTH 128 // OLED display width, in pixels
#define OLED_HEIGHT 32 // OLED display height, in pixels
Adafruit_SSD1306 oled(OLED_WIDTH, OLED_HEIGHT, &Wire, -1); // // create SSD1306 display object connected to I2C
void setup() {
// Initialize serial communication
Serial.begin(9600);
// Initialize LED pins as outputs
pinMode(FuelLEDPin, OUTPUT);
pinMode(OilLEDPin, OUTPUT);
pinMode(TempLEDPin, OUTPUT);
pinMode(BattLEDPin, OUTPUT);
// Initialize sensor pins as inputs
pinMode(FuelSensorPin, INPUT);
pinMode(OilSensorPin, INPUT);
pinMode(TempSensorPin, INPUT);
// initialize OLED display with address 0x3C for 128x64
if (!oled.begin(SSD1306_SWITCHCAPVCC, 0x3C)) {
Serial.println(F("SSD1306 allocation failed"));
while (true);
}
delay(2000); // wait for initializing
oled.clearDisplay(); // clear display