23.- 7 segment displays

Després de la tria de temps vull que es visualitzin en dos displays de 4 digits. Aquests estaran exclusivament goevernats pel Nano.

Comentar que tenen 4 pins cada un i això implicaria 8 pins al Nano cosa que ara mateix no tinc. Per solucionar això es pot fer servir el protocol I2C posant els 2 displays en paral.lel, aquests tindran una adreça associada i cada vegada que ens volguem comunicar amb un dels dos n'hi haurà prou amb enviar les dades a la seva adreça corresponent.

Per saber quina adreça té cada display s'ha de connectar cada display als pins I2C del Nano i executar l'script següent, l'adreça sortirà al monitro série de l'IDE :
#include <Wire.h>

void setup()
{ Wire.begin();
Serial.begin(9600);
while (!Serial); // Leonardo: wait for serial monitor
Serial.println("\nI2C Scanner");
}

void loop()
{
byte error, address;
int nDevices;
Serial.println("Scanning...");
nDevices = 0;
for(address = 1; address < 127; address++ )
{
// The i2c_scanner uses the return value of
// the Write.endTransmisstion to see if
// a device did acknowledge to the address.
Wire.beginTransmission(address);
error = Wire.endTransmission();
if (error == 0)
{
Serial.print("I2C device found at address 0x");
if (address<16)
Serial.print("0");
Serial.print(address,HEX);
Serial.println(" !");
nDevices++;
}
else if (error==4)
{
Serial.print("Unknown error at address 0x");
if (address<16)
Serial.print("0");
Serial.println(address,HEX);
}
}
if (nDevices == 0)
Serial.println("No I2C devices found\n");
else
Serial.println("done\n");
delay(5000); // wait 5 seconds for next scan
}

Tras la elección del tiempo quiero que se visualice en dos displays de 4 digitos. Estos estarán exclusivamente governados por el Nano.

Comentar que tienen 4 pines cada uno y esto implicaría 8 pines al Nano cosa que ahora mismo no tengo. Para solucionar esto se puede usar el protocolo I2C poniendo los 2 displays en paralelo, estos tendrán una dirección asociada y cada vez que nos queramos comunicar con uno de los dos será suficiente con enviar los datos a su dirección correspondiente.
Cargar el script de arriba en el IDE de arduino, conectar cada display en el puerto I2C de la placa tal como indica el fabricante i darle a ejecutar. La respuesta saldrà en el monitor serie del IDE.

After the time selection I want them to be displayed on two 4 digit displays. These will be exclusively governed by the Nano.

Comment that they mount 4 pins each and that would involve 8 pins on the Nano which I don’t have right now. To solve this you can use the I2C protocol by placing the 2 displays in parallel, they will have an associated address and each time we want to communicate with one of the two it will be enough to send the data to its corresponding address.

To know which address each display has the script above is needed. Connect the display to the I2C pins and exectue the script, the adress of each display will be shown in the IDE serial monitor.

And here we are!



It is also needed the following library:

Adafruit_LED_Backpack-master


This library is intended to run 7 segments displays as well as LED matrix so Ihad to remove this 3 voids from the Adafruit_LEDBackpack.cpp file in order to be able to run it with the displays:


 void Adafruit_8x16matrix::drawPixel(int16_t x, int16_t y, uint16_t color)

   void Adafruit_8x8matrix::drawPixel(int16_t x, int16_t y, uint16_t color)
 

void Adafruit_BicolorMatrix::drawPixel(int16_t x, int16_t y, uint16_t color)

Comentaris

Entrades populars d'aquest blog

45.- Weighting the pieces

3.- Sensors II

18.- First electronic tests: tft