Hi there
I'm looking for a way to take a number and split it down to its individual digits, and then store those digits in an array. I would also like to specify the length of the array, so that larger numbers can be truncated to remove the most significant digits.
I've tried to write a function where I specify the number to split up and the number of digits I want to store, but it isn't working and I don't understand why.
Once the numbers are stored in an array I want to join them back together using bit-shifting and bitwise OR to send out to a shift register, but I haven't tried to write that bit of the code yet.
Here's what I have so far:
/
byte array[4];
byte placeloop;
byte expo;
int sevenSegOut(int displayNumber, byte numDisplays) {
if (numDisplays == 1) { Serial.println("Boobs");
} else {
for(byte placeloop = numDisplays - 1; placeloop == 0; placeloop--) {
int nplace = displayNumber;
for (expo = placeloop; expo == 0; expo--) {
nplace = nplace / 10;
}
array[placeloop] = nplace;
}
}
}
void setup() {
Serial.begin(9600);
}
void loop() {
sevenSegOut(4567, 4);
Serial.println(array[3]);
Serial.println(array[2]);
Serial.println(array[1]);
Serial.println(array[0]);
Serial.println(" ");
delay(1000);
}
Any help would be greatly appreciated.