Deleting code in sketch doesn't change outcome

I had a feeling that this would end up being about the hardware at some point.
Google tells me that Q0 and QA are synonymous. Same with Q1 and QB, and so forth.

Sorry, I'm coming back to this post #14, I missed it earlier.

How do you write code that can't be tested? I can't imagine it. You are way above me in level.

Blockquote

but what does digit-- do that --digit doesn't, or vice versa

Blockquote
Have to explain this . I'm going to bed, got an appt in morning. Thank you for helping. I'll be looking forward to more discussion. I'll be visiting this in the morning. Thank you again!

I wasn't asking you, @crabcrawler, I was asking @b707, because they were the one who had brought it up. As far as I know, the answer is "essentially nothing".

Oh sorry! I was wondering. I think I see what was being asked though, so that's something right? now I know the answer is the order doesn't matter? I'll file that with the rest of the stuff pouring in! :exploding_head:

So, I got humor. I got committment. I went and got my appointment canceled. So is there anyone left to roll with me? If so,:

  1. byte seven_seg_digits_[15] = { where did the num get pulled from
    2.where did "Bxxxx" number come from and its meaning in the code? These are hexadecimal equivalents to the display segment?
    where do the decimal numbers come from?
    3.why does french c++ work and Ukrainian c++ work on same hardware? the c++ commands simply spit out a 01 equivalent? stop has hexadecimal equivalent ?

This is a binary representation of the segments, each "1" means segment on and "0" means it off.

say "NO" to drugs... :slight_smile: Where are you seen such variations of the C++?

Are you asking where did the 15 come from? you have 15 elements in the seven_seg_digits_[] array. 0-14.

You may be missing an important aspect of the seven segment display. Your PDF states you are using a 5161AS common cathode display. The below is from the 5161AS datasheet
image


The first image identifies the locations of the 8 LED segments on the display. For example, to display a '7', you turn on LEDs A, B and C.
The bottom image identifies the physical pins of the seven segments. Your display is common cathode, so to display a '7', you need to set pins 7, 6 and 4 (A, B and C) to 1 (5V on an Uno), the others to 0 (0V), and have pins 3 and/or 8 connected to ground.

Looking at the code to accomplish displaying a '7' on the display

The B11100000 is an 8 bit binary represented number. The leading B tells the Arduino compiler to interpret this as a binary number. The first number after the B is the Most Significant Bit (MSB). The far right number is the Least Significant bit (LSB).

The line of code shiftOut(dataPin, clockPin, LSBFIRST, seven_seg_digits[digit]); has the attribute LSBFIRST. This says start at the far right and shift bit by bit into the shift register from right to left. Considering this, the LSB (far right bit) will control pin QH of the register. The next bit to the left will control QG, and so forth. The MSB, the one closest to the B will control QA.

image

To make a '7', you want segments A, B and C to be turned on. Your display is common cathode so you want 1s on segments A, B and C and the other 5 are 0s. You have segment A tied to pin 15 (QA) of the 595, segment B tied to pin 1 (QB), and segment C tied to pin 2 (QC). After the 8 bits are shifted into the register in the order stated above you will have 5V on QA, QB and QC, displaying the number 7.

I hope this helps. Did this clear up anything?

@crabcrawler - I can't deduce what you are actually uploading and executing, nor whether that is real hardware or a simulation.

Pausing with delay() looks like it should def leave whatever was on the segments for the duration, and w/o pausing, whatever is next should come right away.

Perhaps this simulator and the example they have for the74595 would be useful. I think they have a seven segment display available, but it's easy to just use the LEDs they wired, you will still see things come and go even if nice digits aren't being displayed.

HTH

a7

What is your display doing?

Is it displaying digits now?

Or is it displaying weird, space-alien-like shapes? (can happen if you have the segments in the wrong order)

Or is it just showing a solid "8" ?

Or nothing at all?

At this point, I'm not looking to see if there is anything wrong with the software (that is, the code you are trying to run). It is the hardware (the chips, LED display, wiring, etc.) that I am wondering about.

How exactly do you have your hardware set up? Is there a diagram you could show us? Even a diagram drawn with paper and pencil will suffice, as long as all the parts are there and in the right places.

Repy to Post 26

[TUTORIAL] Arduino 5161as 7-segment display, datasheet + code (arduino-france.site)

Don't see a "french C++" in your link...

I was under the impression his setup is as in section 2.1.4 of the pdf attached in post #17.

@crabcrawler I like how you are documenting your studies. That's good for the mind as well as having something to reference. What I do not like is the Fritzing images taking the place of a schematic. Do yourself a favor and download and learn KiCAD. It is so simple to create a schematic within KiCAD. A 20 minute youtube tutorial is all you need to learn how to draw a schematic. You will only need to learn maybe 5% of KiCADs capability to create and maintain a schematic. Don't worry about the pcb board side of it. You don't need it. Try it. It took me about 20 minutes to do this

No such thing as French C++ or Ukrainian C++.
Think of it like math. A French or Ukrainian multiplication table will give exactly the same answers as an American multiplication table. The same (made in China) calculator can be used in France or Ukraine as in America, and the answers will still be right.

I understand the 0b11111111 or 0B111 syntax, but why doesn't B100000000 appear to work? Is there a file full of #define B11110000 0xF0 ... somewhere?

Yes. But I think it's 240 rather than 0xF0, but, yes, you have the basic idea right.

1 Like

Ugh:

and

Tell us how you really feel. :expressionless:

Unbelievable! Someone must have been paid for lines of code per day...

a7

1 Like

I would think that someone who has been around Arduino as long as you have would have seen enough that this would, in fact, be believable.

1 Like

Thanks! and Thanks! I've had some drawing experience, a little cad decades ago and found I didn't remember much and don't want to relearn it. Later programs, that I like but went bye bye I think was something called Display Right or similar, then various until Claris which got gone. Paint doesn't do what I want so I appreciate KiCAD. Seems maybe someone recommended it with others, or it came up in search. Anyway, I'll go research it. Bet it beats my drawings using Word. That's what I used for the Shift Register but the labels keep shifting despite being grouped ( no pun intended hah! :laughing:)

Heh, in the olden days, Arduino documented their binary Bxxx constants (per the wayback machine):

But the new Arduino doc version moved to the more recent GCC 4.3 / C++14 standard: