Thread Rating:
  • 1 Vote(s) - 5 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Libraries
#16
Bonjour à tous,
Le programme suivant fonctionne :
// programme d'essai de la carte HC868-A6 (Djoii)
// commande successive des relais P0 à P5
// affichage OLED du N° du relais commandé

#include <Arduino.h>
#include <Wire.h>
#include <pcf8574.h>
#include <U8g2lib.h>
PCF8574 pcf8574_R(0x24, 04, 15); // interface relais
// PCF8574 pcf8574_I(0x22, 04, 15); // interface entrées (non utilisée)
U8G2_SSD1306_128X64_NONAME_F_SW_I2C u8g2(U8G2_R0, 15, 4, U8X8_PIN_NONE);//SCL IO15 SDA IO4

uint8_t relais = 0;

void page1() {
u8g2.setFont(u8g2_font_timR12_tf);// Font 12
u8g2.setFontPosTop();
u8g2.setCursor(8,0);
u8g2.print("HC868-A6");
u8g2.setCursor(4,20);
u8g2.print("Initialisation OK ");
u8g2.setCursor(4,40);
u8g2.print("le 10 janvier 2023");
u8g2.drawBox(1,60,5,5); // affichage d'un carré
}
void page2() {
u8g2.setCursor(8,0);
u8g2.print(" COMMANDE "); // TITRE
u8g2.setCursor(10,25);
u8g2.print("du relais N° " + String(relais,DEC)); // relais
}

void setup() {
Serial.begin(9600);

pcf8574_R.begin();
pcf8574_R.pinMode (P0, OUTPUT);
pcf8574_R.pinMode (P1, OUTPUT);
pcf8574_R.pinMode (P2, OUTPUT);
pcf8574_R.pinMode (P3, OUTPUT);
pcf8574_R.pinMode (P4, OUTPUT);
pcf8574_R.pinMode (P5, OUTPUT);
pcf8574_R.begin();
for(int i=0;i<6;i++)
{
pcf8574_R.digitalWrite(i,HIGH);
}
delay(50);

u8g2.setI2CAddress(0x3C*2);
u8g2.begin();
u8g2.enableUTF8Print();
u8g2.firstPage();
do { page1(); }while(u8g2.nextPage());
}

void loop() {
for(int i=0;i<6;i++)
{
delay(1000);
pcf8574_R.begin();
pcf8574_R.digitalWrite(i,LOW);
delay(200);
pcf8574_R.digitalWrite(i,HIGH);

relais = i;
u8g2.firstPage();
do { page2(); }while(u8g2.nextPage());
delay(10);
}
}
Les critiques sont les bien-venues !
A suivre
Djoii
Reply


Messages In This Thread
Libraries - by Vulcan - 12-20-2022, 04:22 AM
RE: Libraries - by admin - 12-20-2022, 06:14 AM
RE: Libraries - by Vulcan - 12-21-2022, 02:47 PM
RE: Libraries - by Djoii - 12-20-2022, 08:24 AM
RE: Libraries - by admin - 12-22-2022, 01:19 AM
RE: Libraries - by Djoii - 12-30-2022, 05:45 PM
RE: Libraries - by admin - 12-31-2022, 01:32 AM
RE: Libraries - by Djoii - 01-01-2023, 09:34 AM
RE: Libraries - by admin - 01-02-2023, 06:30 AM
RE: Libraries - by Djoii - 01-02-2023, 08:28 PM
RE: Libraries - by admin - 01-03-2023, 01:29 AM
RE: Libraries - by Djoii - 01-04-2023, 06:19 PM
RE: Libraries - by admin - 01-04-2023, 11:56 PM
RE: Libraries - by Djoii - 01-05-2023, 09:34 AM
RE: Libraries - by admin - 01-05-2023, 10:07 AM
RE: Libraries - by Djoii - 01-10-2023, 05:59 PM
RE: Libraries - by admin - 01-11-2023, 01:37 AM

Forum Jump:


Users browsing this thread:
1 Guest(s)