Go Down

Topic: Domino Clock (Read 12 times) previous topic - next topic

CrossRoads

All this stuff here
Code: [Select]

//Hour adjustment
// if the button is pressed
// 1) reset the debouncing timer
// 2) take the debounce delay as the current state
// 3) Set time
// 4) save the hourstat

if (hourState == HIGH) {

  lastDebounceTime = millis();

  if ((millis() - lastDebounceTime) > debounceDelay) {
    buttonState = hourstate;
  }

  time_t t = now();
  t = t + 3600;
  setTime(t);

  lastButtonState = hourstate;

}

//Minute adjustment
if (minState == HIGH) {

  lastDebounceTime = millis();

  if ((millis() - lastDebounceTime) > debounceDelay) {
    buttonState2 = minstate;
  }

  time_t t = now();
  t = t + 60;
  setTime(t);
  lastButtonState2 = minstate;
}

needs to be part of void loop, or a function that void loop calls.
If it is in void setup, you get that brief shot as your sketch starts to press the buttons, and then no more.

please start putting [ code ] and [ /code ] (without the spaces) around the code you post. The # sign pull them up for you also.
Designing & building electrical circuits for over 25 years. Check out the ATMega1284P based Bobuino and other '328P & '1284P creations & offerings at  www.crossroadsfencing.com/BobuinoRev17.
Arduino for Teens available at Amazon.com.

stregoi

okay thank you .. but was it the right way to do a debounce, because it was i understood from the sources i read ?

what about the RTC, do you have any suggestions how to set the digits to only change every second ... should i use delay(60000) efter the minutes is shifted ?

CrossRoads

This section of code
Code: [Select]

void loop() {

    h = hourFormat12();
    m = minute();

    if(previousHours != h) {
digitalWrite(hlatchPin, LOW);
shiftOut(hdataPin, hclockPin, MSBFIRST, (number_to_display[h] >>8));
shiftOut(hdataPin, hclockPin, MSBFIRST, hours_display[h]);

digitalWrite(hlatchPin, HIGH);
previousHours = h;
    }
    if(previousMins != m) {

constantly reads the RTC and see if the hour has changed, or if the minute has changed.
Why do you think you need to do anything else?
As far as debounce, give it a try, see if it works.
Designing & building electrical circuits for over 25 years. Check out the ATMega1284P based Bobuino and other '328P & '1284P creations & offerings at  www.crossroadsfencing.com/BobuinoRev17.
Arduino for Teens available at Amazon.com.

stregoi

i just tried to make the setup .. i can flip the dot one way, but nit the other way ! .. i guess that i have to use a H-brigde anyways. i've looking around at the internet and i guess i will use "L293D"

http://www.datasheetcatalog.org/datasheet/texasinstruments/l293d.pdf

it can only run 2 stepmotors / electromagnets at a time ... my question is what is the smartest to do, one H-bridge for every single electromagnet ? and please how can i connect these to my shift registers ?

CrossRoads

So the magnet pulling back to the screwhead is not working? That's too bad. Let me do datasheet reading & thinking.
Designing & building electrical circuits for over 25 years. Check out the ATMega1284P based Bobuino and other '328P & '1284P creations & offerings at  www.crossroadsfencing.com/BobuinoRev17.
Arduino for Teens available at Amazon.com.

Go Up