Hi guys, i ran into some problems with the oled display.
I was trying to make a boost controller for a car with a potentionmeter,
I set the potentionmeter value as max on the display
the map sensor value from the car is correct it's displaying me 0.00
i tried everything to make the "max" value to shown as 0.00 too but with any success
Here is the code:
#include <SPI.h>
#include <Wire.h>
#include <max6675.h>
#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h>
#define potentiometer A3
#define relay 7
#define alarmr 9
int pottemperature;
#define SCREEN_WIDTH 128
#define SCREEN_HEIGHT 64
int rawValue; // A/D readings
int offset = 102; // zero pressure adjust
int fullScale = 922; // max pressure (span) adjust
float pressure; // final pressure
#define OLED_RESET -1
Adafruit_SSD1306 display(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire, OLED_RESET);
void setup() {
Serial.begin(9600);
Wire.begin();
if(!display.begin(SSD1306_SWITCHCAPVCC, 0x3C))
pinMode(potentiometer, INPUT);
pinMode(relay, OUTPUT);
digitalWrite(relay, LOW);
pinMode(alarmr, OUTPUT);
digitalWrite(alarmr, LOW);
display.setTextSize(2);
display.setTextColor(WHITE);
updatedisplay();
}
void loop() {
rawValue = analogRead(A0);
pressure = (rawValue - offset) * 3.0 / (fullScale - offset); // conversion
updatedisplay();
delay(300);
if (pressure < pottemperature) {
digitalWrite(relay, HIGH);
}
else if (pressure > pottemperature) {
digitalWrite(relay , LOW);
delay(0);
}
if (pressure < 1.4 ) {
digitalWrite(alarmr , HIGH);
}
else if (12 > 27) {
digitalWrite(alarmr , LOW);
}
}
void zero() {
}
void updatedisplay() {
pottemperature = analogRead(potentiometer);
pottemperature = map(pottemperature, 1, 1023, 0, 1.41);
display.clearDisplay();
display.setCursor(15, 20);
display.print("MAX:");
display.print(pottemperature, 1);
display.setCursor(15, 40);
display.print("BAR:");
display.print(pressure);
display.setCursor(5, 0);
display.print("Levi TURBO");
display.display();
}
Thanks for any help to make this work, the solenoid control is not done yet, i stopped beacuse of this. The max value what can be set would be 1.40 Bar