Skip to content

LED control code in "p08_DigitalHourglass" affects non-LED pins after completion of timer #83

@drf5n

Description

@drf5n

if (currentTime - previousTime > interval) {
// save the current time as the last time you changed an LED
previousTime = currentTime;
// Turn the LED on
digitalWrite(led, HIGH);
// increment the led variable
// in 10 minutes the next LED will light up
led++;
if (led == 7) {
// the hour is up
}
}

Note that the code in the Digital Hourglass example starts cycling above pin 7 after the hour is up, setting pins to low and essentially setting the pinMode(switchPin,INPUT_PULLUP), overriding the external pulldown, and making the button non-functional.

The code should either reset the hourglass automatically, or check that it is in the 2-7 range before setting the pin to low.

Maybe change the test to:

if (currentTime - previousTime > interval && led <= 7 ) {

Sped-up (6 seconds/step) Example:

https://wokwi.com/projects/422992836439284737

Metadata

Metadata

Assignees

Labels

conclusion: off topicOff topic for this repositorytopic: codeRelated to content of the project itselftype: imperfectionPerceived defect in any part of project

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions

    pFad - Phonifier reborn

    Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

    Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


    Alternative Proxies:

    Alternative Proxy

    pFad Proxy

    pFad v3 Proxy

    pFad v4 Proxy