Re: Help Needed With My Code

Don't you need a Void Setup() somewhere? I am new at this too.

Yes I do, but was waiting for a hand on how it should fit in with the void display_time.

think it would go at the end of that and just befor loop

void setup () {

   lc.shutdown(0,false);          // Turn on the LEDs
   lc.setIntensity(0,15);         // Set intensity to full
}

Any help welcome :-[

so would be

/*       n00b's 1 hour countdown.
Attempting to make a code for a countdown for 60.00 to 00.00 (mm.ss) on 4 x 7-segment LEDs
*/
#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 m,s
int minutes_tens;        // these are the values actually sent to the LEDs
volatile unsigned char tick;
unsigned char seconds = 0;
unsigned char minutes = 60;     // Inititialise actual values for mm,ss

ISR (TIMER2_OVF_vect) {     // When timer2 overflows...
  tick++;             // increment tick
 
 
}


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
}


void loop () {

if (tick) {                 // If a tick has occured
  seconds = seconds - 1;          // decrement the seconds
  tick = 0;                 // reset the tick flag
  if (seconds<0){             // If a minute has passed
  seconds = 59;              // Send seconds back to 59
  minutes = minutes - 1;          // decrement the minutes
    minutes = 0;            // Send the minutes back to 0
    display_time ();       // send the time to the LEDs to be displayed

but think im missing a “set up timer” in the setup too???

I don't know, I just started 'c' a few days ago.

:-(

;) the Arduino is so much fun till you get stuck

There are about a dozen different active threads on a 60 minute countdown timer. Maybe you could check one of them for the help you need.

I think most of them are started by me :'(

What i need it someone to go "look sweetheart, this is where you going wrong, and this is how you fix it"

but no one wants to give a girl a brake!