Domino Clock

Not like that.
You can't see the .jpg attachment in reply #9?

If you want the LED/Resistor there, connect it to the collector of the transistor.

i See .. but please just bear with my, i am trying to understand. The ULN2083 has 18 pins, but i can only see 2 in your schematics.

what about hookinit the the shift register is it from the SW side ?

Okay, here's a more complete picture. The transistor was meant to represent one driver of the ULN2803, and to provide a means to test if your electromagnet worked.

I stuck in the 7-driver ULN2003 as an example here, replace with the 8-driver ULN2803 if that's what you have.
Or go with the indivual transistors driven by the shift register out (with a series resistor, likethe input to the ULN part has)

For the shift register, you are using shiftout command?
So, datapin goes to SerDataIn
shiftclock goes to SerInClk
your latch control, an output that you will make go from Low to High after the Shiftout, goes to OutClk.

For example, here I shift out 2 bytes, then clock the output register

 digitalWrite(outclock, LOW);  // set up output clock
 // shift out highbyte
 shiftOut(shiftdataout, serialclock, MSBFIRST, highbyte);  // clocks out 8 bits
 // shift out lowbyte
 shiftOut(shiftdataout, serialclock, MSBFIRST, lowbyte); // clocks out 8 bits
digitalWrite(outclock, HIGH);  // this transition makes the data show up on the outputs

OutH/ goes to SerDataIn on the next device.
OE/ goes to ground
SerCLR goes to +5V.

Ahhh i Understand now, that made a lot of sans ! thanks a lot !

last question ( quite banal indeed ! ) .. for the push buttons to set the hours and minuts, i am plannning to hook them to the analog pin 0 ( PC0 ) and 5 ( PC5 ) of the arduino, where the one leg is connected to the 5v through a resistor and the other leg is grounded.

i am also planning to use a RTC to get an accurate time, instead of the internal clock, using the schematic in the picture

is it the right way to do it ?

Don't know, never used the DS1307, can you send a linkt to a datasheet? The drawing looks very nice.
I believe you have the right arduino pins (or at worst they are swapped).

For push buttons, why not use the internal pullups and switch to ground instead? Save on a few parts.
Which pins are PC0 & PC5? Aren't those the analog pins?
You already have A5 committed to SCL above, so that wouldn't be a good choice for an input pin.

Great Then ! yes the PC0 and the PC5 are analog pins, so i guess i will just use PC0 and PC3 wich is analog too.

i just did a little research about using internal pull-ups, but i cant see the logic in saving parts, because as far as i understood i will still using 2 push buttons and to resistors.

and the datascheet for the RTC is : http://www.datasheetdir.com/DS1307+download

With the internal pullups, you only need the switch.
With the switch open, the pin is pulled high internally and reads as 1.
To get 0 you close the switch to ground. No external resistors needed.

You can use digital pins for switch closures like this as well, doesn't have to go into an analog pin.

Sounds Very good, i guess i will stick with the 2 push up buttons to set the hours and the minutes, it is much easier for me to understand, the newbee as i am :slight_smile:
I guess my hardware part is done .. thanks for a big help, i learned a lot.

now i have to move to the coding part, and i guess i will read the earlier post you answered earlier, i should learned something from there, since i guess it will fit with what i am doing.

i will surely ask for more help :slight_smile: ... and i will publish my steps so others can learn something too :slight_smile:

i Guess you should take a look at the the FP2880A is kind of smart and can be used to control the flip-dots, here is the dokumentation :

http://www.datasheetcatalog.org/datasheets/320/500899_DS.pdf

but there is no much information / projects with it in google.

Now for the code :slight_smile: .... i've been studying the code from the original thread, from the biginning i can't understand this part of code :

//Data Lines to the hour stone
int hlatchPin = 3;
int hclockPin = 4;
int hdataPin = 5;

//Data Lines to the decimal minute stone
int dlatchPin = 6;
int dclockPin = 7;
int ddataPin = 8;

//Data Lines to the single minute stone
int mlatchPin = 9;
int mclockPin = 10;
int mdataPin = 11;

as far as i understood we are hooking ALL the 75HC595's to only 3 output pins ( latch / clock / data ) witch are ( 8 / 11 / 12 ),
In the code why are we defining 6 output pins from the adruino ? is it because every to 74HC595 are going to be hooked to three pin's in the adruino ( 2 shift registers at 3 / 4 / 5 ) ( 2 shift registers at 6 / 7 / 8 )( 2 shift registers at 9 / 10 / 11 )?

Either method works.
The original allows the 3 "digits" to be updated individually.
Your schematics will have all data go out at once. Either way can work.

The FP2800 looks like a nice chip, able to both output high current and sink high current (unlike the ULN2803, which only sinks current).
Wonder where they are available?

Yeah .. it seems like something nice, unfortunetly it's quite hard to find and almost no DIY projects with it. I guess you can request it from this website : Buy Electronic Parts OEM Electronic Component IC Inventory, Military Aircraft Aerospace Marine Automotive Parts - HoBid.com

i was thinking to experiment with it, but i guess i'll stick to the easy stuff for now .. this project, is kind of "learning by doing" so .

About the code .. that made sans !

i was editing the code spencerH wrote, taking in onsideration your answers too, i have a "finished" version ... is it okay you think ? ( it makes sans to me anyways :slight_smile: )

#include <Time.h>


//Data Lines to the hour stone
int hlatchPin = 3;
int hclockPin = 4;
int hdataPin = 5;

//Data Lines to the decimal minute stone
int dlatchPin = 6;
int dclockPin = 7;
int ddataPin = 8;

//Data Lines to the single minute stone
int mlatchPin = 9;
int mclockPin = 10;
int mdataPin = 11;

int h = 0;
int m = 0;
int mins = 0;
int d = 0;
int previousHours = 0;
int previousMins = 0;


byte number_to_display;


//hour and minute adjust buttons
const int hourPin = 12;
const int minPin = 13;

void loop() {

hourState = digitalRead(hourPin);
minState = digitalRead(minPin);

//Hour adjustment
if (hourState == HIGH) {
  time_t t = now();
  t = t + 3600;
  setTime(t);
}
//Minute adjustment
if (minState == HIGH) {
  time_t t = now();
  t = t + 60;
  setTime(t);
}


void setup() {

  pinMode(hlatchPin, OUTPUT);
  pinMode(hclockPin, OUTPUT);
  pinMode(hdataPin, OUTPUT);

  pinMode(dlatchPin, OUTPUT);
  pinMode(dclockPin, OUTPUT);
  pinMode(ddataPin, OUTPUT);

  pinMode(mlatchPin, OUTPUT);
  pinMode(mclockPin, OUTPUT);
  pinMode(mdataPin, OUTPUT);



int hours_display[13];

number_to_display[0] = B0000000000000000;
number_to_display[1] = 0000000001000000;
number_to_display[2] = 0100000001000000;
number_to_display[3] = 0100000000100100;
number_to_display[4] = 0010010000100100;
number_to_display[5] = 0010010001100100;
number_to_display[6] = 0110010001100100;
number_to_display[7] = 0110010000101101;
number_to_display[8] = 0010110100101101;
number_to_display[9] = 0010110101101101;
number_to_display[10] = 0110110101101101;
number_to_display[11] = 0110110100111111;
number_to_display[12] = 0011111100111111;
}

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) {
	mins = m;
	if(mins >= 10) {
	  d = 0;
	  while(mins >= 10) {
	    mins = mins - 10;
	    d = d + 1;
	  }
	  digitalWrite(dlatchPin, LOW);
	  shiftOut(ddataPin, dclockPin, MSBFIRST, (number_to_display[d] >> 8));
          shiftOut(ddataPin, dclockPin, MSBFIRST, number_to_display[d]);

	  digitalWrite(dlatchPin, HIGH);
	  digitalWrite(mlatchPin, LOW);
          shiftOut(mdataPin, mclockPin, MSBFIRST, (number_to_display[mins] >> 8));
          shiftOut(mdataPin, mclockPin, MSBFIRST, number_to_display[mins]);

	  digitalWrite(mlatchPin, HIGH);
	}
	else {
	  digitalWrite(dlatchPin, LOW);
	  shiftOut(ddataPin, dclockPin, MSBFIRST, 0);
	  shiftOut(ddataPin, dclockPin, MSBFIRST, 0);
	  shiftOut(ddataPin, dclockPin, MSBFIRST, 0);
	  digitalWrite(dlatchPin, HIGH);
	  digitalWrite(mlatchPin, LOW);
          shiftOut(mdataPin, mclockPin, MSBFIRST, (number_to_display[mins] >> 8));
          shiftOut(mdataPin, mclockPin, MSBFIRST, number_to_display[mins]);
	  digitalWrite(mlatchPin, HIGH);
	}
	previousMins = m;
    }

}

Okay, here's my initial comments.

Need to declare your time set buttons as pinMode inputs. (just good coding practice - may work as is with the default after a reset being to put the pins into input state I believe).

You declare a bunch of stuff in setup that belongs prior to setup. May work as is, again just good coding practice
everything from
int hours_display[13];
down to
number_to_display[12] = 0011111100111111;

Okay, this part will be a gotcha:
You have void loop, void setup, and then void loop again.
I would probably take the button reading stuff in the first void loop and insert it before } that ends the 2nd void loop.
I'm not sure how fast the 2nd void loop goes thru, probably pretty darn fast since the 2 if conditions are only met once/hour and once/minute.

You likely need some debounce code with the button press to avoid multiple changes with each press.
You have access to seconds with time.h? Maybe ensure that digits only change once a second or something.

Okay i made the changes in the code ( in red ) - including the debounce code, i hope it is coded right.

Thought I cannot figure out how to use the clock, i ensure that digits only change once a second.

I am using a real-time clock DS1307 i found this code, for defining the library, but honestly i can figure out how to do it :

/*
 * DS1307RTC.h - library for DS1307 RTC
 * This library is intended to be uses with Arduino Time.h library functions
 */

#ifndef DS1307RTC_h
#define DS1307RTC_h

#include <Time.h>

// library interface description
class DS1307RTC
{
  // user-accessible "public" interface
  public:
    DS1307RTC();
    static time_t get();
        static void set(time_t t);
        static void read(tmElements_t &tm);
        static void write(tmElements_t &tm);

  private:
        static uint8_t dec2bcd(uint8_t num);
    static uint8_t bcd2dec(uint8_t num);
};

extern DS1307RTC RTC;

#endif
#include <Time.h>


//Data Lines to the hour stone
int hlatchPin = 3;
int hclockPin = 4;
int hdataPin = 5;

//Data Lines to the decimal minute stone
int dlatchPin = 6;
int dclockPin = 7;
int ddataPin = 8;

//Data Lines to the single minute stone
int mlatchPin = 9;
int mclockPin = 10;
int mdataPin = 11;

int h = 0;
int m = 0;
int mins = 0;
int d = 0;
int previousHours = 0;
int previousMins = 0;

byte number_to_display;

//hour and minute adjust buttons
const int hourPin = 12;
const int minPin = 13;

[color=red]int hours_display[13];
number_to_display[0] = B0000000000000000;
number_to_display[1] = 0000000001000000;
number_to_display[2] = 0100000001000000;
number_to_display[3] = 0100000000100100;
number_to_display[4] = 0010010000100100;
number_to_display[5] = 0010010001100100;
number_to_display[6] = 0110010001100100;
number_to_display[7] = 0110010000101101;
number_to_display[8] = 0010110100101101;
number_to_display[9] = 0010110101101101;
number_to_display[10] = 0110110101101101;
number_to_display[11] = 0110110100111111;
number_to_display[12] = 0011111100111111;[/color]

void setup() {

  pinMode(hlatchPin, OUTPUT);
  pinMode(hclockPin, OUTPUT);
  pinMode(hdataPin, OUTPUT);

  pinMode(dlatchPin, OUTPUT);
  pinMode(dclockPin, OUTPUT);
  pinMode(ddataPin, OUTPUT);

  pinMode(mlatchPin, OUTPUT);
  pinMode(mclockPin, OUTPUT);
  pinMode(mdataPin, OUTPUT);

[color=red]  pinMode(hourPin, INPUT);
  pinMode(minPin, INPUT);[/color]

[color=red]
int hourState = digitalRead(hourPin);
int minState = digitalRead(minPin);

int buttonState;             // the current hourstate from the input pin
int lastButtonState = LOW;   // the previous hourstate from the input pin
int buttonState2;             // the current hourstate from the input pin
int lastButtonState2 = LOW;   // the previous hourstate from the input pin

long lastDebounceTime = 0;  // the last time the output pin was toggled
long debounceDelay = 50;    // the debounce time; increase if the output flickers

//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;
}[/color]
}

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) {
	mins = m;
	if(mins >= 10) {
	  d = 0;
	  while(mins >= 10) {
	    mins = mins - 10;
	    d = d + 1;
	  }
	  digitalWrite(dlatchPin, LOW);
	  shiftOut(ddataPin, dclockPin, MSBFIRST, (number_to_display[d] >> 8 ));
          shiftOut(ddataPin, dclockPin, MSBFIRST, number_to_display[d]);

	  digitalWrite(dlatchPin, HIGH);
	  digitalWrite(mlatchPin, LOW);
          shiftOut(mdataPin, mclockPin, MSBFIRST, (number_to_display[mins] >> 8 ));
          shiftOut(mdataPin, mclockPin, MSBFIRST, number_to_display[mins]);

	  digitalWrite(mlatchPin, HIGH);
	}
	else {
	  digitalWrite(dlatchPin, LOW);
	  shiftOut(ddataPin, dclockPin, MSBFIRST, 0);
	  shiftOut(ddataPin, dclockPin, MSBFIRST, 0);
	  shiftOut(ddataPin, dclockPin, MSBFIRST, 0);
	  digitalWrite(dlatchPin, HIGH);
	  digitalWrite(mlatchPin, LOW);
          shiftOut(mdataPin, mclockPin, MSBFIRST, (number_to_display[mins] >> 8 ));
          shiftOut(mdataPin, mclockPin, MSBFIRST, number_to_display[mins]);
	  digitalWrite(mlatchPin, HIGH);
	}
	previousMins = m;
    }

}

All this stuff here

//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.

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 ?

This section of code

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.

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 ?

So the magnet pulling back to the screwhead is not working? That's too bad. Let me do datasheet reading & thinking.

no unfortunately .. i did not work ! .. i ve trying to search in the internet but i couldn't find a good solution. so i hope you can give an idea