# Using 4fnd (seven segment dispaly) count down from 100 to 0, also buzz once hits 0

I'm trying to have my 4fnd count down from 100 to 0.
once the count has hit zero buzzer sounds.
Currently my code is out putting on my display 1234 then 2345, 3456 and so on, but i just want it to start at 100 and decrement 1 each time with a 200ms delay each time. This is what I have so far..

My main focus is just fixing this loop to make it count from 100 to 0.

``````#define FND_A 2
#define FND_DP 9
int beepPin = 10;
int pos[4] = {A0,A1,A2,A3};

void setup()
{
for(int i = FND_A ; i <= 10; i++){
pinMode(i, OUTPUT);
}
for(int i = 0; i < 4; i++){
pinMode(pos[i], OUTPUT);
}
}
boolean digit[10][8] = {
{ 1,1,1,1,1,1,0,0 }, //0
{ 0,1,1,0,0,0,0,0 }, //1
{ 1,1,0,1,1,0,1,0 }, //2
{ 1,1,1,1,0,0,1,0 }, //3
{ 0,1,1,0,0,1,1,0 }, //4
{ 1,0,1,1,0,1,1,0 }, //5
{ 1,0,1,1,1,1,1,0 }, //6
{ 1,1,1,0,0,0,0,1 },
{ 1,1,1,1,1,1,1,1 },
{ 1,1,1,0,0,1,1,0, }
};
unsigned long pre = 0;
int count = 0;
void loop()
{
unsigned long current = millis();

if(current - pre > 1000){
pre = current;
count++;
if(count ==5)
count = 0;
}
for(int i = 0; i < 4; i++){
positions(i);
number(count + i);
delay(5);
}

}

void number(int n){
for(int i = FND_A; i <= FND_DP; i++)
{
digitalWrite(i, digit[n][i - 2]);
}

}

void positions(int p){
for(int i =0; i<3; i++){
digitalWrite(pos[i], HIGH);
}
digitalWrite(pos[p],LOW);
}
``````

Do you know how to send a four digit number to the display?

If so, start from there, and count that number down.

I believe i added it, also i trying to change the loop i have in order to count down from 100 to 0, instead of what its currently doing which is starting at 1234 then going to 2345, 3456....

Other post/duplicate DELETED
Please do NOT cross post / duplicate as it wastes peoples time and efforts to have more than one post for a single topic.

Continued cross posting could result in a time out from the forum.

Could you take a few moments to Learn How To Use The Forum

Hello, Welcome to the Arduino Forum. This guide explains how to get the best out of this forum. Please read and follow the instructions below. Being new here you might think this is having rules for the sake of rules, but that is not the case. If you don’t follow the guidelines all that happens is there is a long exchange of posts while we try to get you to tell us what we need in order to help you, which is frustrating for you and frustrating for us. The people who try to help with your pro…

Your OS and version can be valuable information, please include it along with extra security you are using.

Always list the version of the IDE you are using and the board version if applicable.

Use quote or add error messages as an attachment NOT a picture.

How to insert an image into your post. ( Thanks @sterretje )

Add a SCHEMATIC were needed even if it is hand drawn

Remember that the people trying to help cannot see your problem so give as much information as you can

COMMON ISSUES

Ensure you have FULLY inserted the USB cables.

Check you have a COMMON GROUND where required. ( Thanks @Perry)

Where possible use USB 2.0 ports or a USB 2.0 POWERED HUB to rule out USB 3.0 issues.

Try other computers where possible.

Try other USB leads where possible.

You may not have the correct driver installed. CH340/341 or CP2102 or FT232 VCP Drivers - FTDI

There may be a problem with the board check or remove your wiring first.

Remove any items connected to pins 0 and 1.

COMPUTER RELATED

Close any other serial programs before opening the IDE.

Ensure you turn off any additional security / antivirus just to test.

There may be a problem with the PC try RESTARTING it.

You may be selecting the wrong COM port.

Avoid cloud/network based installations where possible OR ensure your Network/Cloud software is RUNNING.

Close the IDE before using any other serial programs.

ARDUINO SPECIFIC BOARDS

CH340/341 based clones do not report useful information to the “get board info” button.

NANO (Old Types) some require you to use the OLD BOOTLOADER option.

NANO (ALL Types) See the specific sections lower in the forum.

NANO (NEW Types) Install your board CORE’s.

Unless using EXTERNAL PROGRAMMERS please leave the IDE selection at default “AVRISP mkII”.

Boards using a MICRO usb connector need a cable that is both DATA and CHARGE. Many are CHARGE ONLY.

CREATE editor install locations.

On macOs ~/Applications/ArduinoCreateAgent-1.1/ArduinoCreateAgent.app/Contents/MacOS/config.ini

On Linux ~/ArduinoCreateAgent-1.1/config.ini

Performing the above actions may help resolve your problem without further help.
Language problem ?
Try a language closer to your native language:

Deutsch - German

Español - Spanish

Français - French

অসমীয়া, বাংলা, बड़ो - India

Italiano - Italian

Nederlands - Dutch

Portugues - Portuguese

Россия - Russia

Scandinavia Swedish, Suomi - Finnish, Norsk - Norwegian

Thanks to all those who helped and added to this list.

That is certainly a mystery.

Evidently, you don't yet know how to display an arbitrary number. The number 100 might be fun. Don't you think it would be wise to figure out how to do that, then move on to greater things?

Don't forget to add the code tags!

any other help would be appreciated thank you!

i did add the codes, tags I'm just trying to figure out how to make my 4fnd display 100 and count down to 0.

How is that going? Thoughts? Observations? We need some follow up information from reply #6. Before you can count, you certainly must be able to display a number. If you can't, then that is what you should be working on.

ive had something displayed this whole time, im geting 1234 but its going up? and im not sure how to start it at 100.

I could upload a picture of my Arduino if that would help clarify things.

What are you trying to do there?

By the way, where is your schematic or wiring diagram that the forum guidelines ask you to post? As pointed out to you in the links you were directed to, in reply #5.

I believe this checking the position when it's less then 4 and if it is incrementing each number by one.

Believe, but don't know? Did someone else write the code?

I haven't created a schematic for this yet, but i can right now

okay will do, sorry about that!

It looks to me that you did not write this code, which means that to change it, you first need to understand it. To do so, go through it line by line, and make sure you know what each line does, and why.

Or, you could write your own!

We were given this code to work off of.

Well, that is a bummer.

That code is written in a particularly obtuse style that is quite difficult for beginners to understand.

Would there be a problem if you were to write your own, after studying some much more reasonable and simpler approaches?

https://create.arduino.cc/projecthub/aboda243/get-started-with-seven-segment-c73200