It gives the right value on the monitor but it doesnt display the value on my display.
int pinNumb[7] = {2, 3, 4, 5, 6, 7, 8};
int num_array[11][7] = {
{ 1, 1, 1, 1, 1, 0, 1 }, // 0
{ 0, 1, 1, 0, 0, 0, 0 }, // 1
{ 1, 1, 0, 1, 1, 1, 0 }, // 2
{ 1, 1, 1, 1, 0, 1, 0 }, // 3
{ 0, 1, 1, 0, 0, 1, 1 }, // 4
{ 1, 0, 1, 1, 0, 1, 1 }, // 5
{ 1, 0, 1, 1, 1, 1, 1 }, // 6
{ 1, 1, 1, 0, 0, 0, 0 }, // 7
{ 1, 1, 1, 1, 1, 1, 1 }, // 8
{ 1, 1, 1, 0, 0, 1, 1 }, // 9
{ 0, 0, 0, 0, 0, 0, 0 } //nothing
};
int pin = 2;
int button = 12;
int buttonVal;
int randVal;
bool pressVal;
void setup() {
Serial.begin(9600);
for (int i = 0; i < 7 ; i++)
{
pinMode(pinNumb[i], OUTPUT);
}
pressVal = false;
pinMode(button, INPUT);
}
void loop() {
buttonVal = digitalRead(button);
if (buttonVal == 0)
{
//zero();
turnOff();
pressVal = false;
}
else
{
//zero();
if (pressVal == false)
{
randVal = rand() % 10;
pressVal = true;
delay(100);
}
Serial.println(randVal);
if (randVal == 0)
{
zero();
}
else if (randVal == 1)
{
one();
}
else if (randVal == 2)
{
two();
}
else if (randVal == 3)
{
three();
}
else if (randVal == 4)
{
four();
}
else if (randVal == 5)
{
five();
}
else if (randVal == 6)
{
six();
}
else if (randVal == 7)
{
seven();
}
else if (randVal == 8)
{
eight();
}
else
{
nine();
}
}
}
void zero()
{
for(int i = 0; i < 7 ; i++)
{
digitalWrite(pinNumb[i],LOW);
}
for (int j = 0; j < 7; j++) {
digitalWrite(pin, num_array[0][j]);
pin++;
}
}
void one()
{
for(int i = 0; i < 7 ; i++)
{
digitalWrite(pinNumb[i],LOW);
}
for (int j = 0; j < 7; j++) {
digitalWrite(pin, num_array[1][j]);
pin++;
}
}
void two()
{
for(int i = 0; i < 7 ; i++)
{
digitalWrite(pinNumb[i],LOW);
}
for (int j = 0; j < 7; j++) {
digitalWrite(pin, num_array[2][j]);
pin++;
}
}
void three()
{
for(int i = 0; i < 7 ; i++)
{
digitalWrite(pinNumb[i],LOW);
}
for (int j = 0; j < 7; j++) {
digitalWrite(pin, num_array[3][j]);
pin++;
}
}
void four()
{
for(int i = 0; i < 7 ; i++)
{
digitalWrite(pinNumb[i],LOW);
}
for (int j = 0; j < 7; j++) {
digitalWrite(pin, num_array[4][j]);
pin++;
}
}
void five()
{
for(int i = 0; i < 7 ; i++)
{
digitalWrite(pinNumb[i],LOW);
}
for (int j = 0; j < 7; j++) {
digitalWrite(pin, num_array[5][j]);
pin++;
}
}
void six()
{
for(int i = 0; i < 7 ; i++)
{
digitalWrite(pinNumb[i],LOW);
}
for (int j = 0; j < 7; j++) {
digitalWrite(pin, num_array[6][j]);
pin++;
}
}
void seven()
{
for(int i = 0; i < 7 ; i++)
{
digitalWrite(pinNumb[i],LOW);
}
for (int j = 0; j < 7; j++) {
digitalWrite(pin, num_array[7][j]);
pin++;
}
}
void eight()
{
for(int i = 0; i < 7 ; i++)
{
digitalWrite(pinNumb[i],LOW);
}
for (int j = 0; j < 7; j++) {
digitalWrite(pin, num_array[8][j]);
pin++;
}
}
void nine()
{
for(int i = 0; i < 7 ; i++)
{
digitalWrite(pinNumb[i],LOW);
}
for (int j = 0; j < 7; j++) {
digitalWrite(pin, num_array[9][j]);
pin++;
}
}
void turnOff()
{
for(int i = 0; i < 7 ; i++)
{
digitalWrite(pinNumb[i],LOW);
}
}
void zero()
function, what is the point of having the firstfor
loop? ... same for all the other functionsvoid zero()
function ... what is the code doing? ... remember that the whole function executes in a few milliseconds .... do you really need the firstfor
loop?