Infineon Team
Published © MIT

Ring in the New Year with an XMC based Mechanical Display

Check out how you can use the famous XMC4700 to make a mechanical 7 Segment Display!

IntermediateFull instructions provided8 hours1,934

Things used in this project

Hardware components

KIT XMC47 RELAX LITE V1
Infineon KIT XMC47 RELAX LITE V1
×2
SG90 Micro-servo motor
SG90 Micro-servo motor
×35
Breadboard (generic)
Breadboard (generic)
Any breadboard that has at least 35 +/- rows
×1

Software apps and online services

Arduino IDE
Arduino IDE
Preferably Arduino IDE 2.0

Hand tools and fabrication machines

3D Printer (generic)
3D Printer (generic)
Drill / Driver, Cordless
Drill / Driver, Cordless
Any electric drill will do
Servo Motor, Premium Male/Male Jumper Wires
Servo Motor, Premium Male/Male Jumper Wires
Any Malet-to-Male jumper cables will do, preferably long ones (60 cm). About 105 Jumper cables (35x 20 cm and 70x 60 cm)
Hot glue gun (generic)
Hot glue gun (generic)
Any Hot glue gun will do
Custom Plywood Plate (800x340) mm
Thickness is generic. Here 6mm thickness is used
Laser cutter (generic)
Laser cutter (generic)
Power Supply
At least 5V 2A are needed

Story

Read more

Custom parts and enclosures

Lasercut SVG file

This is the SVG file to upload to the EpilogLaser cutter. Note that not all Lasercutters use the same presets to distinguish between cutting, marking, and engraving.

Segment

3D Model of the segment provided by Michael Klements
https://www.the-diy-life.com/mechanical-7-segment-display-clock-using-an-arduino-28-servos/

Spacer

3D Model of the Spacer, where the motor is glued on and glued on the board.
Provided by Michael Klements
https://www.the-diy-life.com/mechanical-7-segment-display-clock-using-an-arduino-28-servos/

Code

7 Segment Encoder 1

Arduino
The Code for the first XMC4700 Relax Kit that's connected to the first 3 letters/digits
//    Arduino form factor PWM Pins
//   /* 3  */    {XMC_GPIO_PORT1, 1},   // PWM40-2(PWM0) / External INT 1  P1.1
//   /* 5  */    {XMC_GPIO_PORT2, 12},  // PWM81-3 output / PWM1        P2.12
//   /* 6  */    {XMC_GPIO_PORT2, 11},  // PWM80-2 output / PWM2        P2.11
//   /* 9  */    {XMC_GPIO_PORT1, 11},  // PWM81-1 output / PWM3        P1.11
//   /* 10  */   {XMC_GPIO_PORT3, 10},  // SPI-SS / PWM41-0 / PWM4      P3.10
//   /* 11  */   {XMC_GPIO_PORT3, 8},   // SPI-MOSI / PWM41-2 / PWM5    P3.8

//   PWM Pins of X1 starting here
//   /* 34  */   {XMC_GPIO_PORT3, 4},   // PWM42-2 / PWM12              P3.4     X1-1
//   /* 36  */   {XMC_GPIO_PORT0, 3},   // PWM80-2 / PWM10              P0.3     X1-5
//   /* 37  */   {XMC_GPIO_PORT0, 1},   // PWM80-1 / PWM9               P0.1     X1-7
//   /* 51  */   {XMC_GPIO_PORT5, 11},  // PWM80-0 / PWM6               P5.11    X1-34
//   /* 61  */   {XMC_GPIO_PORT3, 0},   // PWM42-0 / PWM7               P3.0     X1-14
//   /* 62  */   {XMC_GPIO_PORT0, 9},   // PWM80-1 / PWM8               P0.9     X1-12
//   /* 66  */   {XMC_GPIO_PORT0, 6},   // PWM80-3 / PWM11              P0.6     X1-4

//   PWM Pins of X2 starting here
//   /* 70  */   {XMC_GPIO_PORT0, 14},  // PWM40-1 / PWM21              P0.14    X2-5
//   /* 76  */   {XMC_GPIO_PORT6, 5},   // PWM43-0 / PWM17              P6.5     X2-17
//   /* 77  */   {XMC_GPIO_PORT1, 15},  // PWM81-0 / PWM16              P1.15    X2-19
//   /* 79 */    {XMC_GPIO_PORT5, 3},   // PWM81-2 / PWM15              P5.3     X2-23
//   /* 80  */   {XMC_GPIO_PORT5, 5},   // PWM81-1 / PWM14              P5.5     X2-25
//   /* 81  */   {XMC_GPIO_PORT5, 7},   // PWM81-0 / PWM13              P5.7     X2-27
//   /* 88  */   {XMC_GPIO_PORT6, 4},   // PWM43-1 / PWM18              P6.4     X2-16
//   /* 89  */   {XMC_GPIO_PORT6, 2},   // PWM43-3 / PWM19              P6.2     X2-14
//   /* 93  */   {XMC_GPIO_PORT0, 15},  // PWM40-0 / PWM20              P0.15    X2-6
//   /* 94  */   {XMC_GPIO_PORT0, 12},  // PWM40-3 / PWM22              P0.12    X2-4



/*

This project uses 2 XMC4700 Relax Kit Boards to write Happy New Year with a mechanical 7 segment display driven
by 35 individual Servo motors. 
However, the XMC4700 only has 23 PWM pins to drive the motors with, so we need 2 boards.
                    
                  ___2__
                 |      |
              0  |      |  5
                 |___3__|
                 |      |
              1  |      |  6
                 |___4__|

The 7 Segment display of any Character is numbered as seen above
First letter of the whole word will be called Alpha, 2nd one Bravo, 3rd Charlie, etc. (Phonetic Alphabet)
e.g "BRAVO6" is the bottom right segment (Segment number 6) of the 2nd letter in the word

About the delays: you can change them if you want, but if the segments are really close together a 10-15 ms delay would be recommended to 
avoid collisions, if not you can do a 1ms delay (removing it is not recommended because this can possibly draw too much current that a 
simple power adapter could handle)

THIS IS THE 1ST BOARD-COVERING SEGMENTS: ALPHA,BRAVO & CHARLIE
*/

uint8_t allPins[3][7]={{34,36,37,51,61,62,66},{70,76,77,79,80,81,88},{89,93,94,3,5,6,9}}; //only three because technically 2nd board also uses first two pin packages

uint8_t pins[7]={3,4,2,0,1,5,6}; //pin array to assign the corresponding pin package to - in that order (using schematic above as reference)

uint8_t Wpins1_2[14]={34,36,37,51,61,62,66,70,76,77,79,80,81,88};
uint8_t Wpins2_3[14]={70,76,77,79,80,81,88,89,93,94,3,5,6,9};
uint8_t Wpins3[14]={89,93,94,3,5,6,9};


uint8_t alphaPins[7]={34,36,37,51,61,62,66};//1st letter or digit
uint8_t bravoPins[7]={70,76,77,79,80,81,88};//2nd letter or digit
uint8_t charliePins[7]={89,93,94,3,5,6,9};//3rd letter or digit

//for the second board

// uint8_t deltaPins[7]={34,36,37,51,61,62,66};//4th letter or digit
// uint8_t echoPins[7]={70,76,77,79,80,81,88};//5th letter or digit



uint8_t startSignal=2;     /*PIN of the Signal from first board to also start moving Servos in the second board*/
double mspulse;       /*The pulse duration in milliseconds {0.5ms=0  1.5ms=90   2.5ms=180}*/
uint8_t freq = 50;        /*Frequency of the PWM in Hz (default is 490, but set it to 50Hz to match duty cycle of data sheets)*/
int resolution = 256; /*Resolution of the Duty Cycle in 2^(8,10,12,16)*/


/*calculates the Duty Cycle in respect to the frequency and bit resolution for a chosen pulse width*/
int toAnalogWrite(double mspulse, int freq, int resolution){ 
  int window = 1000 / freq;
  return ceil((mspulse / window) * resolution);
}

/*
    @brief  Each Segment (or each Servo Motor) is an Object which can have two modes, either show or hide (methods)
            with combinations of show and hide you can display a letter made of seven segments, hence seven
            segment display
    
*/
class Segment
{
  private:
  public:

  int pin;
  uint8_t pos;

  /*
      @brief sets the segment in show mode i.e. Servo is 90 
      @param pin which the PWM wire of the Servo is connected to 
  */
  bool show(int pin)
  {
      analogWrite(pin,toAnalogWrite(1.5,freq,resolution));
      return true;
  }

  /*
      @brief sets the segment in hide mode i.e depending on servo orientation either 180 or 0.
      @param pin which the PWM wire of the Servo is connected to.
      @param pos is the position of the servo(segment) as shown at the top.
  */
  bool hide(int pin,int pos)
  {
      switch (pos)
      {
          case 0:
              analogWrite(pin,toAnalogWrite(2.5,freq,resolution));
              break;
          case 1:
              analogWrite(pin,toAnalogWrite(2.5,freq,resolution));
              break;
          case 2:
              analogWrite(pin,toAnalogWrite(0.5,freq,resolution));
              break;
          case 3:
              analogWrite(pin,toAnalogWrite(0.5,freq,resolution));
              break;
          case 4:
              analogWrite(pin,toAnalogWrite(2.5,freq,resolution));
              break;
          case 5:
              analogWrite(pin,toAnalogWrite(0.5,freq,resolution));
              break;
          case 6:
              analogWrite(pin,toAnalogWrite(0.5,freq,resolution));
              break;
          
          default:
              break;
      }
      return true;
  }
};

//Digit is an array of Segments
Segment Zero,One,Two,Three,Four,Five,Six;
Segment Digit[7]={Three,Four,Two,Zero,Five,One,Six};

/*
  @brief: This functions lets all the Segments go into hide mode
*/
void hideAll()
{
  int ctr=6;
  for(int i=0;i<3;i++)
  {
    for(ctr=6;ctr>=0;ctr--)
    {
      Digit[ctr].hide(allPins[i][ctr],allPins[i][ctr]);
      delay(10); 
    }
  }
}

void displayA()
{   uint8_t ctr=0;  Digit[ctr].show(pins[ctr]);ctr+=2;   Digit[ctr].show(pins[ctr]);ctr++;   Digit[ctr].show(pins[ctr]);ctr++;   Digit[ctr].show(pins[ctr]);ctr++;   Digit[ctr].show(pins[ctr]);ctr++;   Digit[ctr].show(pins[ctr]);                                   }
void displayB()
{   uint8_t ctr=0;  Digit[ctr].show(pins[ctr]);ctr++;   Digit[ctr].show(pins[ctr]);ctr++;   Digit[ctr].show(pins[ctr]);ctr++;   Digit[ctr].show(pins[ctr]);ctr++;   Digit[ctr].show(pins[ctr]);ctr++;   Digit[ctr].show(pins[ctr]);ctr++;   Digit[ctr].show(pins[ctr]);     }
void displayC()
{   uint8_t ctr=1;  Digit[ctr].show(pins[ctr]);ctr++;   Digit[ctr].show(pins[ctr]);ctr++;   Digit[ctr].show(pins[ctr]);ctr++;   Digit[ctr].show(pins[ctr]);                                                                                                           }
void displayD()
{   uint8_t ctr=1;  Digit[ctr].show(pins[ctr]);ctr++;   Digit[ctr].show(pins[ctr]);ctr++;   Digit[ctr].show(pins[ctr]);ctr++;   Digit[ctr].show(pins[ctr]);ctr++;   Digit[ctr].show(pins[ctr]);ctr++;    Digit[ctr].show(pins[ctr]);     }
void displayE()
{   uint8_t ctr=0;  Digit[ctr].show(pins[ctr]);ctr++;   Digit[ctr].show(pins[ctr]);ctr++;   Digit[ctr].show(pins[ctr]);ctr++;   Digit[ctr].show(pins[ctr]);ctr++;   Digit[ctr].show(pins[ctr]);                                                                       }
void displayF()
{   uint8_t ctr=0;  Digit[ctr].show(pins[ctr]);ctr+=2;   Digit[ctr].show(pins[ctr]);ctr++;   Digit[ctr].show(pins[ctr]);ctr++;   Digit[ctr].show(pins[ctr]);                                                                                                           }
void displayG()
{   uint8_t ctr=0;  Digit[ctr].show(pins[ctr]);ctr++;   Digit[ctr].show(pins[ctr]);ctr++;   Digit[ctr].show(pins[ctr]);ctr++;   Digit[ctr].show(pins[ctr]);ctr++;   Digit[ctr].show(pins[ctr]);ctr+=2;   Digit[ctr].show(pins[ctr]);                                    }
void displayH()
{   uint8_t ctr=0;  Digit[ctr].show(pins[ctr]);ctr+=3;   Digit[ctr].show(pins[ctr]);ctr++;   Digit[ctr].show(pins[ctr]);ctr++;   Digit[ctr].show(pins[ctr]);ctr++;   Digit[ctr].show(pins[ctr]);                                                                       }
void displayI()
{   uint8_t ctr=5;  Digit[ctr].show(pins[ctr]);ctr++;   Digit[ctr].show(pins[ctr]);                                                                                                                                                                                         }
void displayJ()
{   uint8_t ctr=1;  Digit[ctr].show(pins[ctr]);ctr+=3;   Digit[ctr].show(pins[ctr]);ctr++;   Digit[ctr].show(pins[ctr]);ctr++;   Digit[ctr].show(pins[ctr]);                                                                                                           }

// void displayK() //no "K" in 7 Segment
// {   uint8_t ctr=0;  Digit[ctr].show(pins[ctr]);ctr++;   Digit[ctr].show(pins[ctr]);ctr++;   Digit[ctr].show(pins[ctr]);ctr++;   Digit[ctr].show(pins[ctr]);ctr++;   Digit[ctr].show(pins[ctr]);ctr++;   Digit[ctr].show(pins[ctr]);ctr++;   Digit[ctr].show(pins[ctr]);     }

void displayL()
{   uint8_t ctr=1;  Digit[ctr].show(pins[ctr]);ctr+=2;  Digit[ctr].show(pins[ctr]);ctr++;   Digit[ctr].show(pins[ctr]);                                                                                                                                               }
// void displayM() //no "M" in 7 segment
// {   uint8_t ctr=0;  Digit[ctr].show(pins[ctr]);ctr++;   Digit[ctr].show(pins[ctr]);ctr++;   Digit[ctr].show(pins[ctr]);ctr++;   Digit[ctr].show(pins[ctr]);ctr++;   Digit[ctr].show(pins[ctr]);ctr++;   Digit[ctr].show(pins[ctr]);ctr++;   Digit[ctr].show(pins[ctr]);     }

void displayN()
{   uint8_t ctr=2;  Digit[ctr].show(pins[ctr]);ctr++;   Digit[ctr].show(pins[ctr]);ctr++;   Digit[ctr].show(pins[ctr]);ctr++;   Digit[ctr].show(pins[ctr]);                                                                                                           }

// void displayO() //same as "D"
// {   uint8_t ctr=1;  Digit[ctr].show(pins[ctr]);ctr++;   Digit[ctr].show(pins[ctr]);ctr++;   Digit[ctr].show(pins[ctr]);ctr++;   Digit[ctr].show(pins[ctr]);ctr++;   Digit[ctr].show(pins[ctr]);ctr++;   Digit[ctr].show(pins[ctr]);                                   }

void displayP()
{   uint8_t ctr=0;  Digit[ctr].show(pins[ctr]);ctr+=2;  Digit[ctr].show(pins[ctr]);ctr++;   Digit[ctr].show(pins[ctr]);ctr++;   Digit[ctr].show(pins[ctr]);ctr++;   Digit[ctr].show(pins[ctr]);                                                                             }

// void displayQ() //no "Q" in 7 segment
// {   uint8_t ctr=0;  Digit[ctr].show(pins[ctr]);ctr++;   Digit[ctr].show(pins[ctr]);ctr++;   Digit[ctr].show(pins[ctr]);ctr++;   Digit[ctr].show(pins[ctr]);ctr++;   Digit[ctr].show(pins[ctr]);ctr++;   Digit[ctr].show(pins[ctr]);ctr++;   Digit[ctr].show(pins[ctr]);     }

void displayR() //lowercase r
{   uint8_t ctr=2;  Digit[ctr].show(pins[ctr]);ctr++;   Digit[ctr].show(pins[ctr]);ctr++;   Digit[ctr].show(pins[ctr]);ctr++;                                                                                                                                               }
void displayS()
{   uint8_t ctr=0;  Digit[ctr].show(pins[ctr]);ctr++;   Digit[ctr].show(pins[ctr]);ctr++;   Digit[ctr].show(pins[ctr]);ctr++;   Digit[ctr].show(pins[ctr]);ctr+=3;   Digit[ctr].show(pins[ctr]);                                                                            }

// void displayT() //no "T" in 7 Segment
// {   uint8_t ctr=0;  Digit[ctr].show(pins[ctr]);ctr++;   Digit[ctr].show(pins[ctr]);ctr++;   Digit[ctr].show(pins[ctr]);ctr++;   Digit[ctr].show(pins[ctr]);ctr++;   Digit[ctr].show(pins[ctr]);ctr++;   Digit[ctr].show(pins[ctr]);ctr++;   Digit[ctr].show(pins[ctr]);     }

void displayU()
{   uint8_t ctr=1;  Digit[ctr].show(pins[ctr]);ctr+=2;   Digit[ctr].show(pins[ctr]);ctr++;   Digit[ctr].show(pins[ctr]);ctr++;   Digit[ctr].show(pins[ctr]);ctr++;   Digit[ctr].show(pins[ctr]);ctr++;   Digit[ctr].show(pins[ctr]);ctr++;   Digit[ctr].show(pins[ctr]);     }

// void displayV() //no "V" in 7 Segment
// {   uint8_t ctr=0;  Digit[ctr].show(pins[ctr]);ctr++;   Digit[ctr].show(pins[ctr]);ctr++;   Digit[ctr].show(pins[ctr]);ctr++;   Digit[ctr].show(pins[ctr]);ctr++;   Digit[ctr].show(pins[ctr]);ctr++;   Digit[ctr].show(pins[ctr]);ctr++;   Digit[ctr].show(pins[ctr]);     }

//because "W" takes two 7 segments 
void displayW1_2()
{   uint8_t ctr=1;  Digit[ctr].show(Wpins1_2[ctr]);ctr+=2;   Digit[ctr].show(Wpins1_2[ctr]);ctr++;   Digit[ctr].show(Wpins1_2[ctr]);ctr+=2; Digit[ctr].show(Wpins1_2[ctr]);ctr+=2;  
                    Digit[ctr].show(Wpins1_2[ctr]);ctr+=3;   Digit[ctr].show(Wpins1_2[ctr]);ctr++;   Digit[ctr].show(Wpins1_2[ctr]);ctr++;  Digit[ctr].show(Wpins1_2[ctr]);                                                                                                                                                                                    }
void displayW2_3()
{   uint8_t ctr=1;  Digit[ctr].show(Wpins2_3[ctr]);ctr+=2;   Digit[ctr].show(Wpins2_3[ctr]);ctr++;   Digit[ctr].show(Wpins2_3[ctr]);ctr+=2; Digit[ctr].show(Wpins2_3[ctr]);ctr+=2;  
                    Digit[ctr].show(Wpins2_3[ctr]);ctr+=3;   Digit[ctr].show(Wpins2_3[ctr]);ctr++;   Digit[ctr].show(Wpins2_3[ctr]);ctr++;  Digit[ctr].show(Wpins2_3[ctr]);                                                                                                                                                                                    }
void displayW3()
{   uint8_t ctr=1;  Digit[ctr].show(Wpins3[ctr]);ctr+=2;   Digit[ctr].show(Wpins3[ctr]);ctr++;   Digit[ctr].show(Wpins3[ctr]);ctr+=2; Digit[ctr].show(Wpins3[ctr]);                                                                                                                 }

// void displayX() //no x in 7 segment
// {   uint8_t ctr=0;  Digit[ctr].show(pins[ctr]);ctr++;   Digit[ctr].show(pins[ctr]);ctr++;   Digit[ctr].show(pins[ctr]);ctr++;   Digit[ctr].show(pins[ctr]);ctr++;   Digit[ctr].show(pins[ctr]);ctr++;   Digit[ctr].show(pins[ctr]);ctr++;   Digit[ctr].show(pins[ctr]);     }

void displayY()
{   uint8_t ctr=0;  Digit[ctr].show(pins[ctr]);ctr++;   Digit[ctr].show(pins[ctr]);ctr+=2;   Digit[ctr].show(pins[ctr]);ctr+=2; Digit[ctr].show(pins[ctr]);ctr++; Digit[ctr].show(pins[ctr]);                                                                               }
void displayZ()
{   uint8_t ctr=0;  Digit[ctr].show(pins[ctr]);ctr++;   Digit[ctr].show(pins[ctr]);ctr++;   Digit[ctr].show(pins[ctr]);ctr+=2;   Digit[ctr].show(pins[ctr]);ctr++;   Digit[ctr].show(pins[ctr]);                                                                            }

// Displaying Numbers

// void display0() //same as "O"
// {   uint8_t ctr=0;  Digit[ctr].show(pins[ctr]);ctr++;   Digit[ctr].show(pins[ctr]);ctr++;   Digit[ctr].show(pins[ctr]);ctr++;   Digit[ctr].show(pins[ctr]);ctr++;   Digit[ctr].show(pins[ctr]);ctr++;   Digit[ctr].show(pins[ctr]);ctr++;   Digit[ctr].show(pins[ctr]);     }

// void display1() //same as "I"
// {   uint8_t ctr=0;  Digit[ctr].show(pins[ctr]);ctr++;   Digit[ctr].show(pins[ctr]);ctr++;   Digit[ctr].show(pins[ctr]);ctr++;   Digit[ctr].show(pins[ctr]);ctr++;   Digit[ctr].show(pins[ctr]);ctr++;   Digit[ctr].show(pins[ctr]);ctr++;   Digit[ctr].show(pins[ctr]);     }

// void display2() //same as "Z"
// {   uint8_t ctr=0;  Digit[ctr].show(pins[ctr]);ctr++;   Digit[ctr].show(pins[ctr]);ctr++;   Digit[ctr].show(pins[ctr]);ctr++;   Digit[ctr].show(pins[ctr]);ctr++;   Digit[ctr].show(pins[ctr]);ctr++;   Digit[ctr].show(pins[ctr]);ctr++;   Digit[ctr].show(pins[ctr]);     }

void display3()
{   uint8_t ctr=0;  Digit[ctr].show(pins[ctr]);ctr++;   Digit[ctr].show(pins[ctr]);ctr++;   Digit[ctr].show(pins[ctr]);ctr+=3;  Digit[ctr].show(pins[ctr]);ctr++;  Digit[ctr].show(pins[ctr]);                                                                              }
void display4()
{   uint8_t ctr=0;  Digit[ctr].show(pins[ctr]);ctr+=3;  Digit[ctr].show(pins[ctr]);ctr+=2;   Digit[ctr].show(pins[ctr]);ctr++;   Digit[ctr].show(pins[ctr]);ctr++; Digit[ctr].show(pins[ctr]);                                                                              }
void display5()
{   uint8_t ctr=0;  Digit[ctr].show(pins[ctr]);ctr++;   Digit[ctr].show(pins[ctr]);ctr++;   Digit[ctr].show(pins[ctr]);ctr++;   Digit[ctr].show(pins[ctr]);ctr+=3; Digit[ctr].show(pins[ctr]);                                                                              }

// void display6() //same as "G"
// {   uint8_t ctr=0;  Digit[ctr].show(pins[ctr]);ctr++;   Digit[ctr].show(pins[ctr]);ctr++;   Digit[ctr].show(pins[ctr]);ctr++;   Digit[ctr].show(pins[ctr]);ctr++;   Digit[ctr].show(pins[ctr]);ctr++;   Digit[ctr].show(pins[ctr]);ctr++;   Digit[ctr].show(pins[ctr]);     }

void display7()
{   uint8_t ctr=2;  Digit[ctr].show(pins[ctr]);ctr+=3;   Digit[ctr].show(pins[ctr]);ctr++;  Digit[ctr].show(pins[ctr]);                                                                                                                                                     }

// void display8() //same as "B"
// {   uint8_t ctr=0;  Digit[ctr].show(pins[ctr]);ctr++;   Digit[ctr].show(pins[ctr]);ctr++;   Digit[ctr].show(pins[ctr]);ctr++;   Digit[ctr].show(pins[ctr]);ctr++;   Digit[ctr].show(pins[ctr]);ctr++;   Digit[ctr].show(pins[ctr]);ctr++;   Digit[ctr].show(pins[ctr]);     }

void display9()
{   uint8_t ctr=0;  Digit[ctr].show(pins[ctr]);ctr++;   Digit[ctr].show(pins[ctr]);ctr++;   Digit[ctr].show(pins[ctr]);ctr++;   Digit[ctr].show(pins[ctr]);ctr+=2;   Digit[ctr].show(pins[ctr]);ctr++;      Digit[ctr].show(pins[ctr]);                                     }
   

/*
    @brief Takes a String (const char array) and translates it to motor motion to display it on the mechanical
            7 segment display.
    
    @param word of type string and is the word to translate 
*/
void encodeThis(String myWord)
{
    
    for(int idx=0;idx<5;idx++)
    {
        switch (idx)
        {   
            case 0: 
              for(int itr=0;itr<7;itr++){
                pins[itr]=alphaPins[itr];
              }
                break;
            case 1: 
                for(int itr=0;itr<7;itr++){
                pins[itr]=bravoPins[itr];
              }
              break;
            case 2: 
                for(int itr=0;itr<7;itr++){
                pins[itr]=charliePins[itr];
              }
                break;
            // case 3: digitalWrite(startSignal, HIGH);
            //      break;
            // case 4: digitalWrite(startSignal, HIGH);
            //      break;
            
            default:Serial.println("meant for the other board!");
                break;
        }

        switch (myWord[idx])
        {
            case 'A':displayA();break;      case 'B':displayB();break;      case 'C': displayC();
            case 'D':displayD();break;      case 'E':displayE();break;      case 'F': displayF();
            case 'G':displayG();break;      case 'H':displayH();break;      case 'I': displayI();
            case 'J':displayJ();break;                                      case 'L': displayL();
                                            case 'N':displayN();break;      case 'O': displayD();
            case 'P':displayP();break;                                      case 'R': displayR();
            case 'S':displayS();break;                                      case 'U': displayU();
                                                                            
            case 'Y':displayY();break;      case 'Z':displayZ();break;      case '0': displayD();
            case '1':displayI();break;      case '2':displayZ();break;      case '3': display3();
            case '4':display4();break;      case '5':display5();break;      case '6': displayG();
            case '7':display7();break;      case '8':displayB();break;      case '9': display9();
            
            case 'W':
            if(idx==0)
            {
              displayW1_2();
            }
            else if(idx==1)
            {
              displayW2_3();
            }
            else if(idx==2)
            {
              displayW3();
              digitalWrite(startSignal,HIGH);
            }break;
            default: Serial.println("Can't do nosville");
                break;
        }
        
    }
}


void setup() {
  // put your setup code here, to run once:
  Serial.begin(9600);

  for(int i=0;i<3;i++)
  {
    for(int ctr=0;ctr<7;ctr++)
    {
      pinMode(allPins[i][ctr],OUTPUT);
      delay(5);
      setAnalogWriteFrequency(allPins[i][ctr],50);
      delay(5);
    }
  }
  pinMode(startSignal,OUTPUT);
}

void loop() {
  // put your main code here, to run repeatedly:
  delay(3000);

  digitalWrite(startSignal, HIGH);

  encodeThis("HAPPY");
  delay(2000);
  hideAll();

  encodeThis("NEW");
  delay(2000);
  hideAll();

  encodeThis("YEAR");
  delay(2000);
  hideAll();

  delay(3000);
  digitalWrite(startSignal, LOW);
  exit(0);
}

7 Segment Encoder 2

Arduino
The Code for the second XMC4700 Relax Kit that's connected to the last 2 letters/digits
//    Arduino form factor PWM Pins
//   /* 3  */    {XMC_GPIO_PORT1, 1},   // PWM40-2(PWM0) / External INT 1  P1.1
//   /* 5  */    {XMC_GPIO_PORT2, 12},  // PWM81-3 output / PWM1        P2.12
//   /* 6  */    {XMC_GPIO_PORT2, 11},  // PWM80-2 output / PWM2        P2.11
//   /* 9  */    {XMC_GPIO_PORT1, 11},  // PWM81-1 output / PWM3        P1.11
//   /* 10  */   {XMC_GPIO_PORT3, 10},  // SPI-SS / PWM41-0 / PWM4      P3.10
//   /* 11  */   {XMC_GPIO_PORT3, 8},   // SPI-MOSI / PWM41-2 / PWM5    P3.8

//   PWM Pins of X1 starting here
//   /* 34  */   {XMC_GPIO_PORT3, 4},   // PWM42-2 / PWM12              P3.4     X1-1
//   /* 36  */   {XMC_GPIO_PORT0, 3},   // PWM80-2 / PWM10              P0.3     X1-5
//   /* 37  */   {XMC_GPIO_PORT0, 1},   // PWM80-1 / PWM9               P0.1     X1-7
//   /* 51  */   {XMC_GPIO_PORT5, 11},  // PWM80-0 / PWM6               P5.11    X1-34
//   /* 61  */   {XMC_GPIO_PORT3, 0},   // PWM42-0 / PWM7               P3.0     X1-14
//   /* 62  */   {XMC_GPIO_PORT0, 9},   // PWM80-1 / PWM8               P0.9     X1-12
//   /* 66  */   {XMC_GPIO_PORT0, 6},   // PWM80-3 / PWM11              P0.6     X1-4

//   PWM Pins of X2 starting here
//   /* 70  */   {XMC_GPIO_PORT0, 14},  // PWM40-1 / PWM21              P0.14    X2-5
//   /* 76  */   {XMC_GPIO_PORT6, 5},   // PWM43-0 / PWM17              P6.5     X2-17
//   /* 77  */   {XMC_GPIO_PORT1, 15},  // PWM81-0 / PWM16              P1.15    X2-19
//   /* 79 */    {XMC_GPIO_PORT5, 3},   // PWM81-2 / PWM15              P5.3     X2-23
//   /* 80  */   {XMC_GPIO_PORT5, 5},   // PWM81-1 / PWM14              P5.5     X2-25
//   /* 81  */   {XMC_GPIO_PORT5, 7},   // PWM81-0 / PWM13              P5.7     X2-27
//   /* 88  */   {XMC_GPIO_PORT6, 4},   // PWM43-1 / PWM18              P6.4     X2-16
//   /* 89  */   {XMC_GPIO_PORT6, 2},   // PWM43-3 / PWM19              P6.2     X2-14
//   /* 93  */   {XMC_GPIO_PORT0, 15},  // PWM40-0 / PWM20              P0.15    X2-6
//   /* 94  */   {XMC_GPIO_PORT0, 12},  // PWM40-3 / PWM22              P0.12    X2-4



/*

This project uses 2 XMC4700 Relax Kit Boards to write Happy New Year with a mechanical 7 segment display driven
by 35 individual Servo motors. 
However, the XMC4700 only has 23 PWM pins to drive the motors with, so we need 2 boards.
                    
                  ___2__
                 |      |
              0  |      |  5
                 |___3__|
                 |      |
              1  |      |  6
                 |___4__|

The 7 Segment display of any Character is numbered as seen above
First letter of the whole word will be called Alpha, 2nd one Bravo, 3rd Charlie, etc. (Phonetic Alphabet)
e.g "BRAVO6" is the bottom right segment (Segment number 6) of the 2nd letter in the word

About the delays: you can change them if you want, but if the segments are really close together a 10-15 ms delay would be recommended to 
avoid collisions, if not you can do a 1ms delay (removing it is not recommended because this can possibly draw too much current that a 
simple power adapter could handle)

THIS IS THE 2ND BOARD - COVERING SEGMENTS: DELTA & ECHO
*/

uint8_t allPins[2][7]={{34,36,37,51,61,62,66},{70,76,77,79,80,81,88}}; //only two here

uint8_t pins[7]={3,4,2,0,1,5,6}; //pin array to assign the corresponding pin package to - in that order (using schematic above as reference)

uint8_t Wpins4_5[14]={34,36,37,51,61,62,66,70,76,77,79,80,81,88};
// uint8_t Wpins2_3[14]={70,76,77,79,80,81,88,89,93,94,3,5,6,9};
uint8_t Wpins4[14]={34,36,37,51,61,62,66};

//for the first board
// uint8_t alphaPins[7]={34,36,37,51,61,62,66};//1st letter or digit
// uint8_t bravoPins[7]={70,76,77,79,80,81,88};//2nd letter or digit
// uint8_t charliePins[7]={89,93,94,3,5,6,9};//3rd letter or digit

//for the second board
uint8_t deltaPins[7]={34,36,37,51,61,62,66};//4th letter or digit
uint8_t echoPins[7]={70,76,77,79,80,81,88};//5th letter or digit



int startSignal=2;     /*PIN of the Signal from first board to also start moving Servos in the second board*/
double mspulse;       /*The pulse duration in milliseconds {0.5ms=0  1.5ms=90   2.5ms=180}*/
int freq = 50;        /*Frequency of the PWM in Hz (default is 490, but set it to 50Hz to match duty cycle of data sheets)*/
int resolution = 256; /*Resolution of the Duty Cycle in 2^(8,10,12,16)*/


/*calculates the Duty Cycle in respect to the frequency and bit resolution for a chosen pulse width*/
int toAnalogWrite(double mspulse, int freq, int resolution){ 
  int window = 1000 / freq;
  return ceil((mspulse / window) * resolution);
}

/*
    @brief  Each Segment (or each Servo Motor) is an Object which can have two modes, either show or hide (methods)
            with combinations of show and hide you can display a letter made of seven segments, hence seven
            segment display
    
*/
class Segment
{
  private:
  public:

  int pin;
  uint8_t pos;

  /*
      @brief sets the segment in show mode i.e. Servo is 90 
      @param pin which the PWM wire of the Servo is connected to 
  */
  bool show(int pin)
  {
      analogWrite(pin,toAnalogWrite(1.5,freq,resolution));
      return true;
  }

  /*
      @brief sets the segment in hide mode i.e depending on servo orientation either 180 or 0.
      @param pin which the PWM wire of the Servo is connected to.
      @param pos is the position of the servo(segment) as shown at the top.
  */
  bool hide(int pin,uint8_t pos)
  {
      switch (pos)
      {
          case 0:
              analogWrite(pin,toAnalogWrite(2.5,freq,resolution));
              break;
          case 1:
              analogWrite(pin,toAnalogWrite(2.5,freq,resolution));
              break;
          case 2:
              analogWrite(pin,toAnalogWrite(0.5,freq,resolution));
              break;
          case 3:
              analogWrite(pin,toAnalogWrite(0.5,freq,resolution));
              break;
          case 4:
              analogWrite(pin,toAnalogWrite(2.5,freq,resolution));
              break;
          case 5:
              analogWrite(pin,toAnalogWrite(0.5,freq,resolution));
              break;
          case 6:
              analogWrite(pin,toAnalogWrite(0.5,freq,resolution));
              break;
          
          default:
              break;
      }
      return true;
  }
};

//Digit is an array of Segments
Segment Zero,One,Two,Three,Four,Five,Six;
Segment Digit[7]={Three,Four,Two,Zero,Five,One,Six};

/*
  @brief: This functions lets all the Segments go into hide mode
*/
void hideAll()
{
  uint8_t ctr=6;
  for(int i=0;i<3;i++)
  {
    for(ctr=6;ctr>=0;ctr--)
    {
      Digit[ctr].hide(allPins[i][ctr],allPins[i][ctr]);
      delay(10); 
    }
  }
}

void displayA()
{   uint8_t ctr=0;  Digit[ctr].show(pins[ctr]);ctr+=2;   Digit[ctr].show(pins[ctr]);ctr++;   Digit[ctr].show(pins[ctr]);ctr++;   Digit[ctr].show(pins[ctr]);ctr++;   Digit[ctr].show(pins[ctr]);ctr++;   Digit[ctr].show(pins[ctr]);                                   }
void displayB()
{   uint8_t ctr=0;  Digit[ctr].show(pins[ctr]);ctr++;   Digit[ctr].show(pins[ctr]);ctr++;   Digit[ctr].show(pins[ctr]);ctr++;   Digit[ctr].show(pins[ctr]);ctr++;   Digit[ctr].show(pins[ctr]);ctr++;   Digit[ctr].show(pins[ctr]);ctr++;   Digit[ctr].show(pins[ctr]);     }
void displayC()
{   uint8_t ctr=1;  Digit[ctr].show(pins[ctr]);ctr++;   Digit[ctr].show(pins[ctr]);ctr++;   Digit[ctr].show(pins[ctr]);ctr++;   Digit[ctr].show(pins[ctr]);                                                                                                           }
void displayD()
{   uint8_t ctr=1;  Digit[ctr].show(pins[ctr]);ctr++;   Digit[ctr].show(pins[ctr]);ctr++;   Digit[ctr].show(pins[ctr]);ctr++;   Digit[ctr].show(pins[ctr]);ctr++;   Digit[ctr].show(pins[ctr]);ctr++;   Digit[ctr].show(pins[ctr]);ctr++;   Digit[ctr].show(pins[ctr]);     }
void displayE()
{   uint8_t ctr=0;  Digit[ctr].show(pins[ctr]);ctr++;   Digit[ctr].show(pins[ctr]);ctr++;   Digit[ctr].show(pins[ctr]);ctr++;   Digit[ctr].show(pins[ctr]);ctr++;   Digit[ctr].show(pins[ctr]);                                                                       }
void displayF()
{   uint8_t ctr=0;  Digit[ctr].show(pins[ctr]);ctr+=2;   Digit[ctr].show(pins[ctr]);ctr++;   Digit[ctr].show(pins[ctr]);ctr++;   Digit[ctr].show(pins[ctr]);                                                                                                           }
void displayG()
{   uint8_t ctr=0;  Digit[ctr].show(pins[ctr]);ctr++;   Digit[ctr].show(pins[ctr]);ctr++;   Digit[ctr].show(pins[ctr]);ctr++;   Digit[ctr].show(pins[ctr]);ctr++;   Digit[ctr].show(pins[ctr]);                                                                             }
void displayH()
{   uint8_t ctr=0;  Digit[ctr].show(pins[ctr]);ctr+=3;   Digit[ctr].show(pins[ctr]);ctr++;   Digit[ctr].show(pins[ctr]);ctr++;   Digit[ctr].show(pins[ctr]);ctr++;   Digit[ctr].show(pins[ctr]);                                                                       }
void displayI()
{   uint8_t ctr=5;  Digit[ctr].show(pins[ctr]);ctr++;   Digit[ctr].show(pins[ctr]);                                                                                                                                                                                         }
void displayJ()
{   uint8_t ctr=1;  Digit[ctr].show(pins[ctr]);ctr+=3;   Digit[ctr].show(pins[ctr]);ctr++;   Digit[ctr].show(pins[ctr]);ctr++;   Digit[ctr].show(pins[ctr]);                                                                                                           }

// void displayK() //no "K" in 7 Segment
// {   uint8_t ctr=0;  Digit[ctr].show(pins[ctr]);ctr++;   Digit[ctr].show(pins[ctr]);ctr++;   Digit[ctr].show(pins[ctr]);ctr++;   Digit[ctr].show(pins[ctr]);ctr++;   Digit[ctr].show(pins[ctr]);ctr++;   Digit[ctr].show(pins[ctr]);ctr++;   Digit[ctr].show(pins[ctr]);     }

void displayL()
{   uint8_t ctr=1;  Digit[ctr].show(pins[ctr]);ctr+=2;  Digit[ctr].show(pins[ctr]);ctr++;   Digit[ctr].show(pins[ctr]);                                                                                                                                               }
// void displayM() //no "M" in 7 segment
// {   uint8_t ctr=0;  Digit[ctr].show(pins[ctr]);ctr++;   Digit[ctr].show(pins[ctr]);ctr++;   Digit[ctr].show(pins[ctr]);ctr++;   Digit[ctr].show(pins[ctr]);ctr++;   Digit[ctr].show(pins[ctr]);ctr++;   Digit[ctr].show(pins[ctr]);ctr++;   Digit[ctr].show(pins[ctr]);     }

void displayN()
{   uint8_t ctr=2;  Digit[ctr].show(pins[ctr]);ctr++;   Digit[ctr].show(pins[ctr]);ctr++;   Digit[ctr].show(pins[ctr]);ctr++;   Digit[ctr].show(pins[ctr]);                                                                                                           }
void displayO()
{   uint8_t ctr=1;  Digit[ctr].show(pins[ctr]);ctr++;   Digit[ctr].show(pins[ctr]);ctr++;   Digit[ctr].show(pins[ctr]);ctr++;   Digit[ctr].show(pins[ctr]);ctr++;   Digit[ctr].show(pins[ctr]);ctr++;   Digit[ctr].show(pins[ctr]);                                   }
void displayP()
{   uint8_t ctr=0;  Digit[ctr].show(pins[ctr]);ctr+=2;  Digit[ctr].show(pins[ctr]);ctr++;   Digit[ctr].show(pins[ctr]);ctr++;   Digit[ctr].show(pins[ctr]);ctr++;   Digit[ctr].show(pins[ctr]);                                                                             }

// void displayQ() //no "Q" in 7 segment
// {   uint8_t ctr=0;  Digit[ctr].show(pins[ctr]);ctr++;   Digit[ctr].show(pins[ctr]);ctr++;   Digit[ctr].show(pins[ctr]);ctr++;   Digit[ctr].show(pins[ctr]);ctr++;   Digit[ctr].show(pins[ctr]);ctr++;   Digit[ctr].show(pins[ctr]);ctr++;   Digit[ctr].show(pins[ctr]);     }

void displayR() //lowercase r
{   uint8_t ctr=2;  Digit[ctr].show(pins[ctr]);ctr++;   Digit[ctr].show(pins[ctr]);ctr++;   Digit[ctr].show(pins[ctr]);ctr++;                                                                                                                                               }
void displayS()
{   uint8_t ctr=0;  Digit[ctr].show(pins[ctr]);ctr++;   Digit[ctr].show(pins[ctr]);ctr++;   Digit[ctr].show(pins[ctr]);ctr++;   Digit[ctr].show(pins[ctr]);ctr+=3;   Digit[ctr].show(pins[ctr]);                                                                            }

// void displayT() //no "T" in 7 Segment
// {   uint8_t ctr=0;  Digit[ctr].show(pins[ctr]);ctr++;   Digit[ctr].show(pins[ctr]);ctr++;   Digit[ctr].show(pins[ctr]);ctr++;   Digit[ctr].show(pins[ctr]);ctr++;   Digit[ctr].show(pins[ctr]);ctr++;   Digit[ctr].show(pins[ctr]);ctr++;   Digit[ctr].show(pins[ctr]);     }

void displayU()
{   uint8_t ctr=1;  Digit[ctr].show(pins[ctr]);ctr+=2;   Digit[ctr].show(pins[ctr]);ctr++;   Digit[ctr].show(pins[ctr]);ctr++;   Digit[ctr].show(pins[ctr]);ctr++;   Digit[ctr].show(pins[ctr]);ctr++;   Digit[ctr].show(pins[ctr]);ctr++;   Digit[ctr].show(pins[ctr]);     }

// void displayV() //no "V" in 7 Segment
// {   uint8_t ctr=0;  Digit[ctr].show(pins[ctr]);ctr++;   Digit[ctr].show(pins[ctr]);ctr++;   Digit[ctr].show(pins[ctr]);ctr++;   Digit[ctr].show(pins[ctr]);ctr++;   Digit[ctr].show(pins[ctr]);ctr++;   Digit[ctr].show(pins[ctr]);ctr++;   Digit[ctr].show(pins[ctr]);     }

//because "W" takes two 7 segments 
void displayW4_5()
{   uint8_t ctr=1;  Digit[ctr].show(Wpins4_5[ctr]);ctr+=2;   Digit[ctr].show(Wpins4_5[ctr]);ctr++;   Digit[ctr].show(Wpins4_5[ctr]);ctr+=2; Digit[ctr].show(Wpins4_5[ctr]);ctr+=2;  
                    Digit[ctr].show(Wpins4_5[ctr]);ctr+=3;   Digit[ctr].show(Wpins4_5[ctr]);ctr++;   Digit[ctr].show(Wpins4_5[ctr]);ctr++;  Digit[ctr].show(Wpins4_5[ctr]);                                                                                                 }

void displayW4()
{   uint8_t ctr=1;  Digit[ctr].show(Wpins4[ctr]);ctr+=3;   Digit[ctr].show(Wpins4[ctr]);ctr++;   Digit[ctr].show(Wpins4[ctr]);ctr++;  Digit[ctr].show(Wpins4[ctr]);                                                                                                         }

// void displayX() //no "X" in 7 segment
// {   uint8_t ctr=0;  Digit[ctr].show(pins[ctr]);ctr++;   Digit[ctr].show(pins[ctr]);ctr++;   Digit[ctr].show(pins[ctr]);ctr++;   Digit[ctr].show(pins[ctr]);ctr++;   Digit[ctr].show(pins[ctr]);ctr++;   Digit[ctr].show(pins[ctr]);ctr++;   Digit[ctr].show(pins[ctr]);     }

void displayY()
{   uint8_t ctr=0;  Digit[ctr].show(pins[ctr]);ctr++;   Digit[ctr].show(pins[ctr]);ctr+=2;   Digit[ctr].show(pins[ctr]);ctr+=2; Digit[ctr].show(pins[ctr]);ctr++; Digit[ctr].show(pins[ctr]);                                                                               }
void displayZ()
{   uint8_t ctr=0;  Digit[ctr].show(pins[ctr]);ctr++;   Digit[ctr].show(pins[ctr]);ctr++;   Digit[ctr].show(pins[ctr]);ctr+=2;   Digit[ctr].show(pins[ctr]);ctr++;   Digit[ctr].show(pins[ctr]);                                                                            }

// Displaying Numbers

// void display0() //same as "O"
// {   uint8_t ctr=0;  Digit[ctr].show(pins[ctr]);ctr++;   Digit[ctr].show(pins[ctr]);ctr++;   Digit[ctr].show(pins[ctr]);ctr++;   Digit[ctr].show(pins[ctr]);ctr++;   Digit[ctr].show(pins[ctr]);ctr++;   Digit[ctr].show(pins[ctr]);ctr++;   Digit[ctr].show(pins[ctr]);     }

// void display1() //same as "I"
// {   uint8_t ctr=0;  Digit[ctr].show(pins[ctr]);ctr++;   Digit[ctr].show(pins[ctr]);ctr++;   Digit[ctr].show(pins[ctr]);ctr++;   Digit[ctr].show(pins[ctr]);ctr++;   Digit[ctr].show(pins[ctr]);ctr++;   Digit[ctr].show(pins[ctr]);ctr++;   Digit[ctr].show(pins[ctr]);     }

// void display2() //same as "Z"
// {   uint8_t ctr=0;  Digit[ctr].show(pins[ctr]);ctr++;   Digit[ctr].show(pins[ctr]);ctr++;   Digit[ctr].show(pins[ctr]);ctr++;   Digit[ctr].show(pins[ctr]);ctr++;   Digit[ctr].show(pins[ctr]);ctr++;   Digit[ctr].show(pins[ctr]);ctr++;   Digit[ctr].show(pins[ctr]);     }

void display3()
{   uint8_t ctr=0;  Digit[ctr].show(pins[ctr]);ctr++;   Digit[ctr].show(pins[ctr]);ctr++;   Digit[ctr].show(pins[ctr]);ctr+=3;  Digit[ctr].show(pins[ctr]);ctr++;  Digit[ctr].show(pins[ctr]);                                                                              }
void display4()
{   uint8_t ctr=0;  Digit[ctr].show(pins[ctr]);ctr+=3;  Digit[ctr].show(pins[ctr]);ctr+=2;   Digit[ctr].show(pins[ctr]);ctr++;   Digit[ctr].show(pins[ctr]);ctr++; Digit[ctr].show(pins[ctr]);                                                                              }
void display5()
{   uint8_t ctr=0;  Digit[ctr].show(pins[ctr]);ctr++;   Digit[ctr].show(pins[ctr]);ctr++;   Digit[ctr].show(pins[ctr]);ctr++;   Digit[ctr].show(pins[ctr]);ctr+=3; Digit[ctr].show(pins[ctr]);                                                                              }

// void display6() //same as "G"
// {   uint8_t ctr=0;  Digit[ctr].show(pins[ctr]);ctr++;   Digit[ctr].show(pins[ctr]);ctr++;   Digit[ctr].show(pins[ctr]);ctr++;   Digit[ctr].show(pins[ctr]);ctr++;   Digit[ctr].show(pins[ctr]);ctr++;   Digit[ctr].show(pins[ctr]);ctr++;   Digit[ctr].show(pins[ctr]);     }

void display7()
{   uint8_t ctr=2;  Digit[ctr].show(pins[ctr]);ctr+=3;   Digit[ctr].show(pins[ctr]);ctr++;  Digit[ctr].show(pins[ctr]);                                                                                                                                                     }

// void display8() //same as "B"
// {   uint8_t ctr=0;  Digit[ctr].show(pins[ctr]);ctr++;   Digit[ctr].show(pins[ctr]);ctr++;   Digit[ctr].show(pins[ctr]);ctr++;   Digit[ctr].show(pins[ctr]);ctr++;   Digit[ctr].show(pins[ctr]);ctr++;   Digit[ctr].show(pins[ctr]);ctr++;   Digit[ctr].show(pins[ctr]);     }

void display9()
{   uint8_t ctr=0;  Digit[ctr].show(pins[ctr]);ctr++;   Digit[ctr].show(pins[ctr]);ctr++;   Digit[ctr].show(pins[ctr]);ctr++;   Digit[ctr].show(pins[ctr]);ctr+=2;   Digit[ctr].show(pins[ctr]);ctr++;      Digit[ctr].show(pins[ctr]);                                     }
   

/*
    @brief Takes a String (const char array) and translates it to motor motion to display it on the mechanical
            7 segment display.
    
    @param word of type string and is the word to translate 
*/
void encodeThis(String myWord)
{
    
    for(int idx=0;idx<5;idx++)
    {
        switch (idx)
        {   
            case 3:
             for (int itr=0; itr<7; itr++) {
                    pins[itr]=deltaPins[itr];
            }
                break;
            case 4: 
                for (int itr=0; itr<7; itr++) {
                    pins[itr]=echoPins[itr];
            }
                break;
            // case 2: 
            //     pins[7]={89,93,94,3,5,6,9};
            //     break;
            // case 3: digitalWrite(startSignal, HIGH);
            //      break;
            // case 4: digitalWrite(startSignal, HIGH);
            //      break;
            
            default:Serial.println("meant for the other board!");
                break;
        }

        switch (myWord[idx])
        {
            case 'A':displayA();break;      case 'B':displayB();break;      case 'C': displayC();
            case 'D':displayD();break;      case 'E':displayE();break;      case 'F': displayF();
            case 'G':displayG();break;      case 'H':displayH();break;      case 'I': displayI();
            case 'J':displayJ();break;                                      case 'L': displayL();
                                            case 'N':displayN();break;      case 'O': displayD();
            case 'P':displayP();break;                                      case 'R': displayR();
            case 'S':displayS();break;                                      case 'U': displayU();
                                                                            
            case 'Y':displayY();break;      case 'Z':displayZ();break;      case '0': displayO();
            case '1':displayI();break;      case '2':displayZ();break;      case '3': display3();
            case '4':display4();break;      case '5':display5();break;      case '6': displayG();
            case '7':display7();break;      case '8':displayB();break;      case '9': display9();
            
            case 'W':
            if(idx==3)
            {
              displayW4_5();
            }
            else if(idx==2)
            {
              if(digitalRead(startSignal==HIGH)){
              displayW4();
              }
            }else if (idx==4) {
            Serial.println("Can't do W as last letter");
            }
            break;
            default: Serial.println("Can't do nosville");
                break;
        }
        
    }
}


void setup() {
  // put your setup code here, to run once:
  Serial.begin(9600);

  for(int i=0;i<3;i++)
  {
    for(int ctr=0;ctr<7;ctr++)
    {
      pinMode(allPins[i][ctr],OUTPUT);
      delay(5);
      setAnalogWriteFrequency(allPins[i][ctr],50);
      delay(5);
    }
  }
  pinMode(startSignal,INPUT);
}

void loop() {
  // put your main code here, to run repeatedly:
  delay(3000);

if (digitalRead(startSignal==HIGH)) {

  encodeThis("HAPPY");
  delay(2000);
  hideAll();

  encodeThis("NEW");
  delay(2000);
  hideAll();

  encodeThis("YEAR");
  delay(2000);
  hideAll();

  
  exit(0);
}
  
}

XMC4700 PWM Pins

Arduino
//    Arduino form factor PWM Pins
//   /* 3  */    {XMC_GPIO_PORT1, 1},   // PWM40-2(PWM0) / External INT 1  P1.1
//   /* 5  */    {XMC_GPIO_PORT2, 12},  // PWM81-3 output / PWM1        P2.12
//   /* 6  */    {XMC_GPIO_PORT2, 11},  // PWM80-2 output / PWM2        P2.11
//   /* 9  */    {XMC_GPIO_PORT1, 11},  // PWM81-1 output / PWM3        P1.11
//   /* 10  */   {XMC_GPIO_PORT3, 10},  // SPI-SS / PWM41-0 / PWM4      P3.10
//   /* 11  */   {XMC_GPIO_PORT3, 8},   // SPI-MOSI / PWM41-2 / PWM5    P3.8

//   PWM Pins of X1 starting here
//   /* 34  */   {XMC_GPIO_PORT3, 4},   // PWM42-2 / PWM12              P3.4     X1-1
//   /* 36  */   {XMC_GPIO_PORT0, 3},   // PWM80-2 / PWM10              P0.3     X1-5
//   /* 37  */   {XMC_GPIO_PORT0, 1},   // PWM80-1 / PWM9               P0.1     X1-7
//   /* 51  */   {XMC_GPIO_PORT5, 11},  // PWM80-0 / PWM6               P5.11    X1-34
//   /* 61  */   {XMC_GPIO_PORT3, 0},   // PWM42-0 / PWM7               P3.0     X1-14
//   /* 62  */   {XMC_GPIO_PORT0, 9},   // PWM80-1 / PWM8               P0.9     X1-12
//   /* 66  */   {XMC_GPIO_PORT0, 6},   // PWM80-3 / PWM11              P0.6     X1-4

//   PWM Pins of X2 starting here
//   /* 70  */   {XMC_GPIO_PORT0, 14},  // PWM40-1 / PWM21              P0.14    X2-5
//   /* 76  */   {XMC_GPIO_PORT6, 5},   // PWM43-0 / PWM17              P6.5     X2-17
//   /* 77  */   {XMC_GPIO_PORT1, 15},  // PWM81-0 / PWM16              P1.15    X2-19
//   /* 79 */    {XMC_GPIO_PORT5, 3},   // PWM81-2 / PWM15              P5.3     X2-23
//   /* 80  */   {XMC_GPIO_PORT5, 5},   // PWM81-1 / PWM14              P5.5     X2-25
//   /* 81  */   {XMC_GPIO_PORT5, 7},   // PWM81-0 / PWM13              P5.7     X2-27
//   /* 88  */   {XMC_GPIO_PORT6, 4},   // PWM43-1 / PWM18              P6.4     X2-16
//   /* 89  */   {XMC_GPIO_PORT6, 2},   // PWM43-3 / PWM19              P6.2     X2-14
//   /* 93  */   {XMC_GPIO_PORT0, 15},  // PWM40-0 / PWM20              P0.15    X2-6
//   /* 94  */   {XMC_GPIO_PORT0, 12},  // PWM40-3 / PWM22              P0.12    X2-4

Credits

Infineon Team

Infineon Team

90 projects • 134 followers

Comments