arduino control 7 seg using arrays
simple programa to print number to 7 digits display
const int a = 2;
const int b = 3;
const int c = 4;
const int d = 5;
const int e = 6;
const int f = 7;
const int g = 8
const int h = 9;
int pins[8] = { a, b, c, d, e, f, g, h };
int numbers[10][8] = {
// a b c d e f g h
{ 1, 0, 0, 0, 0, 0, 0, 0 }, // 0 pins 1 = HIGH and 0 = LOW
{ 1, 0, 0, 0, 0, 0, 0, 0 }, // 1 pins
{ 1, 0, 0, 0, 0, 0, 0, 0 }, // 2 pins
{ 1, 0, 0, 0, 0, 0, 0, 0 }, // 3 pins
{ 1, 0, 0, 0, 0, 0, 0, 0 }, // 4 pins
{ 1, 0, 0, 0, 0, 0, 0, 0 }, // 5 pins
{ 1, 0, 0, 0, 0, 0, 0, 0 }, // 6 pins
{ 1, 0, 0, 0, 0, 0, 0, 0 }, // 7 pins
{ 1, 0, 0, 0, 0, 0, 0, 0 }, // 8 pins
{ 1, 0, 0, 0, 0, 0, 0, 0 }, // 9 pins
};
void display(int number) {
for (int i = 0; i < 8; i++) {
digitalWrite(pins[i], numbers[number][i]);
}
}
void setup() {
// put your setup code here, to run once:
display(3);
}
void loop() {
// put your main code here, to run repeatedly:
}