Go Down

Topic: How to change configuration ARDUINO (Read 4495 times) previous topic - next topic

ArtFunk

I realized this project, using an Arduino, and three shift register 74HC595.
I would do it again, making a purifying functions, which requires' adding fourth 74HC595 chip
In this link, you can see the project that I've made??:
http://www.youtube.com/watch?v=kNO6NaJj0Ic
while in that you can see how the original http://www.youtube.com/watch?v=j3YRT39eQuw
Basically I must add, in the lower part near the chin, 4 rows of LED, which will do exactly the sequence of the original, but will ignite scanned. My problem is this, besides not being an expert on everything, I know absolutely nothing about programming dell'arduino, the configuration of the project I've done, they passed me. I have tried to make changes to the examples that are downloaded from the download section of the site, and they work, but the configuration of this project is completely different, and I do not know where to put ever.
I did a test with berdboard, and only adding the fourth chip is connected to eight LEDs, everything works strangely, for the 8 LEDs are added to the same sequence of eight of the first chip, and I want to change this sequence only for the last eight LEDs, which will then file LEDs.
http://www.youtube.com/watch?v=kTMBjib7dO0
The first LED on the right, correspond with the colored bars on the helmet, the central red rectangular LED, white LEDs correspond to the horizontal walking back and forth, the third block, are part of the chin and ears.
This is the base as I realized: http://www.flickr.com/photos/artfunkart/5655090245/in/set-72157624133201215
Someone can help me?

Grumpy_Mike

Quote
I want to change this sequence only for the last eight LEDs, which will then file LEDs.

So you send everything again as before but make the last 8 bits different. That is how you do it with a chain.

Otherwise wire up the extra shift register with its own clock, data and enable/shift pin.

ArtFunk

#2
Jul 29, 2011, 11:11 pm Last Edit: Jul 30, 2011, 10:20 pm by ArtFunk Reason: 1
The problem is that the configuration is Arabic for me is not as classic examples that you download, look.


Code: [Select]
//**************************************************************//
//  Name    : Guy Manual Daft Punk Helmet LED controller        //
//  Author  : James Moss (jamesmoss.co.uk)                      //
//  Date    : 23 September 2009                                 //
//  Version : 1.0                                               //
//  Notes   : Developed for Volpin (volpinprops.blogspot.com)   //
//          : Controls the flashing / animated leds in          //
//          : a Daft Punk replica helmet                        //
//****************************************************************/

#include "Potentiometer.h"
#include "Math.h"
//#include "Rainbow.h" // Rainbowduinio libraries, dont include these if using arduino

/* -- PIN DEFINITIONS ----------------------------------------- */

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

// Inputs
int modePotPin = 1;
int speedPotPin = 2;
int lineInPin = 3;

/* -- PROGRAM CONFIG ----------------------------------------- */

// Tweak these values to suit your preference
unsigned int earSpeed = 300; // Time in milliseconds between ear LED animation frames
unsigned int earPause = 4; // Amount of frames to wait before running the ear animation again (max 250)
unsigned int cheekSpeed = 300; // Time in milliseconds between cheek LED (white LEDs) animation frames
unsigned int chinSpeed = 500; // Time in milliseconds between chin LED (red/green/yellow LEDs) animation frames

/* -- PROGRAM VARIABLES ----------------------------------------- */

// dont edit these
unsigned int barSpeed = 100; // Time in milliseconds between bar LED animation frames
unsigned char earFrame = 1;
int barFrame = 0;
unsigned char barAnimation = 1;
char cheekFrame = 0;
byte earBuffer = 0;
byte cheekBuffer = 0;
byte barBuffer = 0;
byte chinBuffer = 0;
unsigned long lastEarFrame = 0;
unsigned long lastCheekFrame = 0;
unsigned long lastBarFrame = 0;
unsigned long lastChinFrame = 0;

// pots
Potentiometer modePot = Potentiometer(modePotPin);
Potentiometer speedPot = Potentiometer(speedPotPin);

unsigned char NumTab[9]=
{
 B00000000,
 B00000001,
 B00000010,
 B00000100,
 B00001000,
 B00010000,
 B00100000,
 B01000000,
 B10000000
};

// Called when the arduino loads
void setup()
{
 // Rainbowduino code, comment out if using arduino
 //_init();
 
 randomSeed(analogRead(0)); // Initalise the random number generator with noise on pin 1

 // set the pin modes
 pinMode(latchPin, OUTPUT);
 pinMode(clockPin, OUTPUT);
 pinMode(dataPin, OUTPUT);
 
  // init the pots
 modePot.setSectors(10);
 speedPot.setSectors(100);
}

void loop()
{
 checkInputs();
 
 unsigned long currentTime = millis();
 
 // check to see if its time to animate the ear  
 if(currentTime > (lastEarFrame+earSpeed))
 {
   animateEar();
   lastEarFrame = currentTime;
 }
 
 // check to see if its time to animate the cheek  
 if(currentTime > (lastCheekFrame+cheekSpeed))
 {
   animateCheek();
   lastCheekFrame = currentTime;
 }
 
 // check to see if its time to animate the coloured bars  
 if(currentTime > (lastBarFrame+barSpeed))
 {
   animateBars();
   lastBarFrame = currentTime;
 }
 
 // check to see if its time to animate the chin leds  
 if(currentTime > (lastChinFrame+chinSpeed))
 {
   animateChin();
   lastChinFrame = currentTime;
 }
 
 // temporary buffer which ear, jack and chin LEDs get merged into
 byte tempBuffer = B00000000;
 tempBuffer |= earBuffer;
 tempBuffer |= B00001000; // jack LEDs, these are always on
 tempBuffer |= chinBuffer << 4; // shift the chinBuffer left 4 bits
 
 
 // If the animations are being sent to the incorrect shift register try
 // moving the calls to the shiftOut() function around.
 // If the animations are coming out back to front change LSBFIRST to MSBFIRST
 // this tells the shiftOut function which order to send the bits, right to
 // left (LSB) or left to right (MSB)
 digitalWrite(latchPin, LOW);
 shiftOutTest(dataPin, clockPin, tempBuffer);
 shiftOutTest(dataPin, clockPin, cheekBuffer);
 shiftOutTest(dataPin, clockPin, barBuffer);  
 digitalWrite(latchPin, HIGH);
 
 
 // Rainbowduino code, comment out if using with arduino
// shift_24_bit(/*earBuffer*/0, tempBuffer, cheekBuffer); //RGB
 
 delay(5);
}

void checkInputs()
{
 // this creates a logarithmic curve so that its easier to
 // adjust the faster speeds
 short int pot = speedPot.getSector();
 barSpeed = ceil(pow(pot, 3)*0.001);
 
 
 // check mode
 static char lastMode = 0;
 unsigned char p = modePot.getSector();
 if(lastMode != p)
 {
   // change mode
   barFrame = 0;
   barAnimation = p;
   lastMode = p;
 }
}

/* -- EAR ANIMATIONS ----------------------------------------- */

void animateEar()
{
   
 switch(earFrame)
 {
   case 1:
     earBuffer = B00000100;
     break;
   case 2:
     earBuffer = B00000110;
     break;
   case 3:
     earBuffer = B00000010;
     break;  
   case 4:
     earBuffer = B00000011;
     break;
   case 5:
     earBuffer = B00000001;
     break;
   default:
     earBuffer = B00000000;
     if(earFrame-5 > earPause) // 5 is the number of frames in the animation
     {
       earFrame = 0;
     }
     break;    
 }

 
earFrame++;
}

/* -- CHEEK ANIMATIONS -------------------------------------- */

void animateCheek()
{
 cheekBuffer = B00000000;
 cheekBuffer |= NumTab[abs(cheekFrame-7)+1];
 cheekFrame++;
 
 if(cheekFrame > 13)
 {
   cheekFrame = 0;
 }
}

/* -- BAR ANIMATIONS ----------------------------------------- */

void animateBars()
{
 barBuffer = B00000000;
 
 switch(barAnimation)
 {
   case 1: singleChaser();       break;
   case 2: multiChaser();        break;
   case 3: bounce();             break;
   case 4: growOutwards();       break;
   case 5: growInwards();        break;
   case 6: simpleStrobe();       break;
   case 7: singleRandomStrobe(); break;
   case 8: multiRandomStrobe();  break;
   case 9: allBarsOn();          break;
   case 10: vuMeter();           break;
   
   // just in case the pot breaks :)
   default: singleChaser();      break;  
 }

}


ArtFunk

#3
Jul 29, 2011, 11:11 pm Last Edit: Jul 30, 2011, 10:20 pm by ArtFunk Reason: 1
Code: [Select]
/* -- CHIN ANIMATIONS ----------------------------------------- */

void animateChin()
{
 static char chinFrame = 0;
 
 chinBuffer = B00000000;
 
 char i;
 for(i = 1; i <= 4; i++)
 {
   if(random(0, 4) == 0)
   {
     chinBuffer |= NumTab[i];
   }
 }
 
 if(chinFrame > 4)
 {
   chinFrame = 0;
 }
}

/* ---------------------------------------------------------------
   turnOnBar(int pinNum)
   Takes a integer between 1 and 8 and turns the corresponding
   bar on.
---------------------------------------------------------------- */

void turnOnBar(int pinNum)
{
 if(pinNum >= 1 && pinNum <= 8)
 {
   barBuffer |= NumTab[pinNum];
 }
}

/* ---------------------------------------------------------------
   The following functions are the different animations
   for the bars,
---------------------------------------------------------------- */
 
 

/* -- 1: SINGLE CHASER ----------------------------------------- */

void singleChaser()
{
 barFrame++;
 
  if(barFrame > 8)
  {
    barFrame = 1;
  }
 
 turnOnBar(barFrame);
}

/* -- 2: MULTI CHASER ----------------------------------------- */

void multiChaser()
{
 barFrame++;

  if(barFrame > 11)
  {
    barFrame = 1;
  }
 
 
 turnOnBar(barFrame);
 turnOnBar(barFrame - 1);
 turnOnBar(barFrame - 2);

}

/* -- 3: BOUNCE ----------------------------------------- */

void bounce()
{
 char position = abs(barFrame-7)+1;
 barFrame++;
 if(barFrame > 13)
 {
   barFrame = 0;
 }
 
 turnOnBar(position);

}

/* -- 4: GROW OUTWARDS ----------------------------------------- */

void growOutwards()
{
 barFrame++;
 
 if(barFrame > 5)
 {
   barFrame = 1;
 }  
 char pos = barFrame - 2;
 char i;
   
 for(i = (4-pos); i <= 4; i++)
 {
   turnOnBar(i);
   turnOnBar(9-i);
 }    
}

/* -- 5: GROW INWARDS ----------------------------------------- */

void growInwards()
{
 barFrame++;
 
 if(barFrame > 5)
 {
   barFrame = 1;
 }
 
 char pos = barFrame - 1;
 char i;
   
 for(i = 1; i <= pos; i++)
 {
     turnOnBar(i);
     turnOnBar(9-i);
 }    
}

/* -- 6: SIMPLE STROBE --------------------------------------- */

void simpleStrobe()
{
 if(barFrame == 0)
 {  
   barBuffer = B11111111;
   barFrame = 1;
 }
 else
 {
   barFrame = 0;
 }

}

/* -- 7: SINGLE RANDOM STROBE ----------------------------------------- */

void singleRandomStrobe()
{
 turnOnBar(random(1, 9));
}

/* -- 8: MULTI RANDOM STROBE ----------------------------------------- */

void multiRandomStrobe()
{
 int randNum = random(0, 4);
 int i = 0;
 
 for(i = 0; i <= randNum; i++)
 {
   turnOnBar(random(1, 9));
 }
}

/* -- 9: ALL BARS ON ----------------------------------------- */

void allBarsOn()
{
 int i;
 
 // loop through the bars and turn them all on
 for(i = 1; i <= 8; i++)
 {
   turnOnBar(i);
 }
}

/* -- 10: VU Meter ----------------------------------------- */

void vuMeter()
{
 char volume =  round(analogRead(lineInPin)/128);
 
 char i;
 for(i = 1; i <= volume; i++)
 {
   turnOnBar(i);
 }
}

void shiftOutTest(int myDataPin, int myClockPin, byte myDataOut) {
 // This shifts 8 bits out MSB first,
 //on the rising edge of the clock,
 //clock idles low

 //internal function setup
 int i=0;
 int pinState;
 pinMode(myClockPin, OUTPUT);
 pinMode(myDataPin, OUTPUT);

 //clear everything out just in case to
 //prepare shift register for bit shifting
 digitalWrite(myDataPin, 0);
 digitalWrite(myClockPin, 0);

 //for each bit in the byte myDataOut?
 //NOTICE THAT WE ARE COUNTING DOWN in our for loop
 //This means that %00000001 or "1" will go through such
 //that it will be pin Q0 that lights.
 for (i=7; i>=0; i--)  {
   digitalWrite(myClockPin, 0);

   //if the value passed to myDataOut and a bitmask result
   // true then... so if we are at i=6 and our value is
   // %11010100 it would the code compares it to %01000000
   // and proceeds to set pinState to 1.
   if ( myDataOut & (1<<i) ) {
     pinState= 1;
   }
   else {
     pinState= 0;
   }

   //Sets the pin to HIGH or LOW depending on pinState
   digitalWrite(myDataPin, pinState);
   //register shifts bits on upstroke of clock pin  
   digitalWrite(myClockPin, 1);
   //zero the data pin after shift to prevent bleed through
   digitalWrite(myDataPin, 0);
 }

 //stop shifting
 digitalWrite(myClockPin, 0);
}

Grumpy_Mike

Please modify that post so the code is in a code box. Select it and hit the # icon.

This bit does the shifting out:-
Code: [Select]
digitalWrite(latchPin, LOW);
  shiftOutTest(dataPin, clockPin, tempBuffer);
  shiftOutTest(dataPin, clockPin, cheekBuffer);
  shiftOutTest(dataPin, clockPin, barBuffer); 
  digitalWrite(latchPin, HIGH);


If you add another shift register then add another:-
shiftOutTest(dataPin, clockPin, newBuffer);

Quote
The problem is that the configuration is Arabic for me

You will have to learn how to code if you want to do something unique.

ArtFunk

Code: [Select]
//**************************************************************//
//  Name    : Guy Manual Daft Punk Helmet LED controller        //
//  Author  : James Moss (jamesmoss.co.uk)                      //
//  Date    : 23 September 2009                                 //
//  Version : 1.0                                               //
//  Notes   : Developed for Volpin (volpinprops.blogspot.com)   //
//          : Controls the flashing / animated leds in          //
//          : a Daft Punk replica helmet                        //
//****************************************************************/

#include "Potentiometer.h"
#include "Math.h"
//#include "Rainbow.h" // Rainbowduinio libraries, dont include these if using arduino

/* -- PIN DEFINITIONS ----------------------------------------- */

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

// Inputs
int modePotPin = 1;
int speedPotPin = 2;
int lineInPin = 3;

/* -- PROGRAM CONFIG ----------------------------------------- */

// Tweak these values to suit your preference
unsigned int earSpeed = 300; // Time in milliseconds between ear LED animation frames
unsigned int earPause = 4; // Amount of frames to wait before running the ear animation again (max 250)
unsigned int cheekSpeed = 300; // Time in milliseconds between cheek LED (white LEDs) animation frames
unsigned int chinSpeed = 500; // Time in milliseconds between chin LED (red/green/yellow LEDs) animation frames

/* -- PROGRAM VARIABLES ----------------------------------------- */

// dont edit these
unsigned int barSpeed = 100; // Time in milliseconds between bar LED animation frames
unsigned char earFrame = 1;
int barFrame = 0;
unsigned char barAnimation = 1;
char cheekFrame = 0;
byte earBuffer = 0;
byte cheekBuffer = 0;
byte barBuffer = 0;
byte chinBuffer = 0;
unsigned long lastEarFrame = 0;
unsigned long lastCheekFrame = 0;
unsigned long lastBarFrame = 0;
unsigned long lastChinFrame = 0;

// pots
Potentiometer modePot = Potentiometer(modePotPin);
Potentiometer speedPot = Potentiometer(speedPotPin);

unsigned char NumTab[9]=
{
 B00000000,
 B00000001,
 B00000010,
 B00000100,
 B00001000,
 B00010000,
 B00100000,
 B01000000,
 B10000000
};

// Called when the arduino loads
void setup()
{
 // Rainbowduino code, comment out if using arduino
 //_init();
 
 randomSeed(analogRead(0)); // Initalise the random number generator with noise on pin 1

 // set the pin modes
 pinMode(latchPin, OUTPUT);
 pinMode(clockPin, OUTPUT);
 pinMode(dataPin, OUTPUT);
 
  // init the pots
 modePot.setSectors(10);
 speedPot.setSectors(100);
}

void loop()
{
 checkInputs();
 
 unsigned long currentTime = millis();
 
 // check to see if its time to animate the ear  
 if(currentTime > (lastEarFrame+earSpeed))
 {
   animateEar();
   lastEarFrame = currentTime;
 }
 
 // check to see if its time to animate the cheek  
 if(currentTime > (lastCheekFrame+cheekSpeed))
 {
   animateCheek();
   lastCheekFrame = currentTime;
 }
 
 // check to see if its time to animate the coloured bars  
 if(currentTime > (lastBarFrame+barSpeed))
 {
   animateBars();
   lastBarFrame = currentTime;
 }
 
 // check to see if its time to animate the chin leds  
 if(currentTime > (lastChinFrame+chinSpeed))
 {
   animateChin();
   lastChinFrame = currentTime;
 }
 
 // temporary buffer which ear, jack and chin LEDs get merged into
 byte tempBuffer = B00000000;
 tempBuffer |= earBuffer;
 tempBuffer |= B00001000; // jack LEDs, these are always on
 tempBuffer |= chinBuffer << 4; // shift the chinBuffer left 4 bits
 
 
 // If the animations are being sent to the incorrect shift register try
 // moving the calls to the shiftOut() function around.
 // If the animations are coming out back to front change LSBFIRST to MSBFIRST
 // this tells the shiftOut function which order to send the bits, right to
 // left (LSB) or left to right (MSB)
 digitalWrite(latchPin, LOW);
 shiftOutTest(dataPin, clockPin, tempBuffer);
 shiftOutTest(dataPin, clockPin, cheekBuffer);
 shiftOutTest(dataPin, clockPin, barBuffer);  
 digitalWrite(latchPin, HIGH);
 
 
 // Rainbowduino code, comment out if using with arduino
// shift_24_bit(/*earBuffer*/0, tempBuffer, cheekBuffer); //RGB
 
 delay(5);
}

void checkInputs()
{
 // this creates a logarithmic curve so that its easier to
 // adjust the faster speeds
 short int pot = speedPot.getSector();
 barSpeed = ceil(pow(pot, 3)*0.001);
 
 
 // check mode
 static char lastMode = 0;
 unsigned char p = modePot.getSector();
 if(lastMode != p)
 {
   // change mode
   barFrame = 0;
   barAnimation = p;
   lastMode = p;
 }
}

/* -- EAR ANIMATIONS ----------------------------------------- */

void animateEar()
{
   
 switch(earFrame)
 {
   case 1:
     earBuffer = B00000100;
     break;
   case 2:
     earBuffer = B00000110;
     break;
   case 3:
     earBuffer = B00000010;
     break;  
   case 4:
     earBuffer = B00000011;
     break;
   case 5:
     earBuffer = B00000001;
     break;
   default:
     earBuffer = B00000000;
     if(earFrame-5 > earPause) // 5 is the number of frames in the animation
     {
       earFrame = 0;
     }
     break;    
 }

 
earFrame++;
}




ArtFunk

Code: [Select]
/* -- CHEEK ANIMATIONS -------------------------------------- */

void animateCheek()
{
 cheekBuffer = B00000000;
 cheekBuffer |= NumTab[abs(cheekFrame-7)+1];
 cheekFrame++;
 
 if(cheekFrame > 13)
 {
   cheekFrame = 0;
 }
}

/* -- BAR ANIMATIONS ----------------------------------------- */

void animateBars()
{
 barBuffer = B00000000;
 
 switch(barAnimation)
 {
   case 1: singleChaser();       break;
   case 2: multiChaser();        break;
   case 3: bounce();             break;
   case 4: growOutwards();       break;
   case 5: growInwards();        break;
   case 6: simpleStrobe();       break;
   case 7: singleRandomStrobe(); break;
   case 8: multiRandomStrobe();  break;
   case 9: allBarsOn();          break;
   case 10: vuMeter();           break;
   
   // just in case the pot breaks :)
   default: singleChaser();      break;  
 }

}

/* -- CHIN ANIMATIONS ----------------------------------------- */

void animateChin()
{
 static char chinFrame = 0;
 
 chinBuffer = B00000000;
 
 char i;
 for(i = 1; i <= 4; i++)
 {
   if(random(0, 4) == 0)
   {
     chinBuffer |= NumTab[i];
   }
 }
 
 if(chinFrame > 4)
 {
   chinFrame = 0;
 }
}

/* ---------------------------------------------------------------
   turnOnBar(int pinNum)
   Takes a integer between 1 and 8 and turns the corresponding
   bar on.
---------------------------------------------------------------- */

void turnOnBar(int pinNum)
{
 if(pinNum >= 1 && pinNum <= 8)
 {
   barBuffer |= NumTab[pinNum];
 }
}

/* ---------------------------------------------------------------
   The following functions are the different animations
   for the bars,
---------------------------------------------------------------- */
 
 

/* -- 1: SINGLE CHASER ----------------------------------------- */

void singleChaser()
{
 barFrame++;
 
  if(barFrame > 8)
  {
    barFrame = 1;
  }
 
 turnOnBar(barFrame);
}

/* -- 2: MULTI CHASER ----------------------------------------- */

void multiChaser()
{
 barFrame++;

  if(barFrame > 11)
  {
    barFrame = 1;
  }
 
 
 turnOnBar(barFrame);
 turnOnBar(barFrame - 1);
 turnOnBar(barFrame - 2);

}

/* -- 3: BOUNCE ----------------------------------------- */

void bounce()
{
 char position = abs(barFrame-7)+1;
 barFrame++;
 if(barFrame > 13)
 {
   barFrame = 0;
 }
 
 turnOnBar(position);

}

/* -- 4: GROW OUTWARDS ----------------------------------------- */

void growOutwards()
{
 barFrame++;
 
 if(barFrame > 5)
 {
   barFrame = 1;
 }  
 char pos = barFrame - 2;
 char i;
   
 for(i = (4-pos); i <= 4; i++)
 {
   turnOnBar(i);
   turnOnBar(9-i);
 }    
}

/* -- 5: GROW INWARDS ----------------------------------------- */

void growInwards()
{
 barFrame++;
 
 if(barFrame > 5)
 {
   barFrame = 1;
 }
 
 char pos = barFrame - 1;
 char i;
   
 for(i = 1; i <= pos; i++)
 {
     turnOnBar(i);
     turnOnBar(9-i);
 }    
}

/* -- 6: SIMPLE STROBE --------------------------------------- */

void simpleStrobe()
{
 if(barFrame == 0)
 {  
   barBuffer = B11111111;
   barFrame = 1;
 }
 else
 {
   barFrame = 0;
 }

}

/* -- 7: SINGLE RANDOM STROBE ----------------------------------------- */

void singleRandomStrobe()
{
 turnOnBar(random(1, 9));
}

/* -- 8: MULTI RANDOM STROBE ----------------------------------------- */

void multiRandomStrobe()
{
 int randNum = random(0, 4);
 int i = 0;
 
 for(i = 0; i <= randNum; i++)
 {
   turnOnBar(random(1, 9));
 }
}

/* -- 9: ALL BARS ON ----------------------------------------- */

void allBarsOn()
{
 int i;
 
 // loop through the bars and turn them all on
 for(i = 1; i <= 8; i++)
 {
   turnOnBar(i);
 }
}

/* -- 10: VU Meter ----------------------------------------- */

void vuMeter()
{
 char volume =  round(analogRead(lineInPin)/128);
 
 char i;
 for(i = 1; i <= volume; i++)
 {
   turnOnBar(i);
 }
}

void shiftOutTest(int myDataPin, int myClockPin, byte myDataOut) {
 // This shifts 8 bits out MSB first,
 //on the rising edge of the clock,
 //clock idles low

 //internal function setup
 int i=0;
 int pinState;
 pinMode(myClockPin, OUTPUT);
 pinMode(myDataPin, OUTPUT);

 //clear everything out just in case to
 //prepare shift register for bit shifting
 digitalWrite(myDataPin, 0);
 digitalWrite(myClockPin, 0);

 //for each bit in the byte myDataOut?
 //NOTICE THAT WE ARE COUNTING DOWN in our for loop
 //This means that %00000001 or "1" will go through such
 //that it will be pin Q0 that lights.
 for (i=7; i>=0; i--)  {
   digitalWrite(myClockPin, 0);

   //if the value passed to myDataOut and a bitmask result
   // true then... so if we are at i=6 and our value is
   // %11010100 it would the code compares it to %01000000
   // and proceeds to set pinState to 1.
   if ( myDataOut & (1<<i) ) {
     pinState= 1;
   }
   else {
     pinState= 0;
   }

   //Sets the pin to HIGH or LOW depending on pinState
   digitalWrite(myDataPin, pinState);
   //register shifts bits on upstroke of clock pin  
   digitalWrite(myClockPin, 1);
   //zero the data pin after shift to prevent bleed through
   digitalWrite(myDataPin, 0);
 }

 //stop shifting
 digitalWrite(myClockPin, 0);
}

ArtFunk


Please modify that post so the code is in a code box. Select it and hit the # icon.

This bit does the shifting out:-
Code: [Select]
digitalWrite(latchPin, LOW);
  shiftOutTest(dataPin, clockPin, tempBuffer);
  shiftOutTest(dataPin, clockPin, cheekBuffer);
  shiftOutTest(dataPin, clockPin, barBuffer); 
  digitalWrite(latchPin, HIGH);


If you add another shift register then add another:-
shiftOutTest(dataPin, clockPin, newBuffer);

Quote
The problem is that the configuration is Arabic for me

You will have to learn how to code if you want to do something unique.

so I have to add to the code this string?
shiftOutTest(dataPin, clockPin, newBuffer);

and get this?

Code: [Select]
digitalWrite(latchPin, LOW);
  shiftOutTest(dataPin, clockPin, tempBuffer);
  shiftOutTest(dataPin, clockPin, cheekBuffer);
  shiftOutTest(dataPin, clockPin, barBuffer);
  shiftOutTest(dataPin, clockPin, newBuffer);
  digitalWrite(latchPin, HIGH);


but then as I say led to what sequence do?

Grumpy_Mike

You put stuff in newBuffer and then you will see it on the last of the chained shift registers.

ArtFunk


You put stuff in newBuffer and then you will see it on the last of the chained shift registers.

I tried adding the string as I wrote above, but it gives me error already at checkout.
I really have no idea what I do.

Grumpy_Mike

Quote
but it gives me error already at checkout.

I am not sure what that means, do you mean the compiler gives an error?

If so then you read the error and fix it. These errors are only syntax errors.
If you don't know what it means then you post the code AND what error message you are getting and people will try to explain it to you.

ArtFunk


Quote
but it gives me error already at checkout.

I am not sure what that means, do you mean the compiler gives an error?

If so then you read the error and fix it. These errors are only syntax errors.
If you don't know what it means then you post the code AND what error message you are getting and people will try to explain it to you.

ok, I will do other tests.
thanks

icegooner

It's been a while since this thread has been active, but I'm trying to use the same code as artfunk, from James Moss, but I'm wondering where I can get the potentiometer.h and math.h files? Are these general libraries I can get somewhere or were these files made specially for this project. If someone could help me out with this I'd really appreciate it. I don't quite understand these .h files, never used them before.

Go Up