Pages: [1] 2   Go Down
Author Topic: Domino Clock  (Read 9456 times)
0 Members and 1 Guest are viewing this topic.
The Hague, Netherlands
Offline Offline
Newbie
*
Karma: 0
Posts: 34
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

So not too long ago I came across this domino clock that was featured on Hackaday. [ http://www.yankodesign.com/2010/12/14/domino-clock/ ] Now I figured that would be cool and I'm trying to figure it all out at once, so I decided to use shift registers to shift leds for the dots. Now I have read the shiftout tutorial a few times but still have some questions.

So if I'm correct for one register the binary value 100000000 will turn on the first pin of the register. But say I have 9 registers, my guess is I'll have a 71 bit value...

And using the internal clock instead of a real time clock. How could I have the time trigger the LEDs.
ie.
while(mins == 09) {
   digitalWrite(..... , HIGH);
}

The only problem with doing this is that i have to write conditions for all 60 minutes and 12 hours. Is there an easier way to do this?

Thanks
Logged

Global Moderator
Boston area, metrowest
Offline Offline
Brattain Member
*****
Karma: 549
Posts: 27418
Author of "Arduino for Teens". Available for Design & Build services. Now with Unlimited Eagle board sizes!
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Do a search for  Stopwatch - this is an ongoing Exhibit project. The logic involved is pretty straightforward.
Logged

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.

The Hague, Netherlands
Offline Offline
Newbie
*
Karma: 0
Posts: 34
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Alright I've done some work on it. Probably my way is way too long but anyways just see if it makes any sense.
Code:
#include <Time.h>

int latchPin = 8;
int clockPin = 12;
int dataPin = 11;

byte dataArrayHour[12];

void setup() {

pinMode(latchPin, OUTPUT);
pinMode(clockPin, OUTPUT);
pinMode(dataPin, OUTPUT);

     //Hour matrix bits
dataArrayHour[1] = 1024 //000000000000010000000000
dataArrayHour[2] = 525312 //000010000000010000000000
dataArrayHour[3] = 540736 //000010000100000001000000
dataArrayHour[4] = 8437824 //100000001100000001000000
dataArrayHour[5] = 8438848 //100000001100010001000000
dataArrayHour[6] = 8963136 //100010001100010001000000
dataArrayHour[7] = 8966464 //100010001101000101000000
dataArrayHour[8] = 10670400 //101000101101000101000000
dataArrayHour[9] = 10671424 //101000101101010101000000
dataArrayHour[10] = 11195712 //101010101101010101000000
dataArrayHour[11] = 11197248 //101010101101101101000000
dataArrayHour[12] = 11983680 //101101101101101101000000


}

void loop() {
  // put your main code here, to run repeatedly:
if (hourFormat12() == 1) {
  digitalWrite(latchPin, LOW);
  shiftOut(dataPin, clockPin, MSBFIRST, dataArrayHour[1]);
  digitalWrite(latchPin, HIGH);
}
else if (hourFormat12() == 2) {
  digitalWrite(latchPin, LOW);
  shiftOut(dataPin, clockPin, MSBFIRST, dataArrayHour[2]);
  digitalWrite(latchPin, HIGH);
}
else if ........


}


You guys think this would work?
Logged

The Hague, Netherlands
Offline Offline
Newbie
*
Karma: 0
Posts: 34
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

So no matter whether it would work or not, I had too much time so finished the code with a little bit of explanation.
I decided to use three shift register arrays so i can independantly change the displays.
The minute part is fairly long smiley
Code:
#include <Time.h>

//shift register array for hour stone
int latchPin1 = 8;
int clockPin1 = 12;
int dataPin1 = 11;

//shift register array for first minute stone
int latchPin2 = 2;
int clockPin2 = 4;
int dataPin2 = 3;

//shift register array for second minute stone
int latchPin3 = 5;
int clockPin3 = 7;
int dataPin3 = 6;

//hour and minute adjust buttons
const int hourPin = 9;
const int minPin = 10;

int hourState = 0;
int minState = 0;

byte dataArray[12];

void setup() {

pinMode(latchPin1, OUTPUT);
pinMode(clockPin1, OUTPUT);
pinMode(dataPin1, OUTPUT);

pinMode(latchPin2, OUTPUT);
pinMode(clockPin2, OUTPUT);
pinMode(dataPin2, OUTPUT);

pinMode(latchPin3, OUTPUT);
pinMode(clockPin3, OUTPUT);
pinMode(dataPin3, OUTPUT);

pinMode(hourPin, INPUT);
pinMode(minPin, INPUT);

     //Matrix bits
dataArray[1] = 1024; //000000000000010000000000
dataArray[2] = 525312; //000010000000010000000000
dataArray[3] = 540736; //000010000100000001000000
dataArray[4] = 8437824; //100000001100000001000000
dataArray[5] = 8438848; //100000001100010001000000
dataArray[6] = 8963136; //100010001100010001000000
dataArray[7] = 8966464; //100010001101000101000000
dataArray[8] = 10670400; //101000101101000101000000
dataArray[9] = 10671424; //101000101101010101000000
dataArray[10] = 11195712; //101010101101010101000000
dataArray[11] = 11197248; //101010101101101101000000
dataArray[12] = 11983680; //101101101101101101000000


}

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);
}
//Hour stone output
if (hourFormat12() == 1) {
  digitalWrite(latchPin1, LOW);
  shiftOut(dataPin1, clockPin1, MSBFIRST, dataArray[1]);
  digitalWrite(latchPin1, HIGH);
}
if (hourFormat12() == 2) {
  digitalWrite(latchPin1, LOW);
  shiftOut(dataPin1, clockPin1, MSBFIRST, dataArray[2]);
  digitalWrite(latchPin1, HIGH);
}
if (hourFormat12() == 3) {
  digitalWrite(latchPin1, LOW);
  shiftOut(dataPin1, clockPin1, MSBFIRST, dataArray[3]);
  digitalWrite(latchPin1, HIGH);
}
if (hourFormat12() == 4) {
  digitalWrite(latchPin1, LOW);
  shiftOut(dataPin1, clockPin1, MSBFIRST, dataArray[4]);
  digitalWrite(latchPin1, HIGH);
}
if (hourFormat12() == 5) {
  digitalWrite(latchPin1, LOW);
  shiftOut(dataPin1, clockPin1, MSBFIRST, dataArray[5]);
  digitalWrite(latchPin1, HIGH);
}
if (hourFormat12() == 6) {
  digitalWrite(latchPin1, LOW);
  shiftOut(dataPin1, clockPin1, MSBFIRST, dataArray[6]);
  digitalWrite(latchPin1, HIGH);
}
if (hourFormat12() == 7) {
  digitalWrite(latchPin1, LOW);
  shiftOut(dataPin1, clockPin1, MSBFIRST, dataArray[7]);
  digitalWrite(latchPin1, HIGH);
}
if (hourFormat12() == 8) {
  digitalWrite(latchPin1, LOW);
  shiftOut(dataPin1, clockPin1, MSBFIRST, dataArray[8]);
  digitalWrite(latchPin1, HIGH);
}
if (hourFormat12() == 9) {
  digitalWrite(latchPin1, LOW);
  shiftOut(dataPin1, clockPin1, MSBFIRST, dataArray[9]);
  digitalWrite(latchPin1, HIGH);
}
if (hourFormat12() == 10) {
  digitalWrite(latchPin1, LOW);
  shiftOut(dataPin1, clockPin1, MSBFIRST, dataArray[10]);
  digitalWrite(latchPin1, HIGH);
}
if (hourFormat12() == 11) {
  digitalWrite(latchPin1, LOW);
  shiftOut(dataPin1, clockPin1, MSBFIRST, dataArray[11]);
  digitalWrite(latchPin1, HIGH);
}
if (hourFormat12() == 12) {
  digitalWrite(latchPin1, LOW);
  shiftOut(dataPin1, clockPin1, MSBFIRST, dataArray[12]);
  digitalWrite(latchPin1, HIGH);
}
//Minute stones output
if (minute() == 0) {
  digitalWrite(latchPin2, LOW);
  digitalWrite(latchPin3, LOW);
  shiftOut(dataPin2, clockPin2, MSBFIRST, 0);
  shiftOut(dataPin3, clockPin3, MSBFIRST, 0);
  digitalWrite(latchPin2, HIGH);
  digitalWrite(latchPin3, HIGH);
}
if (minute() == 1) {
  digitalWrite(latchPin2, LOW);
  digitalWrite(latchPin3, LOW);
  shiftOut(dataPin2, clockPin2, MSBFIRST, 0);
  shiftOut(dataPin3, clockPin3, MSBFIRST, dataArray[1]);
  digitalWrite(latchPin2, HIGH);
  digitalWrite(latchPin3, HIGH);
}
if (minute() == 2) {
  digitalWrite(latchPin2, LOW);
  digitalWrite(latchPin3, LOW);
  shiftOut(dataPin2, clockPin2, MSBFIRST, 0);
  shiftOut(dataPin3, clockPin3, MSBFIRST, dataArray[2]);
  digitalWrite(latchPin2, HIGH);
  digitalWrite(latchPin3, HIGH);
}
if (minute() == 3) {
  digitalWrite(latchPin2, LOW);
  digitalWrite(latchPin3, LOW);
  shiftOut(dataPin2, clockPin2, MSBFIRST, 0);
  shiftOut(dataPin3, clockPin3, MSBFIRST, dataArray[3]);
  digitalWrite(latchPin2, HIGH);
  digitalWrite(latchPin3, HIGH);
}
if (minute() == 4) {
  digitalWrite(latchPin2, LOW);
  digitalWrite(latchPin3, LOW);
  shiftOut(dataPin2, clockPin2, MSBFIRST, 0);
  shiftOut(dataPin3, clockPin3, MSBFIRST, dataArray[4]);
  digitalWrite(latchPin2, HIGH);
  digitalWrite(latchPin3, HIGH);
}
if (minute() == 5) {
  digitalWrite(latchPin2, LOW);
  digitalWrite(latchPin3, LOW);
  shiftOut(dataPin2, clockPin2, MSBFIRST, 0);
  shiftOut(dataPin3, clockPin3, MSBFIRST, dataArray[5]);
  digitalWrite(latchPin2, HIGH);
  digitalWrite(latchPin3, HIGH);
}
if (minute() == 6) {
  digitalWrite(latchPin2, LOW);
  digitalWrite(latchPin3, LOW);
  shiftOut(dataPin2, clockPin2, MSBFIRST, 0);
  shiftOut(dataPin3, clockPin3, MSBFIRST, dataArray[6]);
  digitalWrite(latchPin2, HIGH);
  digitalWrite(latchPin3, HIGH);
}
if (minute() == 7) {
  digitalWrite(latchPin2, LOW);
  digitalWrite(latchPin3, LOW);
  shiftOut(dataPin2, clockPin2, MSBFIRST, 0);
  shiftOut(dataPin3, clockPin3, MSBFIRST, dataArray[7]);
  digitalWrite(latchPin2, HIGH);
  digitalWrite(latchPin3, HIGH);
}
if (minute() == 8) {
  digitalWrite(latchPin2, LOW);
  digitalWrite(latchPin3, LOW);
  shiftOut(dataPin2, clockPin2, MSBFIRST, 0);
  shiftOut(dataPin3, clockPin3, MSBFIRST, dataArray[8]);
  digitalWrite(latchPin2, HIGH);
  digitalWrite(latchPin3, HIGH);
}
if (minute() == 9) {
  digitalWrite(latchPin2, LOW);
  digitalWrite(latchPin3, LOW);
  shiftOut(dataPin2, clockPin2, MSBFIRST, 0);
  shiftOut(dataPin3, clockPin3, MSBFIRST, dataArray[9]);
  digitalWrite(latchPin2, HIGH);
  digitalWrite(latchPin3, HIGH);
}
if (minute() == 10) {
  digitalWrite(latchPin2, LOW);
  digitalWrite(latchPin3, LOW);
  shiftOut(dataPin2, clockPin2, MSBFIRST, dataArray[1]);
  shiftOut(dataPin3, clockPin3, MSBFIRST, 0);
  digitalWrite(latchPin2, HIGH);
  digitalWrite(latchPin3, HIGH);
}
if (minute() == 11) {
  digitalWrite(latchPin2, LOW);
  digitalWrite(latchPin3, LOW);
  shiftOut(dataPin2, clockPin2, MSBFIRST, dataArray[1]);
  shiftOut(dataPin3, clockPin3, MSBFIRST, dataArray[1]);
  digitalWrite(latchPin2, HIGH);
  digitalWrite(latchPin3, HIGH);
}
if (minute() == 12) {
  digitalWrite(latchPin2, LOW);
  digitalWrite(latchPin3, LOW);
  shiftOut(dataPin2, clockPin2, MSBFIRST, dataArray[1]);
  shiftOut(dataPin3, clockPin3, MSBFIRST, dataArray[2]);
  digitalWrite(latchPin2, HIGH);
  digitalWrite(latchPin3, HIGH);
}
if (minute() == 13) {
  digitalWrite(latchPin2, LOW);
  digitalWrite(latchPin3, LOW);
  shiftOut(dataPin2, clockPin2, MSBFIRST, dataArray[1]);
  shiftOut(dataPin3, clockPin3, MSBFIRST, dataArray[3]);
  digitalWrite(latchPin2, HIGH);
  digitalWrite(latchPin3, HIGH);
}
if (minute() == 14) {
  digitalWrite(latchPin2, LOW);
  digitalWrite(latchPin3, LOW);
  shiftOut(dataPin2, clockPin2, MSBFIRST, dataArray[1]);
  shiftOut(dataPin3, clockPin3, MSBFIRST, dataArray[4]);
  digitalWrite(latchPin2, HIGH);
  digitalWrite(latchPin3, HIGH);
}
if (minute() == 15) {
  digitalWrite(latchPin2, LOW);
  digitalWrite(latchPin3, LOW);
  shiftOut(dataPin2, clockPin2, MSBFIRST, dataArray[1]);
  shiftOut(dataPin3, clockPin3, MSBFIRST, dataArray[5]);
  digitalWrite(latchPin2, HIGH);
  digitalWrite(latchPin3, HIGH);
}
if (minute() == 16) {
  digitalWrite(latchPin2, LOW);
  digitalWrite(latchPin3, LOW);
  shiftOut(dataPin2, clockPin2, MSBFIRST, dataArray[1]);
  shiftOut(dataPin3, clockPin3, MSBFIRST, dataArray[6]);
  digitalWrite(latchPin2, HIGH);
  digitalWrite(latchPin3, HIGH);
}
if (minute() == 17) {
  digitalWrite(latchPin2, LOW);
  digitalWrite(latchPin3, LOW);
  shiftOut(dataPin2, clockPin2, MSBFIRST, dataArray[1]);
  shiftOut(dataPin3, clockPin3, MSBFIRST, dataArray[7]);
  digitalWrite(latchPin2, HIGH);
  digitalWrite(latchPin3, HIGH);
}
if (minute() == 18) {
  digitalWrite(latchPin2, LOW);
  digitalWrite(latchPin3, LOW);
  shiftOut(dataPin2, clockPin2, MSBFIRST, dataArray[1]);
  shiftOut(dataPin3, clockPin3, MSBFIRST, dataArray[8]);
  digitalWrite(latchPin2, HIGH);
  digitalWrite(latchPin3, HIGH);
}
if (minute() == 19) {
  digitalWrite(latchPin2, LOW);
  digitalWrite(latchPin3, LOW);
  shiftOut(dataPin2, clockPin2, MSBFIRST, dataArray[1]);
  shiftOut(dataPin3, clockPin3, MSBFIRST, dataArray[9]);
  digitalWrite(latchPin2, HIGH);
  digitalWrite(latchPin3, HIGH);
}
if (minute() == 20) {
  digitalWrite(latchPin2, LOW);
  digitalWrite(latchPin3, LOW);
  shiftOut(dataPin2, clockPin2, MSBFIRST, dataArray[2]);
  shiftOut(dataPin3, clockPin3, MSBFIRST, 0);
  digitalWrite(latchPin2, HIGH);
  digitalWrite(latchPin3, HIGH);
}
 etc...
Logged

Global Moderator
Boston area, metrowest
Offline Offline
Brattain Member
*****
Karma: 549
Posts: 27418
Author of "Arduino for Teens". Available for Design & Build services. Now with Unlimited Eagle board sizes!
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

You need some code like this to keep track of the hours & minutes gone by
Code:
 // when started flag is pressed, start counting in 10mS increments
  if (started == 1){
    currentmicros = micros();  // read the time.
    elapsedmicros = currentmicros - previousmicros;

    if (elapsedmicros >= interval) // 10 milliseconds have gone by
    {
      previousmicros  = previousmicros + elapsedmicros;  // save the time for the next comparison
      time_update = 1; // set flag to shift out the new time
    }

    if (time_update == 1){  // no updating if not at 10ms interval, skip this whole section
      // increment the counters, roll as needed, shift the digits out

      time_update = 0; // reset for next pass thru

      hundredths = hundredths +1;

      if (hundredths == 10){
        hundredths = 0;
        tenths = tenths +1;
      }

      if (tenths == 10){
        tenths = 0;
          ones_seconds = ones_seconds +1;
      }

          if (ones_seconds == 10){
      ones_seconds = 0;
        hundredths = hundredths +3;   // Speed up the clock!
        tens_seconds = tens_seconds +1;
    }

            if (tens_seconds == 6){
       tens_seconds = 0;
         hundredths = hundredths +6;   // Speed up the clock!
         ones_minutes = ones_minutes +1;
    }

      if (ones_minutes == 10){
        ones_minutes = 0;
        tens_minutes = tens_minutes +1;
      }
      if (tens_minutes == 6){
        tens_minutes = 0;
        ones_hours = ones_hours +1;  // not used in actual application, only here for stability test over longer time periods
      }
      if (ones_hours == 13){  // not used in actual application, only here for stability test over longer time periods
        ones_hours = 0;
        tens_hours = tens_hours +1;
      }
      if (paused == 0){
        // not paused, update the display

        // counters are all updated now, just do the shiftout one time here:
        digitalWrite(latchpin, LOW); // send the digits down to the shift registers!
        shiftOut(datapin, clockpin, MSBFIRST, segdisp[hundredths]); // print the hundredths digit
        shiftOut(datapin, clockpin, MSBFIRST, segdisp[tenths]);     // print the tenths digit
        shiftOut(datapin, clockpin, MSBFIRST, segdisp[ones_seconds]); // print the lower seconds digit
        shiftOut(datapin, clockpin, MSBFIRST, segdisp[tens_seconds]); // print the upper seconds digit
        shiftOut(datapin, clockpin, MSBFIRST, segdisp[ones_minutes]); // print the lower sinutes digit
        shiftOut(datapin, clockpin, MSBFIRST, segdisp[tens_minutes]); // print the upper minutes digit
        digitalWrite(latchpin, HIGH);
        if (tenths == 0 && hundredths == 0){ // update on screen once a second
          
        }  // end of 1 second check
      } // end of time update is not paused
    }  // end if time to be updated

Logged

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.

Global Moderator
Boston area, metrowest
Offline Offline
Brattain Member
*****
Karma: 549
Posts: 27418
Author of "Arduino for Teens". Available for Design & Build services. Now with Unlimited Eagle board sizes!
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Ok, looks like we posted at similar times and you have something similar worked out already.
Logged

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.

The Hague, Netherlands
Offline Offline
Newbie
*
Karma: 0
Posts: 34
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hehe alright.

But you think that my method of shifting out data works?

I have ordered all of the electronics parts so I'll be posting updates as I go along.

Oh does anyone have experience with the Time library? I based my code on the readme but am not sure if it's all correct.
Logged

Global Moderator
Boston area, metrowest
Offline Offline
Brattain Member
*****
Karma: 549
Posts: 27418
Author of "Arduino for Teens". Available for Design & Build services. Now with Unlimited Eagle board sizes!
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

No, the shifting out probable needs some adjusting.
Shiftout sends out one byte of data one bit at a time. If you are sending 3 bytes,
10110110 11011011 01000000  data array 12 for example you will need three shiftout commands

Modifying the shiftout example from 2 bytes to 3 would yield something like this:
Code:
// Do this for MSBFIRST serial
// replace 'data' with you array definition
// shift out highbyte
shiftOut(dataPin, clock, MSBFIRST, (data >> 8));  
// shift out middlebyte
shiftOut(data, clock, MSBFIRST, (data>>8));
// shift out lowbyte
shiftOut(data, clock, MSBFIRST, data8);

This part is reading some buttons? You will need some debounce to keep from getting multiple presses:
Code:
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);
}

Why not simply the code for writing out the display? You are only updating once a minute and once an hour, right?
So keep track of when the minute changes or when the hour changes and then send out an update.
It looks like
if (hourFormat12() == 11)
&
if (minute() == 0)
do the time tracking for you.
Just sit in a loop, and when you detect a difference, then do the shiftout commands
Code:
ex. old_hours = 0;
old_minutes = 0;
new_hours = hourformat12();
new_minutes = minute();
if (new_hours != old_hours) {
// send out new hours
hours = dataArray[new_hours]
   digitalWrite(latchPin1, LOW);
  shiftOut(dataPin1, clockPin1, MSBFIRST, hours);
  digitalWrite(latchPin1, HIGH);
old_hours = new_hours;
}
if (new_minutes != old_minutes){
// do your math here to break up into tens_minutes & ones_minutes
//example
// high_digit = 0
// if (new_minutes <10) {high_digit = 0;  low_digit = new_minutes;}  // minutes is from 00 to 09
// while (new_minutes >=10 { // loop thru as needed and lop off 10 minutes at a time,
//     high_digit = high_digit+1;  // updating the high_digit for every 10 minutes
//     new_minutes = new_minutes -10;}
//     low_digit = new_minutes;  // when less than 10 is left, the balance is the low digit
//     }
//

tens_minutes = dataArray[high_digit];
ones_minutes = dataArray[low_digit];
  digitalWrite(latchPin2, LOW);
  digitalWrite(latchPin3, LOW);
  shiftOut(dataPin2, clockPin2, MSBFIRST, tens_minutes);
  shiftOut(dataPin3, clockPin3, MSBFIRST, one_minutes);
  digitalWrite(latchPin2, HIGH);
  digitalWrite(latchPin3, HIGH);
old_minutes = new_minutes;
}
« Last Edit: January 17, 2011, 11:25:44 am by CrossRoads » Logged

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.

The Hague, Netherlands
Offline Offline
Newbie
*
Karma: 0
Posts: 34
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Cool I'll start adjusting the shiftout first and use that with the original code and as soon as thats working then ill try to implement some math to it.
Although it surprised me that the difference between shifting out the first and second byte is only a space.

shiftOut(dataPin, clock, MSBFIRST, (data[glow] [/glow]>>[glow] [/glow]smiley-cool);  

shiftOut(data, clock, MSBFIRST, (data>>smiley-cool);
Logged

Global Moderator
Boston area, metrowest
Offline Offline
Brattain Member
*****
Karma: 549
Posts: 27418
Author of "Arduino for Teens". Available for Design & Build services. Now with Unlimited Eagle board sizes!
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

The spaces are ignored during compiling.
The " >>8" indicate the data is shifted by 8 places.
Might even need to be 16, then 8, then none.
Logged

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.

The Hague, Netherlands
Offline Offline
Newbie
*
Karma: 0
Posts: 34
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

So I got all the parts in and started on the boards for the shift registers.
The first one is a bit of a mess as i designed the layout on the go.


And two more of these


So I have my main board in the middle stone together with the arduino and through the 5 pin sockets it sends the clock, latch, data and power the the other two.
I should get started on the housing this weekend so more to come.
Logged

Global Moderator
Boston area, metrowest
Offline Offline
Brattain Member
*****
Karma: 549
Posts: 27418
Author of "Arduino for Teens". Available for Design & Build services. Now with Unlimited Eagle board sizes!
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Interesting looking board, where is that from?
Logged

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.

The Hague, Netherlands
Offline Offline
Newbie
*
Karma: 0
Posts: 34
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Im from Holland and the easiest place to get everything is a place called Conrad. Bit over priced but they have most things you need. Heres a link to it, it's called a euro processor circuit board:
http://www2.conrad-uk.com/goto.php?artikel=527831
Logged

Global Moderator
Boston area, metrowest
Offline Offline
Brattain Member
*****
Karma: 549
Posts: 27418
Author of "Arduino for Teens". Available for Design & Build services. Now with Unlimited Eagle board sizes!
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

You should update your profile to show that, there are others from Holland who could provide local help if needed, or suggest sources, etc. Must be like 2:30 AM there? While for me is just 8:30PM on a chilly winter night (and colder tomorrow, -7F tomorrow night!).
Logged

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.

The Hague, Netherlands
Offline Offline
Newbie
*
Karma: 0
Posts: 34
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

For another update:
Turns out it actually works smiley
Used a very simple bit of code to just blink pin 1 on the register.
Which actually blinks pin 1 on all three registers.
Code:
   digitalWrite(latchPin, LOW);
    delay(500);  
    shiftOut(dataPin, clockPin, MSBFIRST, 2);  
    digitalWrite(latchPin, HIGH);
    delay(500);
    digitalWrite(latchPin, LOW);
    delay(500);
    shiftOut(dataPin, clockPin, MSBFIRST, 0);
    digitalWrite(latchPin, HIGH);

So step 1 is done.
Just step 2 of controlling the registers seperately still baffles me.
If I shift them:     shiftOut(dataPin, clockPin, MSBFIRST, (2 >> smiley-cool);
Nothing happens to pin 1 of the second shift register.

Hehe to be honest it is starting to piss me off because it can't be that hard right??
Anyone any tips??
Logged

Pages: [1] 2   Go Up
Jump to: