the electronic die using 74HC75

hi guys i have some issues in my little projects and i ask you for some help.

here is my code it's same to me logical but it's not working in my circuit.

#define Delay 20
int pips[6][7]={{0,0,0,1,0,0,0},
{1,0,0,0,0,0,1},
{1,0,0,1,0,0,1},
{1,0,1,0,1,0,1},
{1,0,1,1,1,0,1},
{1,1,1,0,1,1,1},};
int button = 13;
int shiftpin = 2;
int storagepin = 3;
int datapin = 4;
int i;
int memor;

void setup()
{
pinMode(shiftpin,OUTPUT);
pinMode(storagepin,OUTPUT);
pinMode(datapin,OUTPUT);
pinMode(button,INPUT);
digitalWrite(storagepin,1);
}

void loop()
{
if(digitalRead(button) == HIGH)
displaypips(random(1,7));

}
void displaypips(int value){
reset();
for( i=0; i<7; i++)

digitalWrite(memor,(pips[value-1]==1)?1:0);

  • //delay(Delay);*
  • shiftOut(datapin,shiftpin,LSBFIRST,memor);*
  • digitalWrite(storagepin,1);*
  • delay(Delay);*
    }
    void reset(){
  • digitalWrite(shiftpin,0);*
  • digitalWrite(storagepin,0);*
  • digitalWrite(datapin,0);*
    }

Can you please be more specific than, "not working"?

Do you have a "real" schematic, even if it is hand drawn?

Please explain the function that the 74HC75 performs in this circuit. I'm having a hard time grasping what a quad latch would accomplish for this circuit.

i want just economize pins (extension of ports).

oualid999:
i want just economize pins (extension of ports).

Your photo shows a 74HC595. That is a different chip. Why are you misleading us? Please read these two posts:

General Guidance and How to use the Forum
and
Read this before posting a programming question ...
You may also find useful information that would answer your question here:
Useful links - check here for reference posts / tutorials

It is important to provide as much of the information that is needed to solve your problem as you can, in your first posts. The forum link above has guidelines for posting in a standard way that makes it easiest for people to provide you with useful answers. Making an effort to do this will greatly increase the number and quality of helpful responses that you get.

In this case, the problem is that you have posted code without using code tags. The code tags make the code look

like this

when posting source code files. It makes it easier to read, and can be copied with a single mouse click. Also, if you don't do it, some of the character sequences in the code can be misinterpred by the forum code as italics or funny emoticons. The "Code: [Select]" feature allows someone to select the entire sketch so it can be easily copied and pasted into the IDE for testing or review.

If you have already posted without using code tags, open your message and select "modify" from the pull down menu labelled, "More", at the lower right corner of the message. Highlight your code by selecting it (it turns blue), and then click on the "</>" icon at the upper left hand corner. Click on the "Save" button. Code tags can also be inserted manually in the forum text using the code and /code metatags.

Welcome

  • memor is not initialized

  • The for loop is missing braces, and it will run only once because you never reset i to 0. Don't use a global variable, especially one with a bad name such as 'i', instead use a local variable declared in the for loop : for ( uint8_t i = 0;

And you could reduce memory usage (not that it's a problem in your case, just good practice) if you used an array like this:

uint8_t const pips[6]=
{
  0b0001000,
  0b1000001,
  0b1001001,
  0b1010101,
  0b1011101,
  0b1110111
};

And using bitRead