MEGA DAS
Published © Apache-2.0

Arduino LIXIE Clock

Hey guys! Here is a new tutorial to teach you how to make a digital clock based on the LIXIE display technology using an Arduino board.

BeginnerFull instructions providedOver 2 days2,085
Arduino LIXIE Clock

Things used in this project

Hardware components

Arduino UNO & Genuino UNO
Arduino UNO & Genuino UNO
×1
SparkFun Bluetooth Modem - BlueSMiRF Silver
SparkFun Bluetooth Modem - BlueSMiRF Silver
×1
5 mm LED: Red
5 mm LED: Red
We used 80 Blue Leds and 2 white leds
×1
Microchip MCP23017
×1
High Accuracy Pi RTC (DS3231)
Seeed High Accuracy Pi RTC (DS3231)
×1

Software apps and online services

MIT App Inventor
MIT App Inventor
Arduino IDE
Arduino IDE

Hand tools and fabrication machines

Laser cutter (generic)
Laser cutter (generic)
Rework Station Kit, SMD
Rework Station Kit, SMD

Story

Read more

Custom parts and enclosures

LIXIE CAD parts

Schematics

LIXIE circuit diagram

Code

LIXIE program

Arduino
/************************************************************************************************************************************************************************                                              
 * - Author               : BELKHIR Mohamed                        *                                               
 * - Profession           : (Electrical Ingineer) MEGA DAS owner   *                                                                                              
 * - Main purpose         : Industrial Application                 *                                                                                 
 * - Copyright (c) holder : All rights reserved                    *
 * - License              : BSD 2-Clause License                   * 
 * - Date                 : 08/15/2019                             *
 * ***********************************************************************************************************************************************************************/
 
 /*********************************** NOTE **************************************/
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are met:

// * Redistributions of source code must retain the above copyright notice, this
//  list of conditions and the following disclaimer.

// * Redistributions in binary form must reproduce the above copyright notice,
//  this list of conditions and the following disclaimer in the documentation
//  and/or other materials provided with the distribution.

// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED
/*                                MMMMMMMXlxMMWXOkOkkOOOKWMMMMMMMMMMMMMMWKOkkOkkkOXMN0OkOkkOk0NMMMMMMN0000OkkOKNMXOOOOOkOk0WMWKOOOOOkkOO0000000OOOOO0NMMMOc
                                  MMMMMMMXlxMMWK;      ,0WMMMMMMMMMMMMMMWk'      :XMNO,      :XMMMMMMN000c .,okKWMXc      .xWMNk'      cO0000000kc.  .kMMMOc
                                  MMMMMMMXldMMMN:      cWMMMMMMMMMMMMMMMMK,      dMMMWx.     'OMMMMMMMMMO :oNMMMMMMo      ;KMMM0'     .xMMMMMMMMMWd. .kMMMOc
                                  MMMMMMMXlxMMMN:      cNMMMMMMMMMMMMMMMMK,      dMMMMNl      :XMMMMMMMX dkWMMMMMMMo      ;KMMM0'     .dMMMMMMMMMMNc .kMMMOc
                                  MMMMMMMXlxMMMN:      cNMMMMMMMMMMMMMMMMK,      dMMMMMK,      oWMMMMMW kkWMMMMMMMMo      ,KMWM0'     .xMMMMMMMMMMMx..kMMMOc
                                  MMMMMMMXlxMMMN:      cNMMMMMMMMMMMMMMMMK,      dMMMMMMk.     .OMMMMM 0xXMMMMMMMMMo      ,KMMM0'     .xMMMMMMMMMMM0'.kMMMOc
                                  MMMMMMMXlxMMMN:      cNMMMMMMMMMMMMMMMMK,      dMMMMMMNl      ;XMMM XxOMMMMMMMMMMo      ,KMWM0'     .xMMMMMMMMMMMN:.kMMMOc
                                  MMMMMMMXlxMMMN:      cNMMMMMMMMMMMMMMMMK,      dMMMMMMMK;      oWM WkkNMMMMMMMMMMo      ,KMWM0'     .xMMMMMMMMMMMWd.xMMMOc
                                  MMMMMMMXlxMMMN:      cNMMMMMMMMMMMMMMMMK,      dMMMMMMMMk.     .k MKxKMMMMMMMMMMMo      ,KMWM0'     .xMMMMMMMMMMMMNOXMMMOc
                                  MMMMMMMXlxMMMN:      cNMMMMMMMMMMMMMMMMK,      dMMMMMMMMWl      ;0kOWMMMMMMMMMMMo      ,KMWM0'     .xMMMMMMMMMMMMMMMMMMOc
                                  MMMMMMMXlxMMMN:      cNMMMMMMMMMMMMMMMMK,      dMMMMMMMMMK;      ,xNMMMMMMMMMMMMo      ,KMWM0'     .xMMMMMMNXWMMMMMMMMMOc
                                  MMMMMMMXlxMMMN:      cNMMMMMMMMMMMMMMMMK,      dMMMMMMMMMMO.     .xMMMMMMMMMMMMMo      ,KMWM0'     .xMMMMMK::KMMMMMMMMMOc
                                  MMMMMMMXlxMMMN:      cNMMMMMMMMMMMMMMMMK,      dMMMMMMMMMMWo      ;XMMMMMMMMMMMMo      ,KMWM0'     .xMMMMXc ,KMMMMMMMMMOc
                                  MMMMMMMXlxMMMN:      cNMMMMMMMMMMMMMMMMK,      dMMMMMMMMMMMX;      oWMMMMMMMMMMMo      ,KMWM0'      ckkxo'  ,KMMMMMMMWMOc
                                  MMMMMMMXlxMMMN:      cNMMMMMMMMMMMMMMMMK,      dMMMMMMMMMMMM .     .kMMMMMMMMMMMo      ,KMWM0'      oKKKOo. ,KMMWWWWWWMOc
                                  MMMMMMMXlxMMMN:      cNMMMMMMMMMMMMMMMMK,      dMMMMMMMMMMM Wo      ;KMMMMMMMMMMo      ,KMWM0'     .xMWWWWx.,KMWWWWWWWMOc
                                  MMMMMMMXlxMMMN:      cNMMMMMMMMMMMMMMMMK,      dMMMMMMMMMM MMk.      oWMMMMMMMMMo      ,KMWM0'     .xMWWWWNkxXMWWWWWWWMOc
                                  MMMMMMMXlxMWMN:      :NMMMMMMMMMMMMMMMMK,      dMMMMMMMMM MMXxo.     .kMMMMMMMMMo      ,KMWM0'     .xMWWWWWWWWWWWWWWWWWOc
                                  MMMMMMMXlxMWMN:      :NMMMMMMMMMMMMMWWMK,      dMMMMMMMM MMWkkWo      ;KMMMMMMMMo      ,KMWM0'     .xMWWWWWWWWWWWWWWWWWOc
                                  MMMMMMMXlxMWMN:      :NMMMMMMMMMMMMXoxWK,      dMMMMMMM MMMOxXMX;      lNMMMMMMWo      ,KMWM0'     .xWWWWWWWWWWWWW0lOWWOc
                                  MMMMMMMXlxMWMN:      :NMWMMMMMMMMMMx.cWK,      dMMMMMM MMMXx0MMMO.     .kWMMMMMWo      ,KWWW0'     .dWWWWWWWWWWWWNc.kWWOc
                                  MMMMMMMXlxMWMN:      :NMWWWMWWWWMMWl cWK,      dMMMMM MMMWkkWMMMWo      ,KMMMMMWo      ,KWWW0'     .dWWWWWWWWWWWWK,.kWWO:
                                  MMMMMMMXlxMWMN:      :NMWWWWWWWWWMX; lWK,      dMMMM MMMM0xXMMMMMX:      lNMMMWWo      ,KWWW0'     .dWWWWWWWWWWWWO..kWWO:
                                  MMMMMMMXlxWWWN:      :NMWWWWWWWWWMO. lWK,      dMMM MWWMXxOMMMMMMMO.     .xWMMWWo      ,KWWW0'     .dWWWWWWWWWWWWo .kWWO:
                                  MMMMMMMXlxWWWN:      :NWWWWWWWWWWNc  lW0'      dMW MWWMWdlXWWMMMWWWd      ,KMWWWo      ,KWWW0'     .dWWWWWWWWWWW0, .kWWO:
                                  MMMMMMMXlxWWWN:      :NWWWWWWWWWXl.  cW0,      oW WWMWM0''OWWWWMWWMX:      cXWWWl      ,0WNWO'      dWWWWWWWWWNO;  .kWWO:
                                  MMMMMMMXlxWWW0l,,,,,,lOOOOOOOOOko;,,;xNOc,,,,,;lKWN0OOOd;;lkXWWWWWWNx;;;;,,:xXWKo;,,,,,:kNWNk:,,,,,;lkOOOOOOOOxc;,,c0WWO:*/

#if defined(ESP8266)
#include <pgmspace.h>
#else
#include <avr/pgmspace.h>
#endif
#include <Wire.h>                                    // must be incuded here so that Arduino library object file references work
#include <RtcDS3231.h>                               // Include the RTC library
#include <EEPROM.h>                                  // Include the EEPROM library needed for alarm handeling
#include "Adafruit_MCP23017.h"                       // Include the MCP library to interface the MCP iC

RtcDS3231 Rtc;                                       // Create the RTC instance
RtcDateTime dateTimeData;
Adafruit_MCP23017 MyMCP;                             // Create the MCP instance

char SerialData;                                     // Use this variable to read each caractere received through serial port
char SerialDataDecisison;
String dateData="";                                     // Store all serial caracters in this variable
String timeData="";                                     // Store all serial caracters in this variable
String alarmData="";                                     // Store all serial caracters in this variable
int monthNumber=13;
long int dotBlinkTime=millis();
int alarmHours=0;
int alarmMinutes=0;
int alarmSeconds=0;
int alarmActivate=0;
int alarmCounterControl=0;
int alarmCounter=0;
int displayDot=1;
long int buzzerTime=millis();
long int buzzerTimeControl=millis();
long int dispalDate=millis();

const int N0=1;                                   // The first line of plexiglass LEDs 0
const int N1=0;                                   // The second line of plexiglass LEDs 1
const int N2=15;                                  // The third line of plexiglass LEDs 2
const int N3=14;                                  // .
const int N4=13;                                  // .
const int N5=12;                                  // .
const int N6=11;                                  // .
const int N7=9;                                   // .
const int N8=10;                                  // .
const int N9=8;                                   // The last line of plexiglass LEDs 9
const int dig1=2;                                 // Control of the first digit
const int dig2=3;                                 // .
const int dig3=4;                                 // .
const int dig4=5;                                 // Control of the fourth digit
const int dot=6;                                  // Control of the two dots
const int buzzer=3;                               // Control of the buzzer

const int delaySeq=5000;

void setup() 
{
  Serial.begin(9600);
  Serial.setTimeout(100);
  Wire.setClock(3400000);
  pinMode(buzzer,OUTPUT);
  digitalWrite(buzzer,LOW);
  MyMCP.begin(1);
  //--------RTC SETUP ------------
  Rtc.Begin();
  for(int i=0;i<16;i++)
  {
    MyMCP.pinMode(i,OUTPUT);
    MyMCP.digitalWrite(i,LOW);
  }
  clearDisplay();

  if (!Rtc.IsDateTimeValid()) 
  {
        // Common Cuases:
        //    1) first time you ran and the device wasn't running yet
        //    2) the battery on the device is low or even missing

      Serial.println("RTC lost confidence in the DateTime!");

        // following line sets the RTC to the date & time this sketch was compiled
        // it will also reset the valid flag internally unless the Rtc device is
        // having an issue
  }
  if (!Rtc.GetIsRunning())
  {
      Serial.println("RTC was not actively running, starting now");
      Rtc.SetIsRunning(true);
  }
  Rtc.Enable32kHzPin(false);
  Rtc.SetSquareWavePin(DS3231SquareWavePin_ModeNone); 
  dateTimeData=Rtc.GetDateTime();
  if(EEPROM.read(0)==1)
  {
    alarmMinutes=EEPROM.read(1);
    alarmHours=EEPROM.read(2);
    alarmActivate=1;
  }
}

void loop() 
{
  while(Serial.available())                   // While serial data are available we store it 
  {
    delay(10);
    SerialDataDecisison=Serial.read();
    if(SerialDataDecisison=='d')
    {
      monthNumber=Serial.parseInt();
      switch (monthNumber)
      {
        case 1 : dateData+="Jan"; break;
        case 2 : dateData+="Feb"; break;
        case 3 : dateData+="Mar"; break;
        case 4 : dateData+="Apr"; break;
        case 5 : dateData+="May"; break;
        case 6 : dateData+="Jun"; break;
        case 7 : dateData+="Jul"; break;
        case 8 : dateData+="Aug"; break;
        case 9 : dateData+="Sep"; break;
        case 10 : dateData+="Oct"; break;
        case 11 : dateData+="Nov"; break;
        case 12 : dateData+="Dec"; break;
      }
      while(Serial.available())                   // While serial data are available we store it 
      {
        delay(10);
        SerialData=Serial.read();
        dateData+=SerialData;
      }
      const char* newDate=dateData.c_str();
      dateTimeData=Rtc.GetDateTime();
      String TimeFromRTC=(String(dateTimeData.Hour())+":"+String(dateTimeData.Minute())+":"+String(dateTimeData.Second()));
      const char* sameTime=TimeFromRTC.c_str();
      Serial.println(sameTime);
      RtcDateTime RtcConfig = RtcDateTime(newDate, sameTime);
      Rtc.SetDateTime(RtcConfig);
    }
    if(SerialDataDecisison=='t')
    {
      while(Serial.available())                   // While serial data are available we store it 
      {
        delay(10);
        SerialData=Serial.read();
        timeData+=SerialData;
      }
            
      const char* newTime=timeData.c_str();
      dateTimeData=Rtc.GetDateTime();
      String DateFromRTC=(String(dateTimeData.Month())+" "+String(dateTimeData.Day())+" "+String(dateTimeData.Year()));
      const char* sameDate=DateFromRTC.c_str();
      Serial.println(sameDate);
      RtcDateTime RtcConfig = RtcDateTime(sameDate, newTime);
      Rtc.SetDateTime(RtcConfig);
    }
    if(SerialDataDecisison=='a')
    {
      while(Serial.available())                   // While serial data are available we store it 
      {
        delay(10);
        SerialData=Serial.read();
        alarmData+=SerialData;
      }
      alarmHours=getValue(alarmData, ':', 0).toInt();
      alarmMinutes=getValue(alarmData, ':', 1).toInt();
      alarmSeconds=getValue(alarmData, ':', 2).toInt();
      EEPROM.write(0,1);
      EEPROM.write(1,alarmMinutes);
      EEPROM.write(2,alarmHours);
      alarmActivate=1;
      buzzerTime=millis();
    }
  }
  dateData="";
  timeData="";
  alarmData="";
  if(millis()-dotBlinkTime<1000&&displayDot==1)
  {
    MyMCP.digitalWrite(dot,HIGH);
  }
  if(millis()-dotBlinkTime>1000&&displayDot==1)
  {
    MyMCP.digitalWrite(dot,LOW);
    if(millis()-dotBlinkTime>2000&&displayDot==1)
    {
      dotBlinkTime=millis();
    }
  }
  RtcDateTime now = Rtc.GetDateTime();
  if(millis()-dispalDate<10000)
    {
      displayMode(now.Minute(),"right");
      displayMode(now.Hour(),"left");
      displayDot=1;
    }
    if(millis()-dispalDate>10000)
    {
      displayDot=0;
      MyMCP.digitalWrite(dot,LOW);
      displayMode(now.Day(),"right");
      displayMode(now.Month(),"left");
      if(millis()-dispalDate>15000)
      {
        dispalDate=millis();
        displayDot=1;
      }
    }
  if(alarmActivate==1&&now.Hour()==alarmHours&&now.Minute()==alarmMinutes)
  {
    if(alarmCounterControl<8)
    {
      alarmControl();
    }
    else
    {
      alarmCounterControl=0;
      alarmActivate=0;
      EEPROM.write(0,0);
    }
  }
}
void alarmControl()
{
  if(millis()-buzzerTime<65)
    {
      digitalWrite(buzzer,HIGH);
    }
    if(millis()-buzzerTime>65)
    {
      digitalWrite(buzzer,LOW);
      if(millis()-buzzerTime>130&&alarmCounter<4)
      {
        buzzerTime=millis();
        alarmCounter+=1;
      }
      if(millis()-buzzerTime>1000)
      {
        alarmCounter=0;
        alarmCounterControl+=1;
      }
    } 
 }
void clearDisplay()
{
  MyMCP.digitalWrite(dig1,HIGH);
  MyMCP.digitalWrite(dig2,HIGH);
  MyMCP.digitalWrite(dig3,HIGH);
  MyMCP.digitalWrite(dig4,HIGH);
  delay(0);
}
void displayMode(int value, String side)
{
  if(side=="right")
  {
    switch (value%10)
    {
      case 0 : 
      {
        MyMCP.digitalWrite(dig1,LOW);
        MyMCP.digitalWrite(dig2,HIGH);
        MyMCP.digitalWrite(dig3,HIGH);
        MyMCP.digitalWrite(dig4,HIGH);
        MyMCP.digitalWrite(N0,HIGH);
        delayMicroseconds(delaySeq);
        MyMCP.digitalWrite(N0,LOW);
      }break;
      case 1 : 
      {
        MyMCP.digitalWrite(dig1,LOW);
        MyMCP.digitalWrite(dig2,HIGH);
        MyMCP.digitalWrite(dig3,HIGH);
        MyMCP.digitalWrite(dig4,HIGH);
        MyMCP.digitalWrite(N1,HIGH);
        delayMicroseconds(delaySeq);
        MyMCP.digitalWrite(N1,LOW);
      }break;
      case 2 : 
      {
        MyMCP.digitalWrite(dig1,LOW);
        MyMCP.digitalWrite(dig2,HIGH);
        MyMCP.digitalWrite(dig3,HIGH);
        MyMCP.digitalWrite(dig4,HIGH);
        MyMCP.digitalWrite(N2,HIGH);
        delayMicroseconds(delaySeq);
        MyMCP.digitalWrite(N2,LOW);
      }break;
      case 3 : 
      {
        MyMCP.digitalWrite(dig1,LOW);
        MyMCP.digitalWrite(dig2,HIGH);
        MyMCP.digitalWrite(dig3,HIGH);
        MyMCP.digitalWrite(dig4,HIGH);
        MyMCP.digitalWrite(N3,HIGH);
        delayMicroseconds(delaySeq);
        MyMCP.digitalWrite(N3,LOW);
      }break;
      case 4 : 
      {
        MyMCP.digitalWrite(dig1,LOW);
        MyMCP.digitalWrite(dig2,HIGH);
        MyMCP.digitalWrite(dig3,HIGH);
        MyMCP.digitalWrite(dig4,HIGH);
        MyMCP.digitalWrite(N4,HIGH);
        delayMicroseconds(delaySeq);
        MyMCP.digitalWrite(N4,LOW);
      }break;
      case 5 : 
      {
        MyMCP.digitalWrite(dig1,LOW);
        MyMCP.digitalWrite(dig2,HIGH);
        MyMCP.digitalWrite(dig3,HIGH);
        MyMCP.digitalWrite(dig4,HIGH);
        MyMCP.digitalWrite(N5,HIGH);
        delayMicroseconds(delaySeq);
        MyMCP.digitalWrite(N5,LOW);
      }break;
      case 6 : 
      {
        MyMCP.digitalWrite(dig1,LOW);
        MyMCP.digitalWrite(dig2,HIGH);
        MyMCP.digitalWrite(dig3,HIGH);
        MyMCP.digitalWrite(dig4,HIGH);
        MyMCP.digitalWrite(N6,HIGH);
        delayMicroseconds(delaySeq);
        MyMCP.digitalWrite(N6,LOW);
      }break;
      case 7 : 
      {
        MyMCP.digitalWrite(dig1,LOW);
        MyMCP.digitalWrite(dig2,HIGH);
        MyMCP.digitalWrite(dig3,HIGH);
        MyMCP.digitalWrite(dig4,HIGH);
        MyMCP.digitalWrite(N7,HIGH);
        delayMicroseconds(delaySeq);
        MyMCP.digitalWrite(N7,LOW);
      }break;
      case 8 : 
      {
        MyMCP.digitalWrite(dig1,LOW);
        MyMCP.digitalWrite(dig2,HIGH);
        MyMCP.digitalWrite(dig3,HIGH);
        MyMCP.digitalWrite(dig4,HIGH);
        MyMCP.digitalWrite(N8,HIGH);
        delayMicroseconds(delaySeq);
        MyMCP.digitalWrite(N8,LOW);
      }break;
      case 9 : 
      {
        MyMCP.digitalWrite(dig1,LOW);
        MyMCP.digitalWrite(dig2,HIGH);
        MyMCP.digitalWrite(dig3,HIGH);
        MyMCP.digitalWrite(dig4,HIGH);
        MyMCP.digitalWrite(N9,HIGH);
        delayMicroseconds(delaySeq);
        MyMCP.digitalWrite(N9,LOW);
      }break;
    }
    switch (value/10)
    {
      case 0 : 
      {
        MyMCP.digitalWrite(dig1,HIGH);
        MyMCP.digitalWrite(dig2,LOW);
        MyMCP.digitalWrite(dig3,HIGH);
        MyMCP.digitalWrite(dig4,HIGH);
        MyMCP.digitalWrite(N0,HIGH);
        delayMicroseconds(delaySeq);
        MyMCP.digitalWrite(N0,LOW);
      }break;
      case 1 : 
      {
        MyMCP.digitalWrite(dig1,HIGH);
        MyMCP.digitalWrite(dig2,LOW);
        MyMCP.digitalWrite(dig3,HIGH);
        MyMCP.digitalWrite(dig4,HIGH);
        MyMCP.digitalWrite(N1,HIGH);
        delayMicroseconds(delaySeq);
        MyMCP.digitalWrite(N1,LOW);
      }break;
      case 2 : 
      {
        MyMCP.digitalWrite(dig1,HIGH);
        MyMCP.digitalWrite(dig2,LOW);
        MyMCP.digitalWrite(dig3,HIGH);
        MyMCP.digitalWrite(dig4,HIGH);
        MyMCP.digitalWrite(N2,HIGH);
        delayMicroseconds(delaySeq);
        MyMCP.digitalWrite(N2,LOW);
      }break;
      case 3 : 
      {
        MyMCP.digitalWrite(dig1,HIGH);
        MyMCP.digitalWrite(dig2,LOW);
        MyMCP.digitalWrite(dig3,HIGH);
        MyMCP.digitalWrite(dig4,HIGH);
        MyMCP.digitalWrite(N3,HIGH);
        delayMicroseconds(delaySeq);
        MyMCP.digitalWrite(N3,LOW);
      }break;
      case 4 : 
      {
        MyMCP.digitalWrite(dig1,HIGH);
        MyMCP.digitalWrite(dig2,LOW);
        MyMCP.digitalWrite(dig3,HIGH);
        MyMCP.digitalWrite(dig4,HIGH);
        MyMCP.digitalWrite(N4,HIGH);
        delayMicroseconds(delaySeq);
        MyMCP.digitalWrite(N4,LOW);
      }break;
      case 5 : 
      {
        MyMCP.digitalWrite(dig1,HIGH);
        MyMCP.digitalWrite(dig2,LOW);
        MyMCP.digitalWrite(dig3,HIGH);
        MyMCP.digitalWrite(dig4,HIGH);
        MyMCP.digitalWrite(N5,HIGH);
        delayMicroseconds(delaySeq);
        MyMCP.digitalWrite(N5,LOW);
      }break;
      case 6 : 
      {
        MyMCP.digitalWrite(dig1,HIGH);
        MyMCP.digitalWrite(dig2,LOW);
        MyMCP.digitalWrite(dig3,HIGH);
        MyMCP.digitalWrite(dig4,HIGH);
        MyMCP.digitalWrite(N6,HIGH);
        delayMicroseconds(delaySeq);
        MyMCP.digitalWrite(N6,LOW);
      }break;
      case 7 : 
      {
        MyMCP.digitalWrite(dig1,HIGH);
        MyMCP.digitalWrite(dig2,LOW);
        MyMCP.digitalWrite(dig3,HIGH);
        MyMCP.digitalWrite(dig4,HIGH);
        MyMCP.digitalWrite(N7,HIGH);
        delayMicroseconds(delaySeq);
        MyMCP.digitalWrite(N7,LOW);
      }break;
      case 8 : 
      {
        MyMCP.digitalWrite(dig1,HIGH);
        MyMCP.digitalWrite(dig2,LOW);
        MyMCP.digitalWrite(dig3,HIGH);
        MyMCP.digitalWrite(dig4,HIGH);
        MyMCP.digitalWrite(N8,HIGH);
        delayMicroseconds(delaySeq);
        MyMCP.digitalWrite(N8,LOW);
      }break;
      case 9 : 
      {
        MyMCP.digitalWrite(dig1,HIGH);
        MyMCP.digitalWrite(dig2,LOW);
        MyMCP.digitalWrite(dig3,HIGH);
        MyMCP.digitalWrite(dig4,HIGH);
        MyMCP.digitalWrite(N9,HIGH);
        delayMicroseconds(delaySeq);
        MyMCP.digitalWrite(N9,LOW);
      }break;
    }
  }
  if(side=="left")
  {
    switch (value%10)
    {
      case 0 : 
      {
        MyMCP.digitalWrite(dig1,HIGH);
        MyMCP.digitalWrite(dig2,HIGH);
        MyMCP.digitalWrite(dig3,LOW);
        MyMCP.digitalWrite(dig4,HIGH);
        MyMCP.digitalWrite(N0,HIGH);
        delayMicroseconds(delaySeq);
        MyMCP.digitalWrite(N0,LOW);
      }break;
      case 1 : 
      {
        MyMCP.digitalWrite(dig1,HIGH);
        MyMCP.digitalWrite(dig2,HIGH);
        MyMCP.digitalWrite(dig3,LOW);
        MyMCP.digitalWrite(dig4,HIGH);
        MyMCP.digitalWrite(N1,HIGH);
        delayMicroseconds(delaySeq);
        MyMCP.digitalWrite(N1,LOW);
      }break;
      case 2 : 
      {
        MyMCP.digitalWrite(dig1,HIGH);
        MyMCP.digitalWrite(dig2,HIGH);
        MyMCP.digitalWrite(dig3,LOW);
        MyMCP.digitalWrite(dig4,HIGH);
        MyMCP.digitalWrite(N2,HIGH);
        delayMicroseconds(delaySeq);
        MyMCP.digitalWrite(N2,LOW);
      }break;
      case 3 : 
      {
        MyMCP.digitalWrite(dig1,HIGH);
        MyMCP.digitalWrite(dig2,HIGH);
        MyMCP.digitalWrite(dig3,LOW);
        MyMCP.digitalWrite(dig4,HIGH);
        MyMCP.digitalWrite(N3,HIGH);
        delayMicroseconds(delaySeq);
        MyMCP.digitalWrite(N3,LOW);
      }break;
      case 4 : 
      {
        MyMCP.digitalWrite(dig1,HIGH);
        MyMCP.digitalWrite(dig2,HIGH);
        MyMCP.digitalWrite(dig3,LOW);
        MyMCP.digitalWrite(dig4,HIGH);
        MyMCP.digitalWrite(N4,HIGH);
        delayMicroseconds(delaySeq);
        MyMCP.digitalWrite(N4,LOW);
      }break;
      case 5 : 
      {
        MyMCP.digitalWrite(dig1,HIGH);
        MyMCP.digitalWrite(dig2,HIGH);
        MyMCP.digitalWrite(dig3,LOW);
        MyMCP.digitalWrite(dig4,HIGH);
        MyMCP.digitalWrite(N5,HIGH);
        delayMicroseconds(delaySeq);
        MyMCP.digitalWrite(N5,LOW);
      }break;
      case 6 : 
      {
        MyMCP.digitalWrite(dig1,HIGH);
        MyMCP.digitalWrite(dig2,HIGH);
        MyMCP.digitalWrite(dig3,LOW);
        MyMCP.digitalWrite(dig4,HIGH);
        MyMCP.digitalWrite(N6,HIGH);
        delayMicroseconds(delaySeq);
        MyMCP.digitalWrite(N6,LOW);
      }break;
      case 7 : 
      {
        MyMCP.digitalWrite(dig1,HIGH);
        MyMCP.digitalWrite(dig2,HIGH);
        MyMCP.digitalWrite(dig3,LOW);
        MyMCP.digitalWrite(dig4,HIGH);
        MyMCP.digitalWrite(N7,HIGH);
        delayMicroseconds(delaySeq);
        MyMCP.digitalWrite(N7,LOW);
      }break;
      case 8 : 
      {
        MyMCP.digitalWrite(dig1,HIGH);
        MyMCP.digitalWrite(dig2,HIGH);
        MyMCP.digitalWrite(dig3,LOW);
        MyMCP.digitalWrite(dig4,HIGH);
        MyMCP.digitalWrite(N8,HIGH);
        delayMicroseconds(delaySeq);
        MyMCP.digitalWrite(N8,LOW);
      }break;
      case 9 : 
      {
        MyMCP.digitalWrite(dig1,HIGH);
        MyMCP.digitalWrite(dig2,HIGH);
        MyMCP.digitalWrite(dig3,LOW);
        MyMCP.digitalWrite(dig4,HIGH);
        MyMCP.digitalWrite(N9,HIGH);
        delayMicroseconds(delaySeq);
        MyMCP.digitalWrite(N9,LOW);
      }break;
    }
    switch (value/10)
    {
      case 0 : 
      {
        MyMCP.digitalWrite(dig1,HIGH);
        MyMCP.digitalWrite(dig2,HIGH);
        MyMCP.digitalWrite(dig3,HIGH);
        MyMCP.digitalWrite(dig4,LOW);
        MyMCP.digitalWrite(N0,HIGH);
        delayMicroseconds(delaySeq);
        MyMCP.digitalWrite(N0,LOW);
      }break;
      case 1 : 
      {
        MyMCP.digitalWrite(dig1,HIGH);
        MyMCP.digitalWrite(dig2,HIGH);
        MyMCP.digitalWrite(dig3,HIGH);
        MyMCP.digitalWrite(dig4,LOW);
        MyMCP.digitalWrite(N1,HIGH);
        delayMicroseconds(delaySeq);
        MyMCP.digitalWrite(N1,LOW);
      }break;
      case 2 : 
      {
        MyMCP.digitalWrite(dig1,HIGH);
        MyMCP.digitalWrite(dig2,HIGH);
        MyMCP.digitalWrite(dig3,HIGH);
        MyMCP.digitalWrite(dig4,LOW);
        MyMCP.digitalWrite(N2,HIGH);
        delayMicroseconds(delaySeq);
        MyMCP.digitalWrite(N2,LOW);
      }break;
      case 3 : 
      {
        MyMCP.digitalWrite(dig1,HIGH);
        MyMCP.digitalWrite(dig2,HIGH);
        MyMCP.digitalWrite(dig3,HIGH);
        MyMCP.digitalWrite(dig4,LOW);
        MyMCP.digitalWrite(N3,HIGH);
        delayMicroseconds(delaySeq);
        MyMCP.digitalWrite(N3,LOW);
      }break;
      case 4 : 
      {
        MyMCP.digitalWrite(dig1,HIGH);
        MyMCP.digitalWrite(dig2,HIGH);
        MyMCP.digitalWrite(dig3,HIGH);
        MyMCP.digitalWrite(dig4,LOW);
        MyMCP.digitalWrite(N4,HIGH);
        delayMicroseconds(delaySeq);
        MyMCP.digitalWrite(N4,LOW);
      }break;
      case 5 : 
      {
        MyMCP.digitalWrite(dig1,HIGH);
        MyMCP.digitalWrite(dig2,HIGH);
        MyMCP.digitalWrite(dig3,HIGH);
        MyMCP.digitalWrite(dig4,LOW);
        MyMCP.digitalWrite(N5,HIGH);
        delayMicroseconds(delaySeq);
        MyMCP.digitalWrite(N5,LOW);
      }break;
      case 6 : 
      {
        MyMCP.digitalWrite(dig1,HIGH);
        MyMCP.digitalWrite(dig2,HIGH);
        MyMCP.digitalWrite(dig3,HIGH);
        MyMCP.digitalWrite(dig4,LOW);
        MyMCP.digitalWrite(N6,HIGH);
        delayMicroseconds(delaySeq);
        MyMCP.digitalWrite(N6,LOW);
      }break;
      case 7 : 
      {
        MyMCP.digitalWrite(dig1,HIGH);
        MyMCP.digitalWrite(dig2,HIGH);
        MyMCP.digitalWrite(dig3,HIGH);
        MyMCP.digitalWrite(dig4,LOW);
        MyMCP.digitalWrite(N7,HIGH);
        delayMicroseconds(delaySeq);
        MyMCP.digitalWrite(N7,LOW);
      }break;
      case 8 : 
      {
        MyMCP.digitalWrite(dig1,HIGH);
        MyMCP.digitalWrite(dig2,HIGH);
        MyMCP.digitalWrite(dig3,HIGH);
        MyMCP.digitalWrite(dig4,LOW);
        MyMCP.digitalWrite(N8,HIGH);
        delayMicroseconds(delaySeq);
        MyMCP.digitalWrite(N8,LOW);
      }break;
      case 9 : 
      {
        MyMCP.digitalWrite(dig1,HIGH);
        MyMCP.digitalWrite(dig2,HIGH);
        MyMCP.digitalWrite(dig3,HIGH);
        MyMCP.digitalWrite(dig4,LOW);
        MyMCP.digitalWrite(N9,HIGH);
        delayMicroseconds(delaySeq);
        MyMCP.digitalWrite(dig4,LOW);
        MyMCP.digitalWrite(N9,LOW);
      }break;
    }
  }
}
String getValue(String data, char separator, int index)
{
    int found = 0;
    int strIndex[] = { 0, -1 };
    int maxIndex = data.length() - 1;

    for (int i = 0; i <= maxIndex && found <= index; i++) 
    {
        if (data.charAt(i) == separator || i == maxIndex) 
        {
            found++;
            strIndex[0] = strIndex[1] + 1;
            strIndex[1] = (i == maxIndex) ? i+1 : i;
        }
    }
    return found > index ? data.substring(strIndex[0], strIndex[1]) : "";
}

Credits

MEGA DAS

MEGA DAS

16 projects • 139 followers
MEGA Development of Automated System is a free community responsible for creating automated systems standing on robotics engineering field
Thanks to JLCPCB.

Comments

Add projectSign up / Login