2 display a 7 segmenti - come si fa?

innanzi tutto buon anno a tutti :smiley:

buona sera ragazzi,

il mio progetto calendario va avanti piano piano,

ho compilato uno sketch che funziona finalmente e ve lo posto qui sotto (se avete consigli o vedete qualcosa di strano accetto consigli :D).

// Date and time functions using a DS1307 RTC connected via I2C and Wire lib
#include <Wire.h>
#include "Adafruit_LEDBackpack.h"
#include "Adafruit_GFX.h"
#include "RTClib.h"
#include <Servo.h>
#include <Arduplex.h>

// Set to false to display time in 12 hour format, or true to use 24 hour:
#define TIME_24_HOUR      true

// I2C address of the display.  Stick with the default address of 0x70
// unless you've changed the address jumpers on the back of the display.
#define DISPLAY_ADDRESS   0x70

// Create display and DS1307 objects.  These are global variables that
// can be accessed from both the setup and loop function below.
Adafruit_7segment clockDisplay = Adafruit_7segment();


Multiplexer multiplexer;

//int ledGiorni[7] = {2, 3, 4, 5, 6, 7, 8}; // reparto giorni con i pin da cambiare quando si mette lo sdoppiatore


#if defined(ARDUINO_ARCH_SAMD)  // for Zero, output on USB Serial console
#define Serial SerialUSB
#endif

RTC_DS1307 rtc;

int hours = 0;
int minutes = 0;
int seconds = 0;
int years = 0;

// Remember if the colon was drawn on the display so it can be blinked
// on and off every second.
bool blinkColon = false;

char daysOfTheWeek[7][12] = {"Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"};

Servo servo1;
Servo servo2; //gradi invertiti
int posServo1 = 0;
int posServo2 = 0;

int val1;
int val2;


void setup () {
  while (!Serial);  // for Leonardo/Micro/Zero

  Serial.begin(9600);
  if (! rtc.begin()) {
    Serial.println("Couldn't find RTC");
    while (1);
  }

  // Setup the display.
  clockDisplay.begin(DISPLAY_ADDRESS);

  // Setup the DS1307 real-time clock.
  rtc.begin();

  // Set the DS1307 clock if it hasn't been set before.
  bool setClockTime = !rtc.isrunning() /*true*/;
  // Alternatively you can force the clock to be set again by
  // uncommenting this line:
  //setClockTime = true;
  if (setClockTime) {
    Serial.println("Setting DS1307 time!");
    // This line sets the DS1307 time to the exact date and time the
    // sketch was compiled:
    rtc.adjust(DateTime(2015, 12, 26, 17, 39, 30));
    // Alternatively you can set the RTC with an explicit date & time,
    // for example to set January 21, 2014 at 3am you would uncomment:
    //rtc.adjust(DateTime(2014, 1, 21, 3, 0, 0));
  }

  multiplexer.begin (8, 9, 10, 11, Multiplexer::NO_INHIBIT);
  // for (int x = 0; x < 8; x++) {

  //pinMode(ledGiorni[x], OUTPUT);
  //digitalWrite(ledGiorni[x], LOW);
  //}

  servo1.attach(3);
  servo2.attach(4);

  if (! rtc.isrunning()) {
    Serial.println("RTC is NOT running!");
    // following line sets the RTC to the date & time this sketch was compiled
    //rtc.adjust(DateTime(2015, 12, 19, 16, 17, 00));
    // This line sets the RTC with an explicit date & time, for example to set
    // January 21, 2014 at 3am you would call:
    // rtc.adjust(DateTime(2014, 1, 21, 3, 0, 0));
  }
}

void loop () {


  DateTime now = rtc.now();

  Serial.print(now.year(), DEC);
  Serial.print('/');
  Serial.print(now.month(), DEC);
  Serial.print('/');
  Serial.print(now.day(), DEC);
  Serial.print(" (");
  Serial.print(daysOfTheWeek[now.dayOfTheWeek()]);
  Serial.print(") ");
  Serial.print(now.hour(), DEC);
  Serial.print(':');
  Serial.print(now.minute(), DEC);
  Serial.print(':');
  Serial.print(now.second(), DEC);
  Serial.println();

  Serial.println();
  delay(1000);

  hours = now.hour();
  minutes = now.minute();
  years = now.year ();

  /*
  int displayValue = years;
  clockDisplay.print(displayValue);
  clockDisplay.writeDisplay();
  */
  
  
  // Show the time on the display by turning it into a numeric
  // value, like 3:30 turns into 330, by multiplying the hour by
  // 100 and then adding the minutes.
  int displayValue = hours * 100 + minutes;

  // If we're using 12-hour format and it's past noon then subtract
  // 1200 from the display value.
  if (!TIME_24_HOUR && hours > 11) {
    displayValue -= 1200;
  }

  // Now print the time value to the display.
  clockDisplay.print(displayValue, DEC);

  // Blink the colon by flipping its value every loop iteration
  // (which happens every second).
  blinkColon = !blinkColon;
  clockDisplay.drawColon(blinkColon);

  // Now push out to the display the new values that were set above.
  clockDisplay.writeDisplay();

  // Pause for a second for time to elapse.  This value is in milliseconds
  // so 1000 milliseconds = 1 second.
  //delay(500);

  // Now increase the seconds by one.
  seconds += 1;
  // If the seconds go above 59 then the minutes should increase and
  // the seconds should wrap back to 0.
  if (seconds > 59) {
    seconds = 0;
    minutes += 1;
    // Again if the minutes go above 59 then the hour should increase and
    // the minutes should wrap back to 0.
    if (minutes > 59) {
      minutes = 0;
      hours += 1;
      // Note that when the minutes are 0 (i.e. it's the top of a new hour)
      // then the start of the loop will read the actual time from the DS1307
      // again.  Just to be safe though we'll also increment the hour and wrap
      // back to 0 if it goes above 23 (i.e. past midnight).
      if (hours > 23) {
        hours = 0;
      }
    }
  }




      // led dei giorni della settimana da cambiare quando si installa il chip che sdoppia

      if (now.dayOfTheWeek() == 0) {      //domenica
        multiplexer.select (6);
      }
      else if (now.dayOfTheWeek() == 1) { //lunedi
        multiplexer.select (0);
      }
      else if (now.dayOfTheWeek() == 2) { //mardedi
        multiplexer.select (1);
      }
      else if (now.dayOfTheWeek() == 5) { //mercoledi
        multiplexer.select (2);
      }
      else if (now.dayOfTheWeek() == 4) { //giovedi
        multiplexer.select (3);
      }
      else if (now.dayOfTheWeek() == 5) { //venerdi
        multiplexer.select (4);
      }
      else if (now.dayOfTheWeek() == 6) { //sabato
        multiplexer.select (5);
      }

      val1 = (now.day());
      servo1.write((val1 * 3) + 45);

      val2 = (now.month());
      servo2.write(val2 * 15);

  }

adesso che ho un display che segna l'ora vorrei far segnare ad un'altro display l'anno ma guardando un po in giro non ho ben capito come fare. so che posso collegarlo sempre ai pin A4 e A5 come l'rtc e il primo display, poi però ho visto che in alcuni sketch non dichiarano il secondo display, come devo fare?

thx in advance

I dispositivi I2C devono avere indirizzi diversi. A quei display I2C puoi cambiare l'indirizzo I2C ?

P.S. qualche info ? di che display parliamo ?

sono due adafruit 7-segment LED HT16K33 Backpack uno è grande 1.2" e l'altro e piccolo 0.65" nel grande vorrei mettere l'ora e nel piccolo l'anno

a dire il vero non so se si può o come si fa chiedevo a voi

xsimo86x:
a dire il vero non so se si può o come si fa chiedevo a voi

Dal sito di adafruit

This board/chip uses I2C 7-bit address between 0x70-0x77, selectable with jumpers

Su un display imposti l'address 0x70 e sull'altro l'address 0x77, poi quando dichiari i relativi oggetti nello sketch specifichi l'address da usare.

cioè cosi?

#define DISPLAY_ADDRESS1   0x70 //ore
#define DISPLAY_ADDRESS2   0x77 //anni

Lato software sicuro, ma devi anche cambiare fisicamente il jumper sul secondo display.

e ma come? :confused:

Vedi qua: Changing I2C Address | Adafruit LED Backpacks | Adafruit Learning System

Vedi qua: Changing I2C Address | Adafruit LED Backpacks | Adafruit Learning System

usiamoli sti tag :slight_smile:

Quando scrivo dal cellulare è troppo scomodo ;).

SukkoPera:
Quando scrivo dal cellulare è troppo scomodo ;).

Usa un tablet :smiley:

SukkoPera:
Quando scrivo dal cellulare è troppo scomodo ;).

già, ora prendi il tuo smartphone e cerca col ditino di selezionare il pezzo di link che hai messo, che tra l'altro se li metteste su riga separata uno tiene premuta la riga 3 secondi e poi seleziona tutta la linea, ma essendici un altro testo prima bisogna col ditino andare a spostare le freccette di selezione piccolissime.
E' da rinuncia, praticamente i link da smartphone non li legge nessuno ed è da processo chi ha fatto le opzioni di questo forum.
:o

grazie ragazzi come sempre grazie a voi sono riuscito :smiley: