Binary Clock code questions

Hi Y'all. I am trying to write a program for a binary clock using arduino UNO. At the moment I have it wired in parallel with 220 ohm resistors. It is using 4 columns an unites ones and units seconds for minuets and the same format for seconds.
0 0
0 0 0 0
0 0 0 0
0 0 0 0

MIN SEC

I know this is not programming related, but I need you to know how I want the program to operate the board.
I want a timer to start at 0 and begin counting up,as long as it does not see 59, I want it to add 1 to a column and roll it over as time goes on. Example: Program starts at 0 it sees less than 59,so it displays a 1 bit then a 2 bit then a 3 bit with a 2 and 1 and etc etc etc, as the count increases, I want the arduino to pull the corresponding resistors LOW. I have supplied a 5v power supply directly to the "hot leg" of the circuit expecting arduino to ground it via PINoutput.

The Problem: It's working backwards. Instead of all lights being off and being triggered on, they are all one and being pulled off, Also it only counts from 7:15 in both columns to 7:13. So displayed on the counter I have my ones unit displaying 7 and my tens displaying 15 (on min) and the same for seconds. The hardware is wired correctly and works as designed, The software on the other hand is well FUCKED.
The program stars and with 7:15 7:15 and just counts down inaccurately. Here is the design of the code. I put a // for things that I understand, If it dosent have a // IDK what its supposed to do.

#include <Time.h> //Open Time package
int secondsLEDs [] = {0,1,2,3,4,5,6}; // Mins will be displayed on pin's
int minuetsLEDs [] = {7,8,9,10,11,12,13}; // Hours will display on pin's
int loopLEDs[] = {13,12,11,10,9,8,7,6,5,4,3,2,1}; // Constantly run these pins
int switchPin = {17}; // Acts as switch to change counters

void setup () // Starts one time when reset button is pressed or program starts
{ // Start program
for (int i = 0; i< 59; i++) // For value i make it 0, if I is less than 59, add one.
{
pinMode (secondsLEDs*, OUTPUT); // Pins 8-13 are set pulled low via output on arduino*

  • }*
  • for (int i = 0; i< 59; i++) // For value i make it 0, if its less than 59, add one.*
  • {*
    _ pinMode (minuetsLEDs*, OUTPUT); // Pins 7-1 are pulled low via output on arduino-_
    _
    }*_

* setTime(0,0,0,0,0,0); // Time is set to 0 hours, 0 min, 0 sec, 0 days,0 months,0 years*
} // End program
void loop() // To run in repeat from here down
*{ *
* if (digitalRead(switchPin)) // If the switch button is pressed add 1 to time.*
* {*
* adjustTime(1);*
* }*
* else if (minute() == 59 && second() == 59) // Or else if the button is not pressed, minuets = 0 and hours equal 0*
* {spin(minute()); // What is the spin function?*
* }*

* updateDisplay();*
* delay(10); // Wait 5 seconds*
}

void updateDisplay() // Return.
{
* time_t t = now(); // The time is set to right now.
_
setOutput (secondsLEDs,3, second(t)); // Sets hours at 6._
_
setOutput (minuetsLEDs,3, minute(t)); // Sets minuets at 6._
_
}_
void setOutput(int *ledArray,int numLEDs, int value)
_
{_
_
for (int i= 0; i < numLEDs; i++)*_

_ digitalWrite(ledArray*,
bitRead(value, i));
}
void spin(int count)
{
for (int i = 0; i < count; i++)
{
for (int j = 0; j<16; j++)
{
digitalWrite(loopLEDs[j], HIGH);
delay(100);
digitalWrite(loopLEDs[j],HIGH);
}
}
}*_

At the moment I have it wired in parallel with 220 ohm resistors.

It is a pronoun with no referent. What is "it"?

I want a timer to start at 0 and begin counting up,as long as it does not see 59,

No, you want a variable to start at 0, to increment by 1, and to reset to 0 when it hits 60.

Here is the design of the code.

Posted improperly so it is not legible. Try again, after reading the sticky at the top of the forum.

It "IS" a clock. A series of LED's all supplied 5V and pulled down to ground through a 220 OHM resistor.

 #include <Time.h>
 int secondsLEDs []  =            {0,1,2,3,4,5,6};                          // Mins will be displayed on pin's
 int minuetsLEDs []  =            {7,8,9,10,11,12,13};                         // Hours will display on pin's
 int loopLEDs[]      =            {13,12,11,10,9,8,7,6,5,4,3,2,1};          // Constantly run these pins
 int switchPin       =            {17};                                     // Acts as switch to change counters
 
 void setup  ()                                 // Starts one time when reset button is pressed or program starts
 {                                               // Start program
   for       (int i = 0; i< 59; i++)            // For value i make it 0, if I is less than 59, add one.
   {
   pinMode   (secondsLEDs[i], OUTPUT);           // Pins 8-13 are set pulled low via output on arduino
   }
   for       (int i = 0; i< 59; i++)            // For value i make it 0, if its less than 59, add one.
   {
   pinMode  (minuetsLEDs[i], OUTPUT);           // Pins 7-1 are pulled low via output on arduino-
   }
  
   setTime(0);                                  // Time is set to 0
 }                                              // End program

 void loop()                                    // To run in repeat from here down
 {
   if (digitalRead(switchPin))                  // If the switch button is pressed add 1 to time.
   {
     adjustTime(1);
   }
   else if (minute() == 0 && second() == 0)     // Or else if the button is not pressed, minuets = 0 and hours equal 0
   {spin(hour());                              // What is the spin function?
   }
 
   updateDisplay();
   delay(10);                                  // Wait 5 seconds
 }
 

 void updateDisplay()                         // Return.
 {
   time_t t = now();                          // The time is set to right now.
   setOutput (secondsLEDs,3, second(t));       // Sets hours at 6.
   setOutput (minuetsLEDs,3, minute(t));       // Sets minuets at 6.
 }
 void setOutput(int *ledArray,int numLEDs, int value)
 {
   for (int i= 0; i < numLEDs; i++)
  
     digitalWrite(ledArray[i],
     bitRead(value, i));
   }
 void spin(int count)
 {
   for (int i = 0; i < count; i++)
   {
     for (int j = 0; j<16; j++)
     {
       digitalWrite(loopLEDs[j], HIGH);
       delay(100);
       digitalWrite(loopLEDs[j],HIGH);
     }
   }
 }
 [code]

[/code]

for       (int i = 0; i< 59; i++)            // For value i make it 0, if I is less than 59, add one.
   {
   pinMode   (secondsLEDs[i], OUTPUT);

How many pins?

   for       (int i = 0; i< 59; i++)            // For value i make it 0, if I is less than 59, add one.
   {
   pinMode   (secondsLEDs[i], OUTPUT);           // Pins 8-13 are set pulled low via output on arduino
   }

Accessing all 59 elements of a 7 element array doesn't seem like a good thing to do.

   for       (int i = 0; i< 59; i++)            // For value i make it 0, if its less than 59, add one.
   {
   pinMode  (minuetsLEDs[i], OUTPUT);           // Pins 7-1 are pulled low via output on arduino-
   }

Accessing all 59 elements of a 7 element array doesn't seem like a good idea.

Oh, wait, I already said that.

 int loopLEDs[]      =            {13,12,11,10,9,8,7,6,5,4,3,2,1};          // Constantly run these pins

First question is what the heck are loopLEDs. Second is why you think you can use some pins for loopLEDs and for secondsLEDs at the same time.

13 DIGITAL PINS. @AWOL
and
What do you mean, why is it a bad way to do it? And I thought if I looped those 1-13 that they would ALL run over and over again MIN and SEC@ paul S

And I thought if I looped those 1-13 that they would ALL run over and over again MIN and SEC

You aren't looping over 13 pins. You are looping over 59 elements in an array that only contains 7.

Setting the mode of a pin has nothing to do with displaying a value on the 7 segment display connected to those pins.

Ok, I think I understand what your talking about. I dont want to loop any pins, I want it to figure out the time and displaying it via pins, like here... https://www.google.com/search?gs_rn=26&gs_ri=psy-ab&cp=9&gs_id=4s&xhr=t&q=binary+clock&bav=on.2,or.r_qf.&bvm=bv.52164340,d.dmg&biw=1280&bih=704&dpr=1&um=1&ie=UTF-8&hl=en&tbm=isch&source=og&sa=N&tab=wi&ei=_z02UpTYF6T_4APwnoGIDw#facrc=_&imgdii=_&imgrc=c7FZwZGq-FRCjM%3A%3BFPcEbU2xZQI5KM%3Bhttp%253A%252F%252Fupload.wikimedia.org%252Fwikipedia%252Fcommons%252Fthumb%252F2%252F27%252FBinary_clock.svg%252F500px-Binary_clock.svg.png%3Bhttp%253A%252F%252Fen.wikipedia.org%252Fwiki%252FBinary_clock%3B500%3B500

I have neglected hours because I dont have enough Digital Outputs on the UNO.

So, you have a value for minutes. Say it's 13. That's 0b1101. Read each bit, using bitRead. Set the corresponding LED pin to the bit value.

for(byte i=0; i<7; i++)
{
   digitalWrite(minutesLEDs, bitRead(minutes, i);
}

Do the same for seconds. The time is then shown.

You do need to loop in setup, to set the mode of the pins, but from 0 to 7, not 0 to 59, in each loop.

sketch_sep15b.ino: In function 'void setup()':
sketch_sep15b:21: error: 'minutesLEDs' was not declared in this scope
sketch_sep15b:21: error: 'minutes' was not declared in this scope
sketch_sep15b:30: error: a function-definition is not allowed here before '{' token
sketch_sep15b:68: error: expected `}' at end of input

hm?

 #include <Time.h>
 int secondsLEDs []  =            {0,1,2,3,4,5,6};                          // Mins will be displayed on pin's
 int minuetsLEDs []  =            {7,8,9,10,11,12,13};                         // Hours will display on pin's
 // Incase this is correct erase both // int loopLEDs[]      =            {13,12,11,10,9,8,7,6,5,4,3,2,1};          // Constantly run these pins
 int switchPin       =            {17};                                     // Acts as switch to change counters
 
 void setup  ()                                 // Starts one time when reset button is pressed or program starts
 {                                               // Start program
   for       (int i = 0; i< 7; i++)            // For value i make it 0, if I is less than 59, add one.
   {
   pinMode   (secondsLEDs[i], OUTPUT);           // Pins 8-13 are set pulled low via output on arduino
   }
   for       (int i = 0; i< 7; i++)            // For value i make it 0, if its less than 59, add one.
   {
   pinMode  (minuetsLEDs[i], OUTPUT);           // Pins 7-1 are pulled low via output on arduino-
   }
   
{ 
   for(byte i=0; i<7; i++)

   digitalWrite(minutesLEDs, bitRead(minutes, i);
}
  
  
 {
  setTime(0);                                  // Time is set to 0
 }                                              // End program

 void loop()                                    // To run in repeat from here down
 {
   if (digitalRead(switchPin))                  // If the switch button is pressed add 1 to time.
   {
     adjustTime(1);
   }
   else if (minute() == 0 && second() == 0)     // Or else if the button is not pressed, minuets = 0 and hours equal 0
   {spin(hour());                              // What is the spin function?
   }
 
   updateDisplay();
   delay(10);                                  // Wait 5 seconds
 }
 

 void updateDisplay()                         // Return.
 {
   time_t t = now();                          // The time is set to right now.
   setOutput (secondsLEDs,3, second(t));       // Sets hours at 6.
   setOutput (minuetsLEDs,3, minute(t));       // Sets minuets at 6.
 }
 void setOutput(int *ledArray,int numLEDs, int value)
 {
   for (int i= 0; i < numLEDs; i++)
  
     digitalWrite(ledArray[i],
     bitRead(value, i));
   }
 void spin(int count)
 {
   for (int i = 0; i < count; i++)
   {
     for (int j = 0; j<16; j++)
     {
       digitalWrite(loopLEDs[j], HIGH);
       delay(100);
       digitalWrite(loopLEDs[j],HIGH);
     }
   }
 }

sketch_sep15b:21: error: 'minutesLEDs' was not declared in this scope
sketch_sep15b:21: error: 'minutes' was not declared in this scope

minuetsLEDs != minutesLEDs

And no, "minutes" wasn't declared in scope.

Looks to me like you need to pay more attention to matching braces.