74HC595 with 74LS47 hexa code to UNO R3

{  pinMode(Pin_A, OUTPUT);
 digitalWrite(Pin_A, HIGH);
  pinMode(Pin_B, OUTPUT);
 digitalWrite(PIN_B, HIGH);   // .......etc to H..........
}
  • The { } are not needed here
  • You are using common cathode, so should set to LOW, not HIGH.
    This is so the LED all start "off".
  • You need to repeat for all letters, Pin_A - Pin_H.
    (Unless you use more complex code)

I'm not sure about the meaning of "hexa" and "case" sorry.
Is it maybe "binary" and "base-10"?

So, to memorize the binary input (0010), you want to store as base-10 (2)?

That's a good way to do the next step. Do you have some idea of how to achieve it?

sketch_SEPT02a_hexa_to_9out_.ino (1,6 Ko)

Re I used ide "copy for forum markdown "

I hope it's easier to read,

and I return in the forum , this afternoon
Jack

Please include code in your posts, not screenshot or .ino files,

Here are the contents of your .ino file:

// to see the schematic with UNOR3 Card refere post 27.................
// Number 6 of Pin_A is the Pin 6 output on UNO Card....and A is the segment into a display commun Cathode
// Number 9 of Pin_H Go to LED N° 8
/* Choose with and into SW1 a code hexa to read on display the numbers 1 or
          2 or 3 or 4 or 5 or 6 or 7 or 8 and on LED N°8 as numner = Zero*/
/*................JACK EU ===== ARDUINO ==== IDE 2.1.1=============.......
..........................................................*/
#define Pin_A 6
#define Pin_B 5 
#define Pin_C 4
#define Pin_D 3
#define Pin_E 2
#define Pin_F 8
#define Pin_G 7
#define Pin_H 9
#define Pin_BP1 18
#define Pin_BP2 10
// entries Hexa names A0 A1 A2 A3 on pins 14 15 16 17
// entry Push-Button named BP1 is on pin 18 and entry named BP2 is on pin 10 of UNO       
//.................................................
void setup()
{
           // this lines run once
      pinMode(Pin_BP1, INPUT);
      pinMode(Pin_BP2, INPUT);      
           // set led pins as outputs to light...............
    pinMode(Pin_A, OUTPUT);
    digitalWrite(Pin_A, LOW);
    pinMode(Pin_B, OUTPUT);
    digitalWrite(Pin_B, LOW);
    pinMode(Pin_C, OUTPUT);
    digitalWrite(Pin_C, LOW);
    pinMode(Pin_D, OUTPUT);
    digitalWrite(Pin_D, LOW);
    pinMode(Pin_E, OUTPUT);
    digitalWrite(Pin_E, LOW);
    pinMode(Pin_F, OUTPUT);
    digitalWrite(Pin_F, LOW);
    pinMode(Pin_G, OUTPUT);
    digitalWrite(Pin_G, LOW);
    pinMode(Pin_H, OUTPUT);
    digitalWrite(Pin_H, LOW);

       
}         // ......................END SETUP  ...................
 
void loop(){
  
}

Everything looks good so far.

OK toddnz,

Tks you for putting the apparent file. But with i d e the sketch was transformed into a file.
When Iput the file in my Post I downloaded this file and it was not placed appearing on the right
as is the area for a photo.
So I haven't found the good method to display it with all lines. I will try for the next one.

now,
I continue for the void loop

The first thing, when starting the UNO card, is to display nothing: 9 segments LOW.
I can press BP2 but there was nothing it.
If I press ON BP1 the code in SW1 will be converted and then displayed with the segments ( or segments +led n°8 ).
The numbers to be displayed from 1 to 8 ; and for 9 the n°8 Led will be UP.
.......I can then erase all Ledsegments by pressing BP2.
( I don't display the number 0 )
Nice sketch to invent !!!

to be continued...
I return here this monday 4th
Best regards ....................................... Jack

Hello, toddnz,

I think you read the previous Post #65

I just received the cathode display this morning.

I drew the organizational and put it here.

void loop()
               // Uno read and store Voltage level at the button BP1 HIGH 1 LOW 0
{
   bool button_BP1 = digitalRead(18);
   bool button BP2 = digitalRead(10);

              // If the reset-release button BP2 is pressed (connected to Gnd)
   if (button_BP2 == LOW)
             /* set all the anodes pins to LOW  , no current no light
identic level anode cathode. The display component is common cathode */
      {
         digitalWrite(Pin_A, LOW);
         digitalWrite(Pin_B, LOW);
         digitalWrite(Pin_C, LOW);
         digitalWrite(Pin_D, LOW);
         digitalWrite(Pin_E, LOW);
         digitalWrite(Pin_F, LOW);
         digitalWrite(Pin_G, LOW);
         digitalWrite(Pin_H, LOW);
     }
           /* now by releasing this button BP2 the levels must be
memorized to keep the leds OFF*  I can for example press BP1 in 5 minutes*/

to be continued,
Best regards, Jack

Hello toddnz

The lines in IDE " bool button_BP2 = digitalRead (10) " , bool button_BP1 too
indicate an error
button_BP2 and button_BP1 are not in the list.

Best regards
Jack

I'm not sure, could you please copy and paste the exact error?
Please also post your full code, so I can see where the error comes from.

Ok toddnz,

I think what it's because BP1 is not developped.


;
for BP1 errors,
;

Hello toddnz,

You can see my error ....... C is not c
;


;
to be continued,
best regards.......................Jack

Hello toddnz

I have worked on the sketch, there is a problem wiith hexa letters A at F to memorizate it.
See the // after number 9.
Ihope yours informations, Thanks ;
here the sketch compiled ok

saisissez ou collez du code ici
// NO date no finished
// NO VALIDED
// to see the schematic with UNOR3 Card refere post 27.................
// Number 6 of Pin_A is the Pin 6 output on UNO Card....and A is the segment into a display commun Cathode
// Number 9 of Pin_H Go to LED N° 8 used to verify number zero ok
/* Choose with and into SW1 a code hexa to read on display the numbers 1 or
          2 or 3 or 4 or 5 or 6 or 7 or 8 or 9
          and letters A to F, and on LED N°8 as verification number = Zero*/
/*................JACK EU ===== ARDUINO ==== IDE 2.1.1=============.......
..........................................................*/
#define Pin_A 6
#define Pin_B 5 
#define Pin_C 4
#define Pin_D 3
#define Pin_E 2
#define Pin_F 8
#define Pin_G 7
#define Pin_H 9
#define Pin_BP1 18
#define Pin_BP2 10
int selected_number =0;
//................................................................
//................................................................
// entries Hexa names A0 A1 A2 A3 on pins 14 15 16 17
// entry Push-Button named BP1 is on pin 18
// and entry named BP2 is on pin 10 of UNO       
//.................................................
void setup()
{
           // this lines run once
      pinMode(Pin_BP1, INPUT);
      pinMode(Pin_BP2, INPUT);
      
             // set led pins as outputs to light...............
    pinMode(Pin_A, OUTPUT);
    digitalWrite(Pin_A, LOW);
    pinMode(Pin_B, OUTPUT);
    digitalWrite(Pin_B, LOW);
    pinMode(Pin_C, OUTPUT);
    digitalWrite(Pin_C, LOW);
    pinMode(Pin_D, OUTPUT);
    digitalWrite(Pin_D, LOW);
    pinMode(Pin_E, OUTPUT);
    digitalWrite(Pin_E, LOW);
    pinMode(Pin_F, OUTPUT);
    digitalWrite(Pin_F, LOW);
    pinMode(Pin_G, OUTPUT);
    digitalWrite(Pin_G, LOW);
    pinMode(Pin_H, OUTPUT);
    digitalWrite(Pin_H, LOW);
       
}         // ......................END SETUP  ...................
 
void loop(){
//  read and store Voltage level button BP1 and BP2 HIGH 1 LOW 0
    bool button_BP1 = digitalRead(18);
    bool button_BP2 = digitalRead(10);
    //bool button_BP1 = digitalRead(18);
// if the release button BP2 is pressed (connected to gnd)
        if (button_BP2 == LOW)
    {
        digitalWrite(Pin_A, LOW);
      }
// if the valid selection BP1 is pressed level is LOW
        else if (button_BP1 == LOW)
    {
        bool switch_a = digitalRead(A0);
        bool switch_b = digitalRead(A1);
        bool switch_c = digitalRead(A2);
        bool switch_d = digitalRead(A3);

// after pressing, this seection will store, the user's selection
        int selected_number = 0;
        //int selected_letter = 0;
// apply the binary data from switches
        bitWrite(selected_number, 0, switch_a); // if switch little a is closed, set first
        bitWrite(selected_number, 1, switch_b); // if switch little b is closed, set second
        bitWrite(selected_number, 2, switch_c); // If .............. c is closed set tre 
        bitWrite(selected_number, 3, switch_d); // if ...............d is closed set fo
    }
        if (selected_number == 0)
          {
            digitalWrite(Pin_A, LOW);
            digitalWrite(Pin_B, LOW);
            digitalWrite(Pin_C, LOW);
            digitalWrite(Pin_D, LOW);
            digitalWrite(Pin_E, LOW);
            digitalWrite(Pin_F, LOW);
            digitalWrite(Pin_G, LOW);
            digitalWrite(Pin_H, HIGH);
          }
        else if (selected_number == 1)
          {
            digitalWrite(Pin_B, HIGH);
            digitalWrite(Pin_C, HIGH);
          }
        else if (selected_number == 2)
          {
            digitalWrite(Pin_A, HIGH);
            digitalWrite(Pin_B, HIGH);
            digitalWrite(Pin_D, HIGH);
            digitalWrite(Pin_E, HIGH);
            digitalWrite(Pin_G, HIGH);
          }
        else if (selected_number == 3)
          {
            digitalWrite(Pin_A, HIGH);
            digitalWrite(Pin_B, HIGH);
            digitalWrite(Pin_C, HIGH);
            digitalWrite(Pin_D, HIGH);
            digitalWrite(Pin_G, HIGH);
          }
        else if (selected_number == 4)
          {
            digitalWrite(Pin_B, HIGH);
            digitalWrite(Pin_C, HIGH);
            digitalWrite(Pin_F, HIGH);
            digitalWrite(Pin_G, HIGH);
          }
        else if (selected_number == 5)
          {
            digitalWrite(Pin_A, HIGH);
            digitalWrite(Pin_F, HIGH);
            digitalWrite(Pin_G, HIGH);
            digitalWrite(Pin_C, HIGH);
            digitalWrite(Pin_D, HIGH);
          }
        else if (selected_number == 6)
          {
            digitalWrite(Pin_F, HIGH);
            digitalWrite(Pin_E, HIGH);
            digitalWrite(Pin_D, HIGH);
            digitalWrite(Pin_C, HIGH);
            digitalWrite(Pin_G, HIGH);
          }  
        else if (selected_number == 7)
          {
            digitalWrite(Pin_A, HIGH);
            digitalWrite(Pin_B, HIGH);
            digitalWrite(Pin_C, HIGH);
          }
        else if (selected_number == 8)
          {
            digitalWrite(Pin_A, HIGH);
            digitalWrite(Pin_B, HIGH);
            digitalWrite(Pin_C, HIGH);
            digitalWrite(Pin_D, HIGH);
            digitalWrite(Pin_E, HIGH);
            digitalWrite(Pin_F, HIGH);
            digitalWrite(Pin_G, HIGH);
          }
        else if (selected_number == 9)
          {
            digitalWrite(Pin_A, HIGH);
            digitalWrite(Pin_B, HIGH);
            digitalWrite(Pin_C, HIGH);
            digitalWrite(Pin_F, HIGH);
            digitalWrite(Pin_G, HIGH);
          }    
// Now To see the letter A ......................................
        else if (selected_number == A7) // .............WHY A7 ? ......
          {
            digitalWrite(Pin_A, HIGH);
            digitalWrite(Pin_B, HIGH);
            digitalWrite(Pin_C, HIGH);
            digitalWrite(Pin_F, HIGH);
            digitalWrite(Pin_E, HIGH);
            digitalWrite(Pin_G, HIGH);
          }
// Now To see the letter b ....................minus....................        
        else if (selected_number == B0) // ..............WHY BO  ?  .........
          {
            digitalWrite(Pin_F, HIGH);
            digitalWrite(Pin_E, HIGH);
            digitalWrite(Pin_D, HIGH);
            digitalWrite(Pin_C, HIGH);
            digitalWrite(Pin_G, HIGH);
          }    


}      

else if (selected_number == A7) // .............WHY A7 ? ......

else if (selected_number == B0) // ..............WHY BO ? .........

I am interested to understand, why did you try A7 and BO?


Ah you want to type the numbers after 9? Well, after 9 is 10, and then 11. If you change A7 and B0 into 10 and 11, I think it would work.

There is also another way: if you want to type in hex, you can start with "0x".
0x9 is 9,   0xA is 10,  0xB is 11, etc.

IDE screenshot showing "zero x" hex prefix

Hello toddnz,

Tks for the reply,

For your two informations:
ONE
I try A7 in first and a second time for b minus B0, because the compilation give errors and suggested it to me.
I wrote it , A7 in first, and it removed the first error line;
As this error had disappeared fot A7, I wrote for the second error the other suggestion B0
I D E gave me the repairs but I don't undestand the principle.

TWO
Yes the switch SW 1 with 4 contacts go to Zero at F ; by tomorrow morning I will have the number 12 with 12 to test.

Something else, please read after #define Pin_BP2 10 ... I had to add " int selected_number = 0; "

Jack

Ah yes I see.
You have typed int selected_number = 0; in two different places. It is typed another time just before bitWrite. This double-up is wrong, but it is not the main issue.

There is part of your code which runs when BP1 is pressed. That entire part is:

else if (button_BP1 == LOW)
    {
        bool switch_a = digitalRead(A0);
        bool switch_b = digitalRead(A1);
        bool switch_c = digitalRead(A2);
        bool switch_d = digitalRead(A3);

// after pressing, this seection will store, the user's selection
        int selected_number = 0;
        //int selected_letter = 0;
// apply the binary data from switches
        bitWrite(selected_number, 0, switch_a); // if switch little a is closed, set first
        bitWrite(selected_number, 1, switch_b); // if switch little b is closed, set second
        bitWrite(selected_number, 2, switch_c); // If .............. c is closed set tre 
        bitWrite(selected_number, 3, switch_d); // if ...............d is closed set fo
    }

Notice the { }, the start one by else if, and the finish one just after bitWrite.
This whole code above is inside loop(). The Arduino tries to run it many many times, but it is only permitted when BP1 is low.

Just after that part, the next section of your code decides which LED segments to turn on.

 if (selected_number == 0)
          {
            digitalWrite(Pin_A, LOW);
            digitalWrite(Pin_B, LOW);
            digitalWrite(Pin_C, LOW);
            digitalWrite(Pin_D, LOW);
            digitalWrite(Pin_E, LOW);
            digitalWrite(Pin_F, LOW);
            digitalWrite(Pin_G, LOW);
            digitalWrite(Pin_H, HIGH);
          }
        else if (selected_number == 1)
          {
            digitalWrite(Pin_B, HIGH);
            digitalWrite(Pin_C, HIGH);
          }

// (Etc..)

Notice that this section, about the LED, is not inside the earlier section, for button BP1. This means that the section for the LED will run repeatedly. Whether you press BP1 or don't press BP1, the section for the LEDs will still run. This is important detail #1

So now you added another int selected_number but at the start you had only one.

Here is important detail #2: "if you put variables" (int selected_number;) inside of {  }, they only exist inside the {  }

The first int selected_number = 0; was inside the { } of loop(), and even more buried, inside the { } of else if (button_BP1 == LOW).

This means that only the BP1 press code can see selected_number. It is invisible to your LED code section.

The IDE probably said an error, that it can't see selected_number, and then you added the second selected_number just below #define Pin_BP2 10.

This second selected_number didn't help, because it is separate from the selected_number inside the BP1 code.

Important point #3: if two "variables" (selected_number) have the same name, the code chooses the one inside its own { }

When your code runs now, there is no error, but it doesn't do what you want. The BP1 code puts the hex data into its own secret selected_number. As soon as the last bitWrite finishes, there is the }, and that "secret selected_number" disappears forever. Then the LED code tries to look at selected_number. It finds the one outside all {}, from near #define Pin_BP2 10, but there is no information here. The PB1 code didn't use this selected_number, because it had its own nearby one inside the { }.


Short answer:

  • Delete the new int selected_number =0;, by #define Pin_BP2 10
  • Move all of the LED code, if (selected_number == 0) etc.., move it to just under bitWrite(selected_number, 3, switch_d);, inside the final } which signals the end of BP1 press code

Re toddnz

Thanks you for your message;

I will study all your explanations and I will send you a message tomorrow. and saturday.

On I D E , I complete the sketch for A to F with 10 at 15.
released A7 and B0,


;

;
and compilation result is OK with int selected_number=0; no delete (for this time).
I am study "int selected_number=0; now.
..................................
If I remove the line " int selected_number=0; under line #define Pin_BP2 10 , the compilation indicates this
;

;
to be continued,
Best regards......................................Jack.

Post #74 has information about that error

Hello toddnz,

Thanks for your message,
I study that with Post #74 this week-end, and make the circuit , the parts on my Breadboard. and photos.
Good Week-End
to be continued,
Best regards..................................Jack

Hello toddnz

I try to understand... But I have difficulties.
;
AA_after_Define
and........................................
;


;
Where is the error ?

to be continued,
Best regards ...........................Jack.

Sorry, I know it's a lot of writing.

Line #21: you have deleted. This is correct.
Line #80: you have deleted. This is not correct. You should keep line 80.
Line #87: you have added. This is not correct. It should be at line 80 only.

Line #89, #90, etc: All this code (about LED output) should move to Line #87, before the "}"


Explanation

Line #80:

Because you create selected_number between the { } of line #73 and #88, it only exists between #73 and #88.

At line #89 and below, selected_number is invisible.

'selected_number' was not declared in this scope
Means something like "selected_number was invisible here"

Line #89 and below

These lines are outside the { } of line #73 and #88. This means that #89 and below will run repeatedly, non-stop, really fast.

Lines #89 and below (changing LED output) should only happen when BP1 is pressed. To achieve this, lines #89 and below need to be before the } at line #88.

Hello toddnz,

I worked this Week-end to assembly all the parts and wires, so the schematic #27
you can see my picture here.
To be continued tomorrow,
Best regards.............................Jack.
;


;
Jack.