YOU STARS!
Thank you for fixing my poor excuse for code,it is now counting up and displaying perfectly with this code
#include "LedControl.h" // Include the LedControl library
LedControl lc=LedControl(12,11,10,1); // Set up an LED object on pins 12,11,10
int seconds_ones;
int minutes_ones;
int seconds_tens; // Initialise values for tens and ones units of h,m,s
int minutes_tens; // these are the values actually sent to the LEDs
unsigned long prevMillis = 0;
unsigned char seconds = 0;
unsigned char minutes = 0; // Inititialise actual values for m,s
int mins_increase = 0;
void set_time() {}
void display_time () { // Function to display the time
seconds_ones = seconds % 10; // Get the 1's digit of seconds
if (seconds>=10){ // If seconds greater than 10
seconds_tens = seconds / 10;} // Get 10's digit of seconds
else {
seconds_tens = 0;} // Otherwise 10s is 0
minutes_ones = minutes % 10; // Repeat for minutes
if (minutes>=10){
minutes_tens = minutes / 10 ;}
else {
minutes_tens = 0;}
lc.setDigit(0,0,(byte)seconds_ones,false); // Send digits to LEDs
lc.setDigit(0,1,(byte)seconds_tens,false);
lc.setDigit(0,2,(byte)minutes_ones,false);
lc.setDigit(0,3,(byte)minutes_tens,false);
}
void setup () {
lc.shutdown(0,false); // Turn on the LEDs
lc.setIntensity(0,15); // Set intensity to full
set_time(); // Run the time set function
}
void loop () {
if( millis() - prevMillis >= 1000)
{
seconds = seconds + 1; // Increment the seconds
prevMillis += 1000;
if (seconds>59) // If a minute has passed
{
seconds = 0; // Send seconds back to 0
minutes = minutes + 1; // Increment the minutes
if (minutes > 59) // If an hour has passed
{
minutes = 0; // Send the minutes back to 0
{
}
}
}
}
display_time ();
delay(1000);
}
going to try and get it to count down now.....so that should be fun, but think i can do it thanks to some tips from Rusty in Texas, but sure i will harass you guys if i get suck! ![]()