Bonjour,
je debute en programmation Arduino j'ai fait une horloge et j'ai recuperer un bout de code qui 'après l'auteur fonctionne. Cependant je n'y arrive pas.
Ci dessous un extrait
#include <FastLED.h>
#include <Wire.h>
#include "RTClib.h"
#include <SoftwareSerial.h>
#include "Timer.h"
#define DHTPIN 12
#define DHTTYPE DHT11
DHT dht(DHTPIN, DHTTYPE);
#define NUM_LEDS 30
#define DATA_PIN 6
CRGB LEDs[NUM_LEDS];
SoftwareSerial BTserial(8, 9);
RTC_DS3231 rtc;
Timer t1;
Timer t2;
Timer t3;
void setup () {
// Initialize LED strip
FastLED.delay(3000);
// Check if you're LED strip is a RGB or GRB version (third parameter)
FastLED.addLeds<WS2812B, DATA_PIN, GRB>(LEDs, NUM_LEDS);
Serial.begin(9600);
while (!Serial) { /* Wait until serial is ready */ }
BTserial.begin(9600);
Serial.println("BTserial started at 9600");
dht.begin();
if (!rtc.begin()) {
Serial.println("Couldn't find RTC");
while (1);
}
if (rtc.lostPower()) {
Serial.println("RTC lost power, lets set the time!");
// following line sets the RTC to the date & time this sketch was compiled
rtc.adjust(DateTime(F(DATE), F(TIME)));
}
et la partie qui affiche l'heure
void displayClock() {
DateTime now = rtc.now();
int h = now.hour();
if (hourFormat == 12 && h > 12)
h = h - 12;
int hl = (h / 10) == 0 ? 13 : (h / 10);
int hr = h % 10;
int ml = now.minute() / 10;
int mr = now.minute() % 10;
displaySegments(0, mr);
displaySegments(7, ml);
displaySegments(16, hr);
displaySegments(23, hl);
displayDots(0);
FastLED.show();
}
Si a ce niveau la je fais un serial.println de h je tombe sur 165. J'ai l'impression qu'il n'arrive pas a ajuster correctement.
J'ai bien branche sur la borne a4 et a5 (arduino nano)
Merci de votre
Cordialement




