This might sound pretty stupid, but I actually don't know WHAT to google to get a simple answer, so hopefully you guys can help me out :-) I bet it's one of those things that's really obvious once I know, but I'm hungover and my brain's not firing on all cylinders... hehe

Anyway, let's say I have a 4 digit number for example 1234. I want to split this up into thousands, hundreds, tens and units across 4 variables, ending up with each one holding a value of 0-9 so I can then push these out to my 7-segment module.

There MUST be a nice neat operation to do this, but hell if I can find it :-P Thanks in advance for the help!

EDIT: Here's the code I'm fiddling with, it should be apparent what I'm trying to accomplish.

int CLK = 10;

int SIN = 11;

int LAT = 12;

byte digitData[10] = {

0x3F, 0x6, 0x5B, 0x4F, 0x66, 0x6D, 0x7D, 0x7, 0x7F, 0x67

};

// Array to hold segment patterns for digits 0 - 9

void setup () {

pinMode(CLK, OUTPUT);

pinMode(SIN, OUTPUT);

pinMode(LAT, OUTPUT);

}

void loop () {

while(1) {

unsigned long time = (millis() / 1000);

int D0 = time ?????????????

int D1 = time ?????????????

int D2 = time ?????????????

int D3 = time ?????????????

digitalWrite(LAT, LOW);

shiftOut(SIN, CLK, MSBFIRST, digitData[D0]);

shiftOut(SIN, CLK, MSBFIRST, digitData[D1]);

shiftOut(SIN, CLK, MSBFIRST, digitData[D2]);

shiftOut(SIN, CLK, MSBFIRST, digitData[D3]);

digitalWrite(LAT, HIGH);

}

}