int courant = 0;
#include <Wire.h>
#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h>
#define SCREEN_WIDTH 128 // OLED display width, in pixels
#define SCREEN_HEIGHT 64 // OLED display height, in pixels
// declare an SSD1306 display object connected to I2C
Adafruit_SSD1306 oled(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire, -1);
int cc=(1);
int relay = 9;
int led=10;
void setup() {
// initialize OLED display with address 0x3C for 128x64
if (!oled.begin(SSD1306_SWITCHCAPVCC, 0x3C)) {
Serial.println(F("SSD1306 allocation failed"));
while (true);
}
pinMode(relay,OUTPUT);
digitalWrite(relay, HIGH);
pinMode (led,OUTPUT) ;
digitalWrite (led,HIGH );
}
void loop() {
int courant = analogRead(0);
courant = map(courant, 0, 1023, 0, 500);
int cc = analogRead (1);
cc = map(cc,0,1023,0,500);
// put your main code here, to run repeatedly:
oled.clearDisplay(); // clear display
oled.setTextSize(1); // text size
oled.setTextColor(WHITE); // text color
oled.setCursor(0, 10); // position to display
oled.println(courant); // text to display
oled.setCursor(0,20);
oled.println (cc);
oled.display();
if(courant>= cc){
digitalWrite(relay, LOW);
digitalWrite (led,LOW);
}
else {
digitalWrite(relay, HIGH);
digitalWrite(led, HIGH);
}}