int disp1 = 2;
int disp2 = 3;
int disp3 = 4;
int disp4 = 5;
int disp5 = 6;
int disp6 = 7;
int disp7 = 8;
int disp8 = 9;
int disp9 = 10;
int disp10= 11;
int disp11= 12;
int disp12 = 13;
int last1 = A0;
int last2 = A1;
int last3 = A2;
int variable = A4;
//pointer declaration
int *number[1000] = NULL;
void zero(void), one(void), two(void), three(void), four(void), five(void), six(void), seven(void), eight(void), nine(void);
void (*number[1000])() = {zero, one, two, three, four, five, six, seven, eight, nine};
int abc[] = {disp1, disp2, disp3, disp4, disp5, disp6, disp7, disp8, disp9, disp10, disp11, disp12, last1, last2, last3};
//function declaration for the counting numbers
void setup() {
// put your setup code here, to run once:
pinMode(1, OUTPUT);
pinMode(2, OUTPUT);
pinMode(3, OUTPUT);
pinMode(4, OUTPUT);
pinMode(5, OUTPUT);
pinMode(6, OUTPUT);
pinMode(7, OUTPUT);
pinMode(8, OUTPUT);
pinMode(9, OUTPUT);
pinMode(10, OUTPUT);
pinMode(11, OUTPUT);
pinMode(12, OUTPUT);
pinMode(13, OUTPUT);
pinMode(A0, OUTPUT);
pinMode(A1, OUTPUT);
pinMode(A2, OUTPUT);
}
void loop()
{
// put your main code here, to run repeatedly:
// read the sensor
int input;
input = analogRead(variable);
if (input == HIGH)
{
for (int i = 0; i< sizeof(number); i++)
{
*number[i];
for (int j = 0; j< sizeof(number); j++)
{
*number[j];
if (*number[j]== *number[8])
{
*number[i]== *number[i+1];
}
}
}
}
}
void zero()
{
digitalWrite(3, HIGH);
delay(30);
digitalWrite(5, HIGH);
delay(30);
digitalWrite(8, HIGH);
delay(30);
digitalWrite(11, HIGH);
delay(30);
digitalWrite(A1, HIGH);
delay(30);
digitalWrite(13, HIGH);
delay(30);
digitalWrite(10, HIGH);
delay(30);
digitalWrite(7, HIGH);
delay(1000);
}
void one()
{
digitalWrite(3, HIGH);
delay(30);
digitalWrite(6, HIGH);
delay(30);
digitalWrite(9, HIGH);
delay(30);
digitalWrite(12, HIGH);
delay(30);
digitalWrite(A1, HIGH);
delay(30);
delay(1000);
}
void two()
{
digitalWrite(5, HIGH);
delay(30);
digitalWrite(3, HIGH);
delay(30);
digitalWrite(7, HIGH);
delay(30);
digitalWrite(10, HIGH);
delay(30);
digitalWrite(12, HIGH);
delay(30);
digitalWrite(A0, HIGH);
delay(30);
digitalWrite(A1, HIGH);
delay(30);
digitalWrite(A2, HIGH);
delay(1000);
}
void three()
{
digitalWrite(2, HIGH);
delay(30);
digitalWrite(3, HIGH);
delay(30);
digitalWrite(4, HIGH);
delay(30);
digitalWrite(7, HIGH);
delay(30);
digitalWrite(9, HIGH);
delay(30);
digitalWrite(10, HIGH);
delay(30);
digitalWrite(13, HIGH);
delay(30);
digitalWrite(A0, HIGH);
delay(30);
digitalWrite(A1, HIGH);
delay(30);
digitalWrite(A2, HIGH);
delay(1000);
}
void four()
{
digitalWrite(3, HIGH);
delay(30);
digitalWrite(6, HIGH);
delay(30);
digitalWrite(8, HIGH);
delay(30);
digitalWrite(9, HIGH);
delay(30);
digitalWrite(10, HIGH);
delay(30);
digitalWrite(12, HIGH);
delay(30);
digitalWrite(A1, HIGH);
delay(1000);
}
void five()
{
digitalWrite(2, HIGH);
delay(30);
digitalWrite(3, HIGH);
delay(30);
digitalWrite(4, HIGH);
delay(30);
digitalWrite(5, HIGH);
delay(30);
digitalWrite(6, HIGH);
delay(30);
digitalWrite(10, HIGH);
delay(30);
digitalWrite(13, HIGH);
delay(30);
digitalWrite(A0, HIGH);
delay(30);
digitalWrite(A1, HIGH);
delay(1000);
}
void six()
{
digitalWrite(2, HIGH);
delay(30);
digitalWrite(3, HIGH);
delay(30);
digitalWrite(7, HIGH);
delay(30);
digitalWrite(10, HIGH);
delay(30);
digitalWrite(13, HIGH);
delay(30);
digitalWrite(A1, HIGH);
delay(30);
digitalWrite(11, HIGH);
delay(30);
digitalWrite(9, HIGH);
delay(1000);
}
void seven()
{
digitalWrite(2, HIGH);
delay(30);
digitalWrite(3, HIGH);
delay(30);
digitalWrite(4, HIGH);
delay(30);
digitalWrite(7, HIGH);
delay(30);
digitalWrite(10, HIGH);
delay(30);
digitalWrite(12, HIGH);
delay(30);
digitalWrite(A0, HIGH);
delay(1000);
}
void eight()
{
digitalWrite(3, HIGH);
delay(30);
digitalWrite(5, HIGH);
delay(30);
digitalWrite(7, HIGH);
delay(30);
digitalWrite(9, HIGH);
delay(30);
digitalWrite(11, HIGH);
delay(30);
digitalWrite(A1, HIGH);
delay(30);
digitalWrite(13, HIGH);
delay(1000);
}
void nine()
{
digitalWrite(3, HIGH);
delay(30);
digitalWrite(5, HIGH);
delay(30);
digitalWrite(7, HIGH);
delay(30);
digitalWrite(9, HIGH);
delay(30);
digitalWrite(10, HIGH);
delay(30);
digitalWrite(12, HIGH);
delay(30);
digitalWrite(A0, HIGH);
delay(1000);
}
void clear()
{
digitalWrite(2, LOW);
delay(30);
digitalWrite(3, LOW);
delay(30);
digitalWrite(4, LOW);
delay(30);
digitalWrite(5, LOW);
delay(30);
digitalWrite(6, LOW);
delay(30);
digitalWrite(7, LOW);
delay(30);
digitalWrite(8, LOW);
delay(30);
digitalWrite(9, LOW);
delay(30);
digitalWrite(10, LOW);
delay(30);
digitalWrite(11, LOW);
delay(30);
digitalWrite(12, LOW);
delay(30);
digitalWrite(13, LOW);
delay(30);
digitalWrite(A0, LOW);
delay(30);
digitalWrite(A1, LOW);
delay(30);
digitalWrite(A2, LOW);
delay(150);
}
I was trying to print the count of People who entered a premise using an IR sensor and display that count using the matrix of LEDs I figured out most of the part but the part where I am struggling is passing a bunch of functions into an array {Yes I can easily do it through switch cases (I understood it from my significant amount of research)} but I am trying to develop my bag of tools for good and be good at programming so I humbly ask for help in this matter (any other suggestions for making this code much more efficient would be a good learning point for me.
Yes, I accept that I made many mistakes but please, help from you all would be great.
Along with that, in the last few days, I noticed that I haven't provided the complete problem statement, I planned to first pass the collection of functions into an array and then call the function from an array for in this case to do display work using the matrix of LEDs as I have shown below. What I want to do is show the LEDs display the count (as soon as the IR sensor detects a person entering the premises) from zero to nine as soon as I have reached nine I want the other LED grid to show the digit one alongside repeat the pattern from zero to nine on the other LED grid and as soon as I reach one of the LED grid and nine on the other LED grid I want the first grid to show two and start the pattern from zero to nine and so on.
Yes, I have used the PIR sensor for the software but in the real project, I shall be using the IR sensor.
So now I have provided the complete information so please help me solving this problem