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);
}
}
}*_