Pages: [1]   Go Down
Author Topic: 7-Seg 4 Digit Display code for ICM7211  (Read 761 times)
0 Members and 1 Guest are viewing this topic.
Kansas City, MO
Offline Offline
Jr. Member
**
Karma: 0
Posts: 71
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I looked around for a while trying to find some code for a ICM7211 display driver and didn't see anything so I've posted one below in case someone is looking for the same. The pins on this were used on a 644P chip so just change for Arduino variant you're using.

Code:
/*******************************************************/
/* Author: Richard Vogel                               */
/* Date: 12/12/12                                      */
/*                                                     */
/* Description: Simple sketch to utilize a ICM7211AM   */
/* 7-segment 4-digit display driver with Arduino.      */
/* Example display for use with this sketch would be   */
/* Varitronix PN: VI-402-DP-FC-S                       */
/* Digi-Key PN: 153-1103-ND  //as of 12/12/12          */
/*******************************************************/


const int d0 = 28;
const int d1 = 29;
const int d2 = 30;
const int d3 = 31;

const int dS1 = 13;
const int dS2 = 14;

const int cS1 = 2;
const int cS2 = 3;

/*****************************************************************************/
/*This example is to display a temp to tenth of degree precision.
Decimal point connection has to go directly to diplay. Same goes for if
you want to use the colon on the display for a clock feature. The
ICM7211 does not output these lines.*/
/*****************************************************************************/
const int dP = 4;  

int tNow[4]={10,3,5,6};   // current temperature   (-35.6)

boolean on = 1;
boolean off = 0;
boolean lcdNum[16][4]=
{
  {off,off,off,off}, // 0
  {off,off,off,on},  // 1
  {off,off,on,off},  // 2
  {off,off,on,on},   // 3  
  {off,on,off,off},  // 4
  {off,on,off,on},   // 5
  {off,on,on,off},   // 6
  {off,on,on,on},    // 7
  {on,off,off,off},  // 8
  {on,off,off,on},   // 9
  {on,off,on,off},   // -      //array pos 10
  {on,off,on,on},    // E      //array pos 11
  {on,on,off,off},   // H      //array pos 12
  {on,on,off,on},    // L      //array pos 13
  {on,on,on,off},    // P      //array pos 14
  {on,on,on,on}      // Blank  //array pos 15
};

void setup()
{
  pinMode(d0, OUTPUT);
  pinMode(d1, OUTPUT);
  pinMode(d2, OUTPUT);
  pinMode(d3, OUTPUT);
  pinMode(dS1, OUTPUT);
  pinMode(dS2, OUTPUT);
  pinMode(cS1, OUTPUT);
  pinMode(cS2, OUTPUT);
  pinMode(dP, OUTPUT);
  digitalWrite(d0, LOW);
  digitalWrite(d1, LOW);
  digitalWrite(d2, LOW);
  digitalWrite(d3, LOW);
  digitalWrite(dS1, HIGH);
  digitalWrite(dS2, HIGH);
  digitalWrite(cS1, LOW);
  digitalWrite(cS2, HIGH);
  digitalWrite(dpColon, HIGH);
  Serial.begin(9600);
}
void loop()
{
  
  for (int x = 0; x < 16; x++)
  {
    disD1(lcdNum[x][0], lcdNum[x][1], lcdNum[x][2], lcdNum[x][3]);
    disD2(lcdNum[x][0], lcdNum[x][1], lcdNum[x][2], lcdNum[x][3]);
    disD3(lcdNum[x][0], lcdNum[x][1], lcdNum[x][2], lcdNum[x][3]);
    disD4(lcdNum[x][0], lcdNum[x][1], lcdNum[x][2], lcdNum[x][3]);
    delay(500);
  }
    bootUpDisplay();
    delay(500);
    clearMemDisplay();
    delay(500);
    helpDisplay();
    delay(500);
    blankDisplay();
    delay(500);  
    displayTemp(tNow[0], tNow[1], tNow[2], tNow[3]);
    delay(1000);

}

void disD1(boolean a, boolean b, boolean c, boolean d)
{
  digitalWrite(d3, a);
  digitalWrite(d2, b);
  digitalWrite(d1, c);
  digitalWrite(d0, d);
  digitalWrite(dS1, LOW);
  digitalWrite(dS2, LOW);
  delay(2);
  digitalWrite(cS2, LOW);
  delay(2);
  digitalWrite(cS2, HIGH);
}

void disD2(boolean a, boolean b, boolean c, boolean d)
{
  digitalWrite(d3, a);
  digitalWrite(d2, b);
  digitalWrite(d1, c);
  digitalWrite(d0, d);
  digitalWrite(dS1, HIGH);
  digitalWrite(dS2, LOW);
  delay(2);
  digitalWrite(cS2, LOW);
  delay(2);
  digitalWrite(cS2, HIGH);
}

void disD3(boolean a, boolean b, boolean c, boolean d)
{
  digitalWrite(d3, a);
  digitalWrite(d2, b);
  digitalWrite(d1, c);
  digitalWrite(d0, d);
  digitalWrite(dS1, LOW);
  digitalWrite(dS2, HIGH);
  delay(2);
  digitalWrite(cS2, LOW);
  delay(2);
  digitalWrite(cS2, HIGH);
}

void disD4(boolean a, boolean b, boolean c, boolean d)
{
  digitalWrite(d3, a);
  digitalWrite(d2, b);
  digitalWrite(d1, c);
  digitalWrite(d0, d);
  digitalWrite(dS1, HIGH);
  digitalWrite(dS2, HIGH);
  delay(2);
  digitalWrite(cS2, LOW);
  delay(2);
  digitalWrite(cS2, HIGH);
}

void bootUpDisplay() //"E1E1"
{
  disD1(lcdNum[11][0], lcdNum[11][1], lcdNum[11][2], lcdNum[11][3]);
  disD2(lcdNum[1][0], lcdNum[1][1], lcdNum[1][2], lcdNum[1][3]);
  disD3(lcdNum[11][0], lcdNum[11][1], lcdNum[11][2], lcdNum[11][3]);
  disD4(lcdNum[1][0], lcdNum[1][1], lcdNum[1][2], lcdNum[1][3]);
}

void clearMemDisplay() //"E2E2"
{
  disD1(lcdNum[11][0], lcdNum[11][1], lcdNum[11][2], lcdNum[11][3]);
  disD2(lcdNum[2][0], lcdNum[2][1], lcdNum[2][2], lcdNum[2][3]);
  disD3(lcdNum[11][0], lcdNum[11][1], lcdNum[11][2], lcdNum[11][3]);
  disD4(lcdNum[2][0], lcdNum[2][1], lcdNum[2][2], lcdNum[2][3]);
}

void helpDisplay() //"HELP"
{
  disD1(lcdNum[12][0], lcdNum[12][1], lcdNum[12][2], lcdNum[12][3]);
  disD2(lcdNum[11][0], lcdNum[11][1], lcdNum[11][2], lcdNum[11][3]);
  disD3(lcdNum[13][0], lcdNum[13][1], lcdNum[13][2], lcdNum[13][3]);
  disD4(lcdNum[14][0], lcdNum[14][1], lcdNum[14][2], lcdNum[14][3]);
}
void blankDisplay() // "  "
{
  disD1(lcdNum[15][0], lcdNum[15][1], lcdNum[15][2], lcdNum[15][3]);
  disD2(lcdNum[15][0], lcdNum[15][1], lcdNum[15][2], lcdNum[15][3]);
  disD3(lcdNum[15][0], lcdNum[15][1], lcdNum[15][2], lcdNum[15][3]);
  disD4(lcdNum[15][0], lcdNum[15][1], lcdNum[15][2], lcdNum[15][3]);
}

void displayTemp(int t4, int t3, int t2, int t1)
{
  disD1(lcdNum[t4][0], lcdNum[t4][1], lcdNum[t4][2], lcdNum[t4][3]);
  disD2(lcdNum[t3][0], lcdNum[t3][1], lcdNum[t3][2], lcdNum[t3][3]);
  disD3(lcdNum[t2][0], lcdNum[t2][1], lcdNum[t2][2], lcdNum[t2][3]);
  disD4(lcdNum[t1][0], lcdNum[t1][1], lcdNum[t1][2], lcdNum[t1][3]);
}


* Display.pdf (145.71 KB - downloaded 27 times.)
* ICM7211.pdf (204.93 KB - downloaded 23 times.)
* IMG_0897.MOV (1481.34 KB - downloaded 24 times.)
« Last Edit: December 13, 2012, 11:28:12 am by vogel1230 » Logged

Pages: [1]   Go Up
Jump to: