Two Displays Led With Arduino

Arduino, Seeeduino Serials and mutants. Share your problems and experence on arduino compatible board such as seeeduino/stalker, etc.

Moderators: lily.li, violet, salmanfarisvp

Post Reply
tiagodebortoli
Pre-kindergarten
Pre-kindergarten
Posts: 1
Joined: Sat Apr 30, 2016 4:33 am

Two Displays Led With Arduino

Post by tiagodebortoli » Sat Apr 30, 2016 4:54 am

Hello
Recently I tried to use two TM1637 Displays led with one Arduino, to show two different variables, but I could not.
I tried to modify the libraries, but I do know how to do this.
Someone have any idea?
Sorry for my English.

kavi
Staff
Staff
Posts: 305
Joined: Tue Dec 09, 2014 12:06 pm

Re: Two Displays Led With Arduino

Post by kavi » Mon May 02, 2016 2:53 pm

Hello,

May I know if you are using Grove 4 digit display(TM1637 display) if so we have modified the example in our library to your requirements.

Code: Select all

#include <TimerOne.h>
#include "TM1637.h"
#define ON 1
#define OFF 0

int8_t TimeDisp[] = {0x00,0x00,0x00,0x00};
unsigned char ClockPoint = 1;
unsigned char Update;
unsigned char halfsecond = 0;
unsigned char second;
unsigned char minute = 0;
unsigned char hour = 12;

//Connect the Grove 4-digit display to Base shield D2 port

#define CLK 2//pins definitions for TM1637 and can be changed to other ports    
#define DIO 3
TM1637 tm1637(CLK,DIO);

//Connect the Grove 4-digit display to Base shield D3 port

#define CLK1 3//pins definitions for TM1637 and can be changed to other ports    
#define DIO1 4
TM1637 tm16371(CLK1,DIO1);

void setup()
{
  tm1637.set();
  tm1637.init();
  
  tm16371.set();
  tm16371.init();
  Timer1.initialize(500000);//timing for 500ms
  Timer1.attachInterrupt(TimingISR);//declare the interrupt serve routine:TimingISR  
}
void loop()
{
  if(Update == ON)
  {
    TimeUpdate();
    tm1637.display(TimeDisp);
    tm16371.display(TimeDisp);

  }
  
}
void TimingISR()
{
  halfsecond ++;
  Update = ON;
  if(halfsecond == 2){
    second ++;
    if(second == 60)
    {
      minute ++;
      if(minute == 60)
      {
        hour ++;
        if(hour == 24)hour = 0;
        minute = 0;
      }
      second = 0;
    }
    halfsecond = 0;  
  }
 // Serial.println(second);
  ClockPoint = (~ClockPoint) & 0x01;
}
void TimeUpdate(void)
{
  if(ClockPoint)tm1637.point(POINT_ON);
  else tm1637.point(POINT_OFF); 
  TimeDisp[0] = hour / 10;
  TimeDisp[1] = hour % 10;
  TimeDisp[2] = minute / 10;
  TimeDisp[3] = minute % 10;
  Update = OFF;
  
  if(ClockPoint)tm16371.point(POINT_ON);
  else tm16371.point(POINT_OFF); 
  TimeDisp[0] = hour / 10;
  TimeDisp[1] = hour % 10;
  TimeDisp[2] = minute / 10;
  TimeDisp[3] = minute % 10;
  Update = OFF;
}
and connect them to the D2 and D3 ports of the base shield.

Let us know if you need any other information.

Post Reply