Led Clock

Hello all i got a small problem i found a led clock online Using 46 leds and everything seems to work even the Sketch but nothing in there for push buttons for the Minutes and Hours. Im not good at Coding at all I'm more of a hardware Guy. i really need help the sketch is using the Time.h library Sketch attached can someone please help me. i try to ask a couple of peoples i know hat plays around with arduino's but none of them know how to add this kind of Feature in it.

ledclock.txt (15.6 KB)

Unless you're running this on a Mega, you've run out of pins for any switches, haven't you?

hello no digital pin 0 - 11 are in use and analog pin A0 -A4 are in use Digital pin 12 and 13 are free and anlong Pin A5 is free also.

the sketch is like this pins out

int column[]={0,1,2,3,4,5,6,7,8,9,10,11};
int row[] = {A0,A1,A2,A3,};

these are the pins being used

OK, just got your code - it's a bit light on comments and symbolic names.

OK, you've got spare pins for the switches - what's the problem?

For a number of reasons, you may want to rethink these loops

void allOn(){
  for(int x=0;x<5;x++){
    for(int y=0;y<13;y++){
      digitalWrite(row[x],LOW);
      digitalWrite(column[y],HIGH);
    }
  }
}

void allOff(){
  for(int x=0;x<5;x++){
    for(int y=0;y<13;y++){
      digitalWrite(row[x],HIGH);
      digitalWrite(column[y],LOW);
    }
  }
}

Im not a programer or a coder at all I'm more of hardware i do not know how to program the pins or what ode to use or anything like that to make the buttons work so when the first button pushed the hours change and when the second button is pushed the minutes are change. as before i can do the hardware but not software i been asking all my friends and peoples i know who is playing with arduinos to help and none of them are doing anything with clocks yet.

Joseph

hello i just seen the code you have got i didn't write the sketch it's self it's someone else

i didn't write the sketch it's self it's someone else

Well, get the "someone else" to rewrite those loops -they're rubbish.

Have you looked at any of the examples in the IDE?
I'm pretty sure there are some related to reading switches.

i do understand that i try to message that person on youtube where i found this at and no reply at all from that person.

but mean while i do need help on how to setup this pins to change the minute and hour button can you please help me?

Have you tried any of the examples provided in the IDE on how to read the state of switches?

honestly man no because i tried to search online for time.h library hour and minute push button it came up alot fo stuff but nothing i can understand it's a little over my head when it comes to this and programing. i checked out a few pages but got so lost.

If you open up the IDE, click on "File", then "Examples", "02.Digital", "DigitalInputPullup" the example code given should be easy for a hardware guy to understand.
It will get you started on how to wire up a switch and read it.
Then you transplant that code into yours.

hello i got one friend to help he doesn't know about the time.h library but he try to help he made some changes to the sketch when i tried it i push the one button that is on pin 13 for the hour the led got dim but when i hit the button that is on pin 12 nothing happens i try to look at it a little more the code but it's to much i include it in attached below.

Joseph

ledclock1.txt (16 KB)

int minut = minute();

// increase value for minute
 if (digitalRead(12) == LOW)   
   {
     if (minut>59)  
     {
       minut = 0;
     }
     else
     {
       minut++;   
     }

Then you'll need to write back the value of "minut".

void allOn(){
  for(int x=0;x<5;x++){
    for(int y=0;y<13;y++){
      digitalWrite(row[x],LOW);
      digitalWrite(column[y],HIGH);
    }
  }
}

void allOff(){
  for(int x=0;x<5;x++){
    for(int y=0;y<13;y++){
      digitalWrite(row[x],HIGH);
      digitalWrite(column[y],LOW);
    }
  }
}

Still needs correcting.

i do not know how to do that I'm trying to learn it.

OK, here's a couple of clues:

  1. x and y are unrelated, so the loops should not be nested
  2. "column" does not have 13 elements.

what do i change it too when i try to do a upload of the sketch with the new minute change i get a error in orange says a function-definition is not allowed here before '{' token and in black says

lite_brite_code.ino: In function 'void loop()':
lite_brite_code:163: error: a function-definition is not allowed here before '{' token
lite_brite_code:712: error: expected `}' at end of input

Hint:

The numbers in bold below are line numbers. Look at those lines (and/or lines before & after).

lite_brite_code.ino: In function 'void loop()':
lite_brite_code:163: error: a function-definition is not allowed here before '{' token
lite_brite_code:712: error: expected `}' at end of input

Questions to ask yourself-
How does the formatting on those lines differ from similar-looking sections in other areas of the code?
What did I change?
What is before "{"?
....where was the "{" before I changed things?
What does "{" do?

got the clock working with the 2 push buttons but can someone please help me on adding a alarm function please I'm not good at coding can someone please help me to change this i have included the text sketch below.

ledclockplusbuttons.txt (16.2 KB)

I see you still haven't taken the hint, so I'll spell it out.

#define ARRAY_SIZE(x) (sizeof (x) / sizeof (x[0]))
void allOn()
{
  for(int x = 0; x < ARRAY_SIZE (row); x++){
    digitalWrite(row[x], LOW);
  }
  for(int y = 0; y < ARRAY_SIZE (column); y++){
    digitalWrite(column[y], HIGH);
  }
}

void allOff()
{
  for(int x = 0; x < ARRAY_SIZE (row); x++){
    digitalWrite(row[x], HIGH);
  }
  for(int y = 0; y < ARRAY_SIZE (column); y++){
    digitalWrite(column[y], LOW);
  }
}