AndrewMascolo / CountUpDownTimer

MIT License
28 stars 20 forks source link

Time not visible on screen #17

Open Egauss opened 7 years ago

Egauss commented 7 years ago

have some kind code, but cant sort out where are problem

two first segments showing seconds and minutes missing, time cursor missing as well, when time less 10 sec = 90 but must by 09

include

const byte PIN_CLK = 12; // define CLK pin (any digital pin) const byte PIN_DIO = 11; // define DIO pin (any digital pin) SevenSegmentTM1637 display(PIN_CLK, PIN_DIO);

include

CountUpDownTimer T(DOWN);

int led = 13; int hourT; int minutesT; int secondsT; int hourDisp; int minutesDisp; int secondsDisp; int hNTS; int mNTS; int sNTS; String HST; String MNT; String SNT;

// run setup code void setup() { Serial.begin(9600); // initializes the Serial connection @ 9600 baud display.begin(); // initializes the display display.setBacklight(100); // set the brightness to 100 %

pinMode(led, OUTPUT);

display.print("...."); display.blink(3000); display.clear(); T.StartTimer(); T.SetTimer(120); }

void loop() { T.Timer();

digitalWrite(led, HIGH);

if (T.TimeHasChanged() ) // this prevents the time from being constantly shown. {

//display.print(T.ShowHours()); display.print(T.ShowMinutes()); display.print(T.ShowSeconds());

Serial.print(T.ShowHours()); Serial.print(":"); Serial.print(T.ShowMinutes()); Serial.print(":"); Serial.print(T.ShowSeconds());

minutesT = T.ShowMinutes(); secondsT = T.ShowSeconds(); if (minutesT == 0 && secondsT == 0) { T.StopTimer(); digitalWrite(led, LOW); delay(10000); display.off(); } }

}

AndrewMascolo commented 7 years ago

I am unfamiliar with your display library, check to see if it has an up date function. If it does then set the time and call it. Once you get that working try some debugging.

I don't have any of my equipment to run any tests, so I can only rely on your tests to move further.

Sent from my iPhone

On Dec 27, 2016, at 6:45 PM, Egauss notifications@github.com wrote:

have some kind code, but cant sort out where are problem

two first segments showing seconds and minutes missing, time cursor missing as well, when time less 10 sec = 90 but must by 09

include

const byte PIN_CLK = 12; // define CLK pin (any digital pin) const byte PIN_DIO = 11; // define DIO pin (any digital pin) SevenSegmentTM1637 display(PIN_CLK, PIN_DIO);

include

CountUpDownTimer T(DOWN);

int led = 13; int hourT; int minutesT; int secondsT; int hourDisp; int minutesDisp; int secondsDisp; int hNTS; int mNTS; int sNTS; String HST; String MNT; String SNT;

// run setup code void setup() { Serial.begin(9600); // initializes the Serial connection @ 9600 baud display.begin(); // initializes the display display.setBacklight(100); // set the brightness to 100 %

pinMode(led, OUTPUT);

display.print("...."); display.blink(3000); display.clear(); T.StartTimer(); T.SetTimer(120); }

void loop() { T.Timer();

digitalWrite(led, HIGH);

if (T.TimeHasChanged() ) // this prevents the time from being constantly shown. {

//display.print(T.ShowHours()); display.print(T.ShowMinutes()); display.print(T.ShowSeconds());

Serial.print(T.ShowHours()); Serial.print(":"); Serial.print(T.ShowMinutes()); Serial.print(":"); Serial.print(T.ShowSeconds());

minutesT = T.ShowMinutes(); secondsT = T.ShowSeconds(); if (minutesT == 0 && secondsT == 0) { T.StopTimer(); digitalWrite(led, LOW); delay(10000); display.off(); } }

}

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub, or mute the thread.

Egauss commented 7 years ago

Thanks, for prom reply, i found missing bits.... now i have another small issue: on the end of time i have 00:01 instead 00:00 any idea?

include

include

const byte PIN_CLK = 12; // define CLK pin (any digital pin) const byte PIN_DIO = 11; // define DIO pin (any digital pin) SevenSegmentExtended display(PIN_CLK, PIN_DIO);

include

CountUpDownTimer T(DOWN);

int led = 13;

int minutesT; int secondsT;

// run setup code void setup() { Serial.begin(9600); // initializes the Serial connection @ 9600 baud display.begin(); // initializes the display display.setBacklight(100); // set the brightness to 100 %

pinMode(led, OUTPUT);

display.print("...."); display.blink(3000); display.clear(); T.StartTimer(); T.SetTimer(120); }

void loop() { T.Timer();

digitalWrite(led, HIGH);

if (T.TimeHasChanged() ) // this prevents the time from being constantly shown. { display.printTime(minutesT, secondsT, true);

}

Serial.print(T.ShowMinutes()); Serial.print(":"); Serial.print(T.ShowSeconds());

minutesT = T.ShowMinutes(); secondsT = T.ShowSeconds();

if (minutesT == 0 && secondsT == 0) { T.StopTimer(); digitalWrite(led, LOW); delay(10000); // display.off(); } }

AndrewMascolo commented 7 years ago

Try changing this part here

if (T.TimeHasChanged() ) // this prevents the time from being constantly shown. {

Serial.print(T.ShowMinutes());

Serial.print(":");

Serial.print(T.ShowSeconds());

minutesT = T.ShowMinutes(); secondsT = T.ShowSeconds();

// once the minutes and seconds are set, you display them display.printTime(minutesT, secondsT, true); } Sent from my iPhone

On Dec 27, 2016, at 10:56 PM, Egauss notifications@github.com wrote:

if (T.TimeHasChanged() ) // this prevents the time from being constantly shown. { display.printTime(minutesT, secondsT, true);

}

Serial.print(T.ShowMinutes()); Serial.print(":"); Serial.print(T.ShowSeconds());

minutesT = T.ShowMinutes(); secondsT = T.ShowSeconds();

Egauss commented 7 years ago

Thanks its works, and sorry i am just couple days playing with Arduino still lauds to learn.

Do you have experience how to turn on/off leds with this library?

its looks not easy for me.

timer stops at 00:10 first led off (still little bit glowing) second led on

include

include

const byte PIN_CLK = 12; // define CLK pin (any digital pin) const byte PIN_DIO = 11; // define DIO pin (any digital pin) SevenSegmentExtended display(PIN_CLK, PIN_DIO);

include

CountUpDownTimer T(DOWN);

int led1 = 13; int led2 = 10; int led3 = 9;

int minT; int secT;

// run setup code void setup() { Serial.begin(9600); // initializes the Serial connection @ 9600 baud display.begin(); // initializes the display display.setBacklight(100); // set the brightness to 100 % int led1State = LOW;

pinMode(led1, OUTPUT);

display.print("...."); display.blink(3000); display.clear(); T.StartTimer(); T.SetTimer(20); }

void loop() {

T.Timer();

digitalWrite(led1, HIGH);

if (T.TimeHasChanged() ) // this prevents the time from being constantly shown. {

Serial.print(T.ShowMinutes()); Serial.print(":"); Serial.print(T.ShowSeconds());

minT = T.ShowMinutes(); secT = T.ShowSeconds();

display.printTime(minT, secT, true); }

if (minT == 0 && secT == 10){ T.PauseTimer(); digitalWrite(led1, LOW); delay(1000);

digitalWrite(led2, HIGH); if(digitalRead(10) == HIGH) T.ResumeTimer();

//digitalWrite(led2, HIGH); //if (minT == 0 && secT == 0) {

//display.clear(); //display.print("DONE"); //display.blink(3000); // display.off();

} }

AndrewMascolo commented 7 years ago

Led1 is constantly being turned on and off, which is why it is glowing. To solve this just use one variable, Led1State.

Set it to true when you start the timer and make sure you use it in digitalwrite(led1, Led1State);

This way the led is always looking at that variable instead of hard coding true or false.

Now according to your code, led2, when it is high is set to resume the timer. Is this what you want? When does it turn off?

Also you are telling the code to pause the timer at seconds = 10 and immediately resuming it.

digitalWrite(led2, HIGH) and digitalRead(10) are both looking at the same pin. So one is setting pin 10 High and the other is always reading pin 10 is high.

Maybe add more If statements to turn off led2

Sent from my iPhone

On Dec 28, 2016, at 8:05 PM, Egauss notifications@github.com wrote:

Thanks its works, and sorry i am just couple days playing with Arduino still lauds to learn.

Do you have experience how to turn on/off leds with this library?

its looks not easy for me.

timer stops at 00:10 first led off (still little bit glowing) second led on

include

include

const byte PIN_CLK = 12; // define CLK pin (any digital pin) const byte PIN_DIO = 11; // define DIO pin (any digital pin) SevenSegmentExtended display(PIN_CLK, PIN_DIO);

include

CountUpDownTimer T(DOWN);

int led1 = 13; int led2 = 10; int led3 = 9;

int minT; int secT;

// run setup code void setup() { Serial.begin(9600); // initializes the Serial connection @ 9600 baud display.begin(); // initializes the display display.setBacklight(100); // set the brightness to 100 % int led1State = LOW;

pinMode(led1, OUTPUT);

display.print("...."); display.blink(3000); display.clear(); T.StartTimer(); T.SetTimer(20); }

void loop() {

T.Timer();

digitalWrite(led1, HIGH);

if (T.TimeHasChanged() ) // this prevents the time from being constantly shown. {

Serial.print(T.ShowMinutes()); Serial.print(":"); Serial.print(T.ShowSeconds());

minT = T.ShowMinutes(); secT = T.ShowSeconds();

display.printTime(minT, secT, true); }

if (minT == 0 && secT == 10){ T.PauseTimer(); digitalWrite(led1, LOW); delay(1000);

digitalWrite(led2, HIGH); if(digitalRead(10) == HIGH) T.ResumeTimer();

//digitalWrite(led2, HIGH); //if (minT == 0 && secT == 0) {

//display.clear(); //display.print("DONE"); //display.blink(3000); // display.off();

} }

— You are receiving this because you commented. Reply to this email directly, view it on GitHub, or mute the thread.

Egauss commented 7 years ago

With this code led2, led3 works , but led1 stays ON. just blink one time at the moment when must be OFF. And if i add display.blink on the end led3 have delay coupe sec.

include

include

const byte PIN_CLK = 12; // define CLK pin (any digital pin) const byte PIN_DIO = 11; // define DIO pin (any digital pin) SevenSegmentExtended display(PIN_CLK, PIN_DIO);

include

CountUpDownTimer T(DOWN);

int led1 = 13; int led2 = 10; int led3 = 9; int led4 = 8; int butt1 = 7; int buzz1 = 6; int led1State = LOW; int led2State = LOW; int led3State = LOW; int led4State = LOW; int minT; int secT;

// run setup code void setup() { Serial.begin(9600); // initializes the Serial connection @ 9600 baud display.begin(); // initializes the display display.setBacklight(100); // set the brightness to 100 %

pinMode(led1, OUTPUT); pinMode(led2, OUTPUT); pinMode(led3, OUTPUT); pinMode(led4, OUTPUT); pinMode(butt1, INPUT); pinMode(buzz1, OUTPUT);

display.print("...."); display.blink(3000); display.clear(); T.StartTimer(); T.SetTimer(30); }

void loop() {

T.Timer();

digitalWrite(led1, led1State); led1State = true;

if (T.TimeHasChanged() ) // this prevents the time from being constantly shown. {

Serial.print(T.ShowMinutes()); Serial.print(":"); Serial.print(T.ShowSeconds());

minT = T.ShowMinutes(); secT = T.ShowSeconds();

display.printTime(minT, secT, true);

}

if (minT == 0 && secT == 20){ digitalWrite(led1, led1State); led1State = false;

digitalWrite(led2, led2State); led2State = true; } if (minT == 0 && secT == 10) { digitalWrite(led2, led2State); led2State = false;

digitalWrite(led3, led3State); led3State = true; } if (minT == 0 && secT == 0) { digitalWrite(led3, led3State); led3State = false;

T.StopTimer(); display.print("DONE"); //display.blink(3000); } }

AndrewMascolo commented 7 years ago

Your code is backwards. You need to set the variable first THEN use it in the digitalWrite.

Sent from my iPhone

On Dec 28, 2016, at 11:30 PM, Egauss notifications@github.com wrote:

With this code led2, led3 works , but led1 stays ON. just blink one time at the moment when must be OFF. And if i add display.blink on the end led3 have delay coupe sec.

include

include

const byte PIN_CLK = 12; // define CLK pin (any digital pin) const byte PIN_DIO = 11; // define DIO pin (any digital pin) SevenSegmentExtended display(PIN_CLK, PIN_DIO);

include

CountUpDownTimer T(DOWN);

int led1 = 13; int led2 = 10; int led3 = 9; int led4 = 8; int butt1 = 7; int buzz1 = 6; int led1State = LOW; int led2State = LOW; int led3State = LOW; int led4State = LOW; int minT; int secT;

// run setup code void setup() { Serial.begin(9600); // initializes the Serial connection @ 9600 baud display.begin(); // initializes the display display.setBacklight(100); // set the brightness to 100 %

pinMode(led1, OUTPUT); pinMode(led2, OUTPUT); pinMode(led3, OUTPUT); pinMode(led4, OUTPUT); pinMode(butt1, INPUT); pinMode(buzz1, OUTPUT);

display.print("...."); display.blink(3000); display.clear(); T.StartTimer(); T.SetTimer(30); }

void loop() {

T.Timer();

digitalWrite(led1, led1State); led1State = true;

if (T.TimeHasChanged() ) // this prevents the time from being constantly shown. {

Serial.print(T.ShowMinutes()); Serial.print(":"); Serial.print(T.ShowSeconds());

minT = T.ShowMinutes(); secT = T.ShowSeconds();

display.printTime(minT, secT, true);

}

if (minT == 0 && secT == 20){ digitalWrite(led1, led1State); led1State = false;

digitalWrite(led2, led2State); led2State = true; } if (minT == 0 && secT == 10) { digitalWrite(led2, led2State); led2State = false;

digitalWrite(led3, led3State); led3State = true; } if (minT == 0 && secT == 0) { digitalWrite(led3, led3State); led3State = false;

T.StopTimer(); display.print("DONE"); //display.blink(3000); } }

— You are receiving this because you commented. Reply to this email directly, view it on GitHub, or mute the thread.