Using MAXIM 7218A with Arduino

Continuing the discussion from Using MAXIM ICM7218A With Arduino:

/\*  Using Maxim 7218A with Arduino UNO. (version 1.01)  \*/

const byte ID0 = 2;

const byte ID1 = 3;

const byte ID2 = 4;

const byte ID3 = 5;

const byte ID4 = 6;

const byte ID5 = 7;

const byte ID6 = 8;

const byte ID7 = 9;

const byte WRITE = 10;

const byte MODE = 11;

const byte LED = 13;

void setup() {

//define outputs (data bus)

pinMode(ID0, OUTPUT);

pinMode(ID1, OUTPUT);

pinMode(ID2, OUTPUT);

pinMode(ID3, OUTPUT);

pinMode(ID4, OUTPUT);

pinMode(ID5, OUTPUT);

pinMode(ID6, OUTPUT);

pinMode(ID7, OUTPUT);

//define outputs WRITE and MODE

pinMode(WRITE, OUTPUT);

pinMode(MODE, OUTPUT);

pinMode(LED, OUTPUT);

//defaults

digitalWrite(MODE, LOW);

digitalWrite(WRITE, HIGH);

delay(10);

}

//send a (negative) write pulse

void writePulse() {

delayMicroseconds(1);

digitalWrite(WRITE, LOW);

delayMicroseconds(1);

digitalWrite(WRITE, HIGH);

delayMicroseconds(1);

}

//Set outputs ID7-ID6-ID5-ID4-ID3-ID2-ID1-ID0 according to byte 'value'

void writeDigit(byte value) {

digitalWrite(ID0, bitRead(value, 0));

digitalWrite(ID1, bitRead(value, 1));

digitalWrite(ID2, bitRead(value, 2));

digitalWrite(ID3, bitRead(value, 3));

digitalWrite(ID4, bitRead(value, 4));

digitalWrite(ID5, bitRead(value, 5));

digitalWrite(ID6, bitRead(value, 6));

digitalWrite(ID7, bitRead(value, 7));

delayMicroseconds(1);

writePulse();

}

int pass = 0;

int ledstate = 0;

void loop() {

if (pass == 0) {


pass = pass + 1;  //only do it once



//Set up pins for control word.

digitalWrite(ID4, HIGH);  //normal, no shutdown

digitalWrite(ID5, HIGH);  //1=no decode= control all segments + DP directly

digitalWrite(ID6, HIGH);  //not needed when no decode. (obsolete?) 

digitalWrite(ID7, HIGH);  //data coming



//start (positive) MODE pulse, WRITE pulse, finally end MODE pulse

digitalWrite(MODE, HIGH);

writePulse();

digitalWrite(MODE, LOW);



//write 8 hex digits starting with least significant

writeDigit(0xB6);

writeDigit(0xF5);

writeDigit(0xED);

writeDigit(0xB0);

writeDigit(0xFF);

writeDigit(0xF0);

writeDigit(0xDF);

writeDigit(0xD7);    


}

//toggle led

ledstate = 1 - ledstate;

digitalWrite(LED, ledstate);

delay(500);  //keep led on/off half a sec

}

Looks good!

Thanks! I just noticed that part of the code is outside the copy & paste box, do you know how to fix it? Please do if you can.

I edited it; there were some out of place ``` formatting symbols (for our forums you just need to put 3 on a line by itself before code, and another 3 on a line after the code)