#include #include #include #include #define SCREEN_WIDTH 128 // OLED display width, in pixels #define SCREEN_HEIGHT 64 // OLED display height, in pixels // Declaration for an SSD1306 display connected to I2C (SDA, SCL pins) // The pins for I2C are defined by the Wire-library. // On an arduino UNO: A4(SDA), A5(SCL) // On an arduino MEGA 2560: 20(SDA), 21(SCL) // On an arduino LEONARDO: 2(SDA), 3(SCL), ... #define OLED_RESET -1 // Reset pin # (or -1 if sharing Arduino reset pin) #define SCREEN_ADDRESS 0x3C ///< See datasheet for Address; 0x3D for 128x64, 0x3C for 128x32 Adafruit_SSD1306 display(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire, OLED_RESET); #define SDA 12 #define SCL 13 #define SORTIE_RELAIS 2 #define LED_FLASH 4 #define LED_BUILTIN 33 // durée par défaut en secondes int count = 12; #define LOGO_HEIGHT 32 #define LOGO_WIDTH 32 const unsigned char bitmap_K [] PROGMEM = { //uint8_t bitmap_K [] PROGMEM = { // 'K, 32x32px 0xff, 0xff, 0xf8, 0x03, 0x80, 0x7f, 0xf0, 0x07, 0x80, 0x7f, 0xe0, 0x0f, 0x80, 0x7f, 0xc0, 0x1f, 0x80, 0x7f, 0x80, 0x3f, 0x80, 0x7f, 0x00, 0x7f, 0x80, 0x7e, 0x00, 0xff, 0x80, 0x7c, 0x01, 0xff, 0x80, 0xf8, 0x03, 0xff, 0x00, 0xf0, 0x07, 0xff, 0x80, 0xe0, 0x0f, 0xff, 0x80, 0xc0, 0x1f, 0xff, 0x80, 0x00, 0x3f, 0xff, 0x00, 0x00, 0x3f, 0xff, 0x00, 0x00, 0x1f, 0xff, 0x00, 0x00, 0x0f, 0xff, 0x00, 0x00, 0x0f, 0xff, 0x00, 0x00, 0x07, 0xff, 0x00, 0x00, 0x03, 0xff, 0x00, 0x38, 0x01, 0xff, 0x00, 0x7c, 0x01, 0xff, 0x00, 0xfe, 0x00, 0xff, 0x00, 0xff, 0x00, 0x7f, 0x00, 0xff, 0x00, 0x3f, 0x00, 0xff, 0x80, 0x3f, 0x00, 0xff, 0xc0, 0x1f, 0x00, 0xff, 0xe0, 0x0f, 0x00, 0xff, 0xe0, 0x07, 0x00, 0xff, 0xf0, 0x07, 0x00, 0xff, 0xf8, 0x03, 0x00, 0xff, 0xf8, 0x01, 0x00, 0xff, 0xfc, 0x01 }; void testdrawchar(void) { display.clearDisplay(); display.setTextSize(5); // Normal 1:1 pixel scale display.setTextColor(SSD1306_WHITE); // Draw white text display.setCursor(0, 0); // Start at top-left corner display.cp437(true); // Use full 256 char 'Code Page 437' font // Not all the characters will fit on the display. This is normal. // Library will draw what it can and the rest will be clipped. for(int16_t i=0; i<256; i++) { if(i == '\n') display.write(' '); else display.write(i); } display.display(); } void setup() { pinMode(SORTIE_RELAIS, OUTPUT); digitalWrite(SORTIE_RELAIS, LOW); Wire.begin(SDA, SCL); // join i2c bus (address optional for master) Serial.begin(115200); // start serial for output // SSD1306_SWITCHCAPVCC = generate display voltage from 3.3V internally if(!display.begin(SSD1306_SWITCHCAPVCC, SCREEN_ADDRESS)) { Serial.println(F("SSD1306 allocation failed")); for(;;); // Don't proceed, loop forever } // Clear the buffer display.clearDisplay(); // Show the 'K' splash screen display.drawBitmap( (display.width() - LOGO_WIDTH ) / 2, (display.height() - LOGO_HEIGHT) / 2, bitmap_K, LOGO_WIDTH, LOGO_HEIGHT, 1); display.display(); delay(2000); // Clear the buffer display.clearDisplay(); } void loop() { digitalWrite(SORTIE_RELAIS, HIGH); for (int i = count; i > 0; i--) { display.clearDisplay(); display.setTextSize(6); // Normal 1:1 pixel scale display.setTextColor(SSD1306_WHITE); // Draw white text display.setCursor(0, 20); // Start at top-left corner display.println(i); display.display(); display.startscrollright(0x00, 0x0F); delay(1000); } display.clearDisplay(); display.display(); digitalWrite(SORTIE_RELAIS, LOW); delay(3000); }