Components and supplies
Arduino UNO
Jumper wires (generic)
4 digit 7 Segment Led display
Project description
Code
Code
arduino
What we do in This code is called multiplexing ( I recommend you watch the video t understand it better). the point is that in A, B, C, ... when it says they´re HIGH they´re off an when it says they´re LOW they´re on. Usually its the other way around but not today. Good Luck
Downloadable files
Connections
Connections
Connections
Connections
Comments
Only logged in users can leave comments
thepccreator
a year ago
Hi everyone, I made a simple library that you can use to write numbers on a display: https://github.com/ThePcCreator/Arduino-4-Digit-7-Segment-Display-Library
adrian-smith31
a year ago
There's no current limiting resistors. It's recommended to use transistors to switch the digits as it's very easy to overload your Arduino pins. They are rated at 20mA, 40mA absolute maximum BUT there is a current limit for each port and the entire chip (200mA) going anywhere near this risks the magic smoke or bonding wire failure. You can multiplex from the Arduino directly but you are really limited to 3mA per segment or less which, unless you are using a high efficiency display will result in a very dim display especially with multiplexing. In the above circuit, assuming current limiting resistors are selected for 5mA of current per segment (around 750 ohms) 40mA can flow through the digit common, damaging the Arduino. Use a PNP transistor (Common Anode) or NPN (Common Cathode) to switch the digits. A better idea is to use a power shift register such as the TPIC6B595 to drive the segments as you can increase the current to prevent a dim display. With multiplexing only one digit is on for x number of total digits thus reducing brightness. You need to increase the current to compensate but always refer to datasheets to ensure current limits are not exceeded. A rough guide for a 4 digit display using modern, high efficiency displays is to have 20mA of segment current giving an average of 5mA depending on the duty cycle. A danger of multiplexing if the program stops it can leave some segments lit and can blow the LED display depending on the current selected. Anyway I have rambled on long enough. But as Grumpy_Mike said and others this circuit will damage your Arduino and / or LED displays if used as-is. With suitable current limiting resistors it *could* work. But the display will be dim.
Grumpy_Mike
a year ago
Sorry but that circuit is absolute rubbish. There are no current limiting resistors, nor drivers for the common, anode or cathode display. You no not even specify what sort of display, common, anode or cathode to use. Like so many misguided guides you assume that the act of multiplexing will some how protect the Arduino pins from being overloaded. It does NOT. The peak current of a multiplexed display is not diminished in any way. I suggest this project is either removed from here, or updated to remove the errors in it.
mediumrhinoceros294
a year ago
me to
mediumrhinoceros294
a year ago
me to
mediumrhinoceros294
a year ago
me to
mediumrhinoceros294
a year ago
me to
adrian-smith31
a year ago
This same schematic is on other guide sites. It won't work as you say and ideally transistors should be used to switch the digit common pins. I've posted my own opinions on it separately.
falisohd
a year ago
Design an arduino based system to interface 7 segment display and switch to implement a display system which will work as when switch is on display E and when switch is off display 0
kamil1982
2 years ago
Hello sir I need your exprience and help and ask you about control devices by relays and gsm800L and the feedback as message in mobil can I measure the loads and the message feed back to my mobil as agauge or curve and what is the program that I used to help me in this project
Anonymous user
2 years ago
TWO WARNINGS: this project and code DOESN'T WORK and may it DAMAGE your Arduino and/or display! PLEASE @SAnwandter1, please fix this project to save many people hours of troubleshooting or worse; expense in damaged hardware! ——————————————————————————————————— . The wiring diagram doesn't include RESISTORS which means it may burn out your LEDs and/or Arduino. . The project's code outputs RUBBISH to the screen! See the comment and code by Maverick1701 — however even this code doesn't have the right digit code to output proper numbers! . The following code is working for me… displaying "0123" on the display. - /* A --- F | | B | G | --- E | | C | | --- D // This example code is in the public domain. // USE RESISTORS on the SEGMENT wires! (Arduino pins 2 to 8) */ // int pinA = 2; int pinB = 3; int pinC = 4; int pinD = 5; int pinE = 6; int pinF = 7; int pinG = 8; int D1 = 9; int D2 = 10; int D3 = 11; int D4 = 12; // // the setup routine runs once when you press reset: void setup() { // initialize the digital pins as outputs. pinMode(pinA, OUTPUT); pinMode(pinB, OUTPUT); pinMode(pinC, OUTPUT); pinMode(pinD, OUTPUT); pinMode(pinE, OUTPUT); pinMode(pinF, OUTPUT); pinMode(pinG, OUTPUT); pinMode(D1, OUTPUT); pinMode(D2, OUTPUT); pinMode(D3, OUTPUT); pinMode(D4, OUTPUT); } // the loop routine runs over and over again forever: void loop() { digitalWrite(D1, LOW); // NOTE that LOW denotes the active DIGIT digitalWrite(D2, HIGH); digitalWrite(D3, HIGH); digitalWrite(D4, HIGH); //0 digitalWrite(pinA, HIGH); // NOTE that HIGH denotes an active SEGMENT digitalWrite(pinB, HIGH); digitalWrite(pinC, HIGH); digitalWrite(pinD, HIGH); digitalWrite(pinE, HIGH); digitalWrite(pinF, HIGH); digitalWrite(pinG, LOW); delay(1); // wait for one millisecond digitalWrite(D1, HIGH); digitalWrite(D2, LOW); // NOTE that LOW denotes the active digit digitalWrite(D3, HIGH); digitalWrite(D4, HIGH); //1 digitalWrite(pinA, LOW); digitalWrite(pinB, HIGH); // NOTE that HIGH denotes an active SEGMENT digitalWrite(pinC, HIGH); digitalWrite(pinD, LOW); digitalWrite(pinE, LOW); digitalWrite(pinF, LOW); digitalWrite(pinG, LOW); delay(1); // wait for one millisecond digitalWrite(D1, HIGH); digitalWrite(D2, HIGH); digitalWrite(D3, LOW); // NOTE that LOW denotes the active DIGIT digitalWrite(D4, HIGH); //2 digitalWrite(pinA, HIGH); // NOTE that HIGH denotes an active SEGMENT digitalWrite(pinB, HIGH); digitalWrite(pinC, LOW); digitalWrite(pinD, HIGH); digitalWrite(pinE, HIGH); digitalWrite(pinF, LOW); digitalWrite(pinG, HIGH); delay(1); // wait for one millisecond digitalWrite(D1, HIGH); digitalWrite(D2, HIGH); digitalWrite(D3, HIGH); digitalWrite(D4, LOW); // NOTE that LOW denotes the active DIGIT //3 digitalWrite(pinA, HIGH); // NOTE that HIGH denotes an active SEGMENT digitalWrite(pinB, HIGH); digitalWrite(pinC, HIGH); digitalWrite(pinD, HIGH); digitalWrite(pinE, LOW); digitalWrite(pinF, LOW); digitalWrite(pinG, HIGH); delay(1); // wait for one millisecond // I've only include digits 0123 – I'm sure if you've got this far you can work out the rest. } -
Anonymous user
2 years ago
Im currently using Arduino and a 4 digit 7 segment display for an escape room timer. Instead of a traditional timer, that counts down from some number to zero, my timer is going to display the voltage of a battery (not actual but its going to keep the game moving as the voltage drops). The game will be a failure if the participants can not solve the room within the allotted time (I'm thinking 20-30 min) and the voltage will start dropping from 12.5V, 12.4, 12.3, 12.2... until when if falls below 11.5V the game is over. Thanks for the info, now I have a good place to start!
Anonymous user
2 years ago
You could additionally create two variables one called `high` and another one called `low` to fix the issue with `HIGH` and `LOW` on `D1`, `D2`, `D3`, and `D4` like so: > _Place this on top of your code before `setup()` and `loop()`:_ ``` #define high = 0x0 #define LOW = 0x1 ``` It should work as C's variables are case-sensitive, which means `HIGH` isn't the same as `high` and `low` isn't the same as `LOW`.
Timpl
2 years ago
How to make a timer of the same wiring from this project?
Anonymous user
2 years ago
The millis() returns the time since the code started. You can take the output to turn into numbers.
Anonymous user
2 years ago
Hello, I don't think the schematic used in this post is correct because the connections don't match the pin assignments in the code. The datasheet shows that pin 1 of the LED display (the pink wire connecting pin 6 on Arduino in the schematic used here) is for Digit 1 but the variable D1 (the blue wire connection to pin 9 of Arduino in the schematic) indicating digit 1 of LED in the code is connected to pin 16 of the display. Please take a note of this! Also, the pin numbering vary with the LED display. Make sure to check the datasheet for the right configuration. Link to the datasheet of the sparkfun seven segment LED used in this post - https://www.sparkfun.com/datasheets/Components/LED/7-Segment/YSD-439AB4B-35.pdf
Anonymous user
2 years ago
How can I do to put 10 or 11 or 12 or 24?
Anonymous user
2 years ago
Your settings for the delay in your code is incorrect for the first 3-4 characters. You have delay(1) and it should be delay(1000). (for those wondering why it may not be working). Also, your code was incorrect for 0 through 3. Given your diagram of the digits at the top of the code... "HIGH" means "OFF". That being the case, "ZERO" should have "G" set as HIGH and the rest set to LOW. This will make the middle line "G" turn off and the rest A,B,C,D,E,F to LOW in which will turn on the lights needed. I have also noted in the code // to show what code "Moves" to the next digit until finaly staying on the last. GOOD WORK and the effort is MUCH appreciated! // Pin 2-8 is connected to the 7 segments of the display. int pinA = 2; int pinB = 3; int pinC = 4; int pinD = 5; int pinE = 6; int pinF = 7; int pinG = 8; int D1 = 9; int D2 = 10; int D3 = 11; int D4 = 12; // the setup routine runs once when you press reset: void setup() { // initialize the digital pins as outputs. pinMode(pinA, OUTPUT); pinMode(pinB, OUTPUT); pinMode(pinC, OUTPUT); pinMode(pinD, OUTPUT); pinMode(pinE, OUTPUT); pinMode(pinF, OUTPUT); pinMode(pinG, OUTPUT); pinMode(D1, OUTPUT); pinMode(D2, OUTPUT); pinMode(D3, OUTPUT); pinMode(D4, OUTPUT); } // the loop routine runs over and over again forever: void loop() { // THIS MOVES BELOW CODE TO THE NEXT LCD BLOCK digitalWrite(D1, HIGH); digitalWrite(D2, LOW); digitalWrite(D3, LOW); digitalWrite(D4, LOW); //THIS ENDS THE MOVEMENT AND REMAINS ON THE LAST BLOCK FOR THE FOLLOWING DIGITS //0 digitalWrite(pinA, LOW); digitalWrite(pinB, LOW); digitalWrite(pinC, LOW); digitalWrite(pinD, LOW); digitalWrite(pinE, LOW); digitalWrite(pinF, LOW); digitalWrite(pinG, HIGH); delay(1000); // wait for a second // THIS MOVES BELOW CODE TO THE NEXT LCD BLOCK digitalWrite(D1, LOW); digitalWrite(D2, HIGH); digitalWrite(D3, LOW); digitalWrite(D4, LOW); //THIS ENDS THE MOVEMENT AND REMAINS ON THE LAST BLOCK FOR THE FOLLOWING DIGITS //1 digitalWrite(pinA, HIGH); digitalWrite(pinB, LOW); digitalWrite(pinC, LOW); digitalWrite(pinD, HIGH); digitalWrite(pinE, HIGH); digitalWrite(pinF, HIGH); digitalWrite(pinG, HIGH); delay(1000); // wait for a second // THIS MOVES BELOW CODE TO THE NEXT LCD BLOCK digitalWrite(D1, LOW); digitalWrite(D2, LOW); digitalWrite(D3, HIGH); digitalWrite(D4, LOW); //THIS ENDS THE MOVEMENT AND REMAINS ON THE LAST BLOCK FOR THE FOLLOWING DIGITS //2 digitalWrite(pinA, LOW); digitalWrite(pinB, LOW); digitalWrite(pinC, HIGH); digitalWrite(pinD, LOW); digitalWrite(pinE, LOW); digitalWrite(pinF, HIGH); digitalWrite(pinG, LOW); delay(1000); // wait for a second // THIS MOVES BELOW CODE TO THE NEXT LCD BLOCK digitalWrite(D1, LOW); digitalWrite(D2, LOW); digitalWrite(D3, LOW); digitalWrite(D4, HIGH); //THIS ENDS THE MOVEMENT AND REMAINS ON THE LAST BLOCK FOR THE FOLLOWING DIGITS //3 digitalWrite(pinA, LOW); digitalWrite(pinB, LOW); digitalWrite(pinC, LOW); digitalWrite(pinD, LOW); digitalWrite(pinE, HIGH); digitalWrite(pinF, HIGH); digitalWrite(pinG, LOW); delay(1000); // wait for a second //4 digitalWrite(pinA, HIGH); digitalWrite(pinB, LOW); digitalWrite(pinC, LOW); digitalWrite(pinD, HIGH); digitalWrite(pinE, HIGH); digitalWrite(pinF, LOW); digitalWrite(pinG, LOW); delay(1000); // wait for a second //5 digitalWrite(pinA, LOW); digitalWrite(pinB, HIGH); digitalWrite(pinC, LOW); digitalWrite(pinD, LOW); digitalWrite(pinE, HIGH); digitalWrite(pinF, LOW); digitalWrite(pinG, LOW); delay(1000); // wait for a second //6 digitalWrite(pinA, LOW); digitalWrite(pinB, HIGH); digitalWrite(pinC, LOW); digitalWrite(pinD, LOW); digitalWrite(pinE, LOW); digitalWrite(pinF, LOW); digitalWrite(pinG, LOW); delay(1000); // wait for a second //7 digitalWrite(pinA, LOW); digitalWrite(pinB, LOW); digitalWrite(pinC, LOW); digitalWrite(pinD, HIGH); digitalWrite(pinE, HIGH); digitalWrite(pinF, HIGH); digitalWrite(pinG, HIGH); delay(1000); // wait for a second //8 digitalWrite(pinA, LOW); digitalWrite(pinB, LOW); digitalWrite(pinC, LOW); digitalWrite(pinD, LOW); digitalWrite(pinE, LOW); digitalWrite(pinF, LOW); digitalWrite(pinG, LOW); delay(1000); // wait for a second //9 digitalWrite(pinA, LOW); digitalWrite(pinB, LOW); digitalWrite(pinC, LOW); digitalWrite(pinD, HIGH); digitalWrite(pinE, HIGH); digitalWrite(pinF, LOW); digitalWrite(pinG, LOW); delay(1000); // wait for a second }
SAnwandter1
2 years ago
Thanks for your contribution and for pointing out that mistake, I'll try to fix it. Glad you liked it!
Anonymous user
2 years ago
no resistor needed?
Anonymous user
2 years ago
Yes a resistor is needed on every anode. If you just have one on the cathode then the brightness will change depending on how many segments are on at the same time. This circuit will damage your Arduino.
Anonymous user
2 years ago
that is true,i had to get another auruino cuz the oter one was acting strange:<
Anonymous user
2 years ago
hi, i have a problem, my 0 looks like 5, 2 is A, and 3 is something like this /¨¨/ anyone has a problem like that?
Anonymous user
2 years ago
So, I followed this tutorial and in reality - my 4th digit started to burn out. Brightness decreased. But I found another tutorial that instead added 220 ohm resistors on pin 2-8. So be careful if you are going to do this tutorial and add 8x 220 ohm resistors
Anonymous user
2 years ago
Thanks for this - the video was the simplest + clearest explanation of how to control the 7-segment display. I'd just not understood it from the other projects I'd seen but this made it simple. I like your tidy garage/workshop too. All my stuff's in a heap on the kitchen table.
Anonymous user
2 years ago
my display showed this,"9999" what is wrong? ;)
Anonymous user
2 years ago
:(
Anonymous user
2 years ago
:}
Anonymous user
2 years ago
:#
Anonymous user
2 years ago
My code makes this: _ _ _ _ I_I I_I _I I I _ I_ I_ I_
Anonymous user
2 years ago
Thanks. I've made nice thermometer with your help.. https://ibb.co/zr9WmP8 https://ibb.co/fN8DSKC https://ibb.co/fdm1gYz
EmanTheBoss816
2 years ago
Wow! You should show people how to make that! That is really cool!
Anonymous user
2 years ago
how do you code 1/4 at a time? all digits are the same and i can't make them different
Anonymous user
2 years ago
What if you want it to count a button press what do you do then?
Anonymous user
2 years ago
Hello, Thank you for doing this project. I have set up my wiring on my half-size breadboard just like your schematic says, and I also copied the code with the link provided, into my Arduino program and uploaded to my Arduino UNO. However, I'm not displaying the number correctly like you show... I posted a link in a forum with pictures here https://forum.arduino.cc/index.php?topic=510062.0 Thanks for your help and time.
SAnwandter1
2 years ago
Did you watch the video for the connections?? If you did than it might be that your LED display is different than mine. It's a little hard to explain through chat, thanks for asking, sorry for the inconvenients
debanshudas23
2 years ago
Don;t we have to put resistors?
keegan656
2 years ago
great project for beginners . thanks alot
supercrashmaster3000
2 years ago
Good idea, try to update the project by adding a LCD to make a sort of visual display. (Try making it a game)
Kentoy
2 years ago
How to make countdown using this code sir?
Anonymous user
2 years ago
Nice detailed project. For controllers with more limited I/O, the SPI bus is a good alternative. There is an SPI-controlled backpack with 4 7-segement digits at 1wattlabs.com
Anonymous user
2 years ago
No current limiting resistors for the LEDs?
Anonymous user
2 years ago
JUST HAD TO LOG IN TO SAY A MASSIVE THANKS FOR SHARING !!!!!! HJGE Thanks for also keeping projects like this Open-Source and free for learning and getting people into the Arduino coding world, keep inspiring folks, well done and again - a "Large & in-Charge" Thanks ! PS; oh also, i had found an IC that can be hooked up to an arduino to save on pins, but its an SMD type component, the MAX7219 - i havent yet hooked it up to an Arduino yet but will endeavour to do so soon with the help of an adapter PCB to convert it to TH (Through-hole) so it can be bread-boarded easier, im sure there are better ones out there that are TH but i dont know of any as im always buying SMD parts, plus if you ever need any help making a PCB, gimmi a shout :)
santoro96
2 years ago
This is a basic, 4-digit 7-segment display - blue in color. It has a common anode. The display features one decimal point per digit, and individually controllable apostrophe and colon points. The LEDs have a forward voltage of 3.4VDC and a max forward current of 20mA.
iFrostizz67
2 years ago
Hi, try this code: /* Showing number 0-9 on a Common Anode 7-segment LED display Displays the numbers 0-9 on the display, with one second inbetween. A --- F | | B | G | --- E | | C | | --- D This example code is in the public domain. */ // Pin 2-8 is connected to the 7 segments of the display. int pinA = 2; int pinB = 3; int pinC = 4; int pinD = 5; int pinE = 6; int pinF = 7; int pinG = 8; int D1 = 9; int D2 = 10; int D3 = 11; int D4 = 12; // the setup routine runs once when you press reset: void setup() { // initialize the digital pins as outputs. pinMode(pinA, OUTPUT); pinMode(pinB, OUTPUT); pinMode(pinC, OUTPUT); pinMode(pinD, OUTPUT); pinMode(pinE, OUTPUT); pinMode(pinF, OUTPUT); pinMode(pinG, OUTPUT); pinMode(D1, OUTPUT); pinMode(D2, OUTPUT); pinMode(D3, OUTPUT); pinMode(D4, OUTPUT); } // the loop routine runs over and over again forever: void loop() { digitalWrite(D1, LOW); digitalWrite(D2, LOW); digitalWrite(D3, LOW); digitalWrite(D4, LOW); //0 digitalWrite(pinA, HIGH); digitalWrite(pinB, HIGH); digitalWrite(pinC, HIGH); digitalWrite(pinD, HIGH); digitalWrite(pinE, HIGH); digitalWrite(pinF, HIGH); digitalWrite(pinG, LOW); delay(1000); // wait for a second //1 digitalWrite(pinA, LOW); digitalWrite(pinB, HIGH); digitalWrite(pinC, HIGH); digitalWrite(pinD, LOW); digitalWrite(pinE, LOW); digitalWrite(pinF, LOW); digitalWrite(pinG, LOW); delay(1000); // wait for a second //2 digitalWrite(pinA, HIGH); digitalWrite(pinB, HIGH); digitalWrite(pinC, LOW); digitalWrite(pinD, HIGH); digitalWrite(pinE, HIGH); digitalWrite(pinF, LOW); digitalWrite(pinG, HIGH); delay(1000); // wait for a second //3 digitalWrite(pinA, HIGH); digitalWrite(pinB, HIGH); digitalWrite(pinC, HIGH); digitalWrite(pinD, HIGH); digitalWrite(pinE, LOW); digitalWrite(pinF, LOW); digitalWrite(pinG, HIGH); delay(1000); // wait for a second //4 digitalWrite(pinA, LOW); digitalWrite(pinB, HIGH); digitalWrite(pinC, HIGH); digitalWrite(pinD, LOW); digitalWrite(pinE, LOW); digitalWrite(pinF, HIGH); digitalWrite(pinG, HIGH); delay(1000); // wait for a second //5 digitalWrite(pinA, HIGH); digitalWrite(pinB, LOW); digitalWrite(pinC, HIGH); digitalWrite(pinD, HIGH); digitalWrite(pinE, LOW); digitalWrite(pinF, HIGH); digitalWrite(pinG, HIGH); delay(1000); // wait for a second //6 digitalWrite(pinA, HIGH); digitalWrite(pinB, LOW); digitalWrite(pinC, HIGH); digitalWrite(pinD, HIGH); digitalWrite(pinE, HIGH); digitalWrite(pinF, HIGH); digitalWrite(pinG, HIGH); delay(1000); // wait for a second //7 digitalWrite(pinA, HIGH); digitalWrite(pinB, HIGH); digitalWrite(pinC, HIGH); digitalWrite(pinD, LOW); digitalWrite(pinE, LOW); digitalWrite(pinF, LOW); digitalWrite(pinG, LOW); delay(1000); // wait for a second //8 digitalWrite(pinA, HIGH); digitalWrite(pinB, HIGH); digitalWrite(pinC, HIGH); digitalWrite(pinD, HIGH); digitalWrite(pinE, HIGH); digitalWrite(pinF, HIGH); digitalWrite(pinG, HIGH); delay(1000); // wait for a second //9 digitalWrite(pinA, HIGH); digitalWrite(pinB, HIGH); digitalWrite(pinC, HIGH); digitalWrite(pinD, HIGH); digitalWrite(pinE, LOW); digitalWrite(pinF, HIGH); digitalWrite(pinG, HIGH); delay(1000); // wait for a second }
Anonymous user
2 years ago
int pinA = 2; int pinB = 3; int pinC = 4; int pinD = 5; int pinE = 6; int pinF = 7; int pinG = 8; int D1 = 9; int D2 = 10; int D3 = 11; int D4 = 12; // the setup routine runs once when you press reset: void setup() { // initialize the digital pins as outputs. pinMode(pinA, OUTPUT); pinMode(pinB, OUTPUT); pinMode(pinC, OUTPUT); pinMode(pinD, OUTPUT); pinMode(pinE, OUTPUT); pinMode(pinF, OUTPUT); pinMode(pinG, OUTPUT); pinMode(D1, OUTPUT); pinMode(D2, OUTPUT); pinMode(D3, OUTPUT); pinMode(D4, OUTPUT); } //NUMBERS: //0 void n0(){ digitalWrite(pinA, HIGH); digitalWrite(pinB, HIGH); digitalWrite(pinC, HIGH); digitalWrite(pinD, HIGH); digitalWrite(pinE, HIGH); digitalWrite(pinF, HIGH); digitalWrite(pinG, LOW); delay(1000); // wait for a second } //1 void n1(){ digitalWrite(pinA, LOW); digitalWrite(pinB, HIGH); digitalWrite(pinC, HIGH); digitalWrite(pinD, LOW); digitalWrite(pinE, LOW); digitalWrite(pinF, LOW); digitalWrite(pinG, LOW); delay(1000); // wait for a second } //2 void n2(){ digitalWrite(pinA, HIGH); digitalWrite(pinB, HIGH); digitalWrite(pinC, LOW); digitalWrite(pinD, HIGH); digitalWrite(pinE, HIGH); digitalWrite(pinF, LOW); digitalWrite(pinG, HIGH); delay(1000); // wait for a second } //3 void n3(){ digitalWrite(pinA, HIGH); digitalWrite(pinB, HIGH); digitalWrite(pinC, HIGH); digitalWrite(pinD, HIGH); digitalWrite(pinE, LOW); digitalWrite(pinF, LOW); digitalWrite(pinG, HIGH); delay(1000); // wait for a second } //4 void n4(){ digitalWrite(pinA, LOW); digitalWrite(pinB, HIGH); digitalWrite(pinC, HIGH); digitalWrite(pinD, LOW); digitalWrite(pinE, LOW); digitalWrite(pinF, HIGH); digitalWrite(pinG, HIGH); delay(1000); // wait for a second } //5 void n5(){ digitalWrite(pinA, HIGH); digitalWrite(pinB, LOW); digitalWrite(pinC, HIGH); digitalWrite(pinD, HIGH); digitalWrite(pinE, LOW); digitalWrite(pinF, HIGH); digitalWrite(pinG, HIGH); delay(1000); // wait for a second } //6 void n6(){ digitalWrite(pinA, HIGH); digitalWrite(pinB, LOW); digitalWrite(pinC, HIGH); digitalWrite(pinD, HIGH); digitalWrite(pinE, HIGH); digitalWrite(pinF, HIGH); digitalWrite(pinG, HIGH); delay(1000); // wait for a second } //7 void n7(){ digitalWrite(pinA, HIGH); digitalWrite(pinB, HIGH); digitalWrite(pinC, HIGH); digitalWrite(pinD, LOW); digitalWrite(pinE, LOW); digitalWrite(pinF, LOW); digitalWrite(pinG, LOW); delay(1000); // wait for a second } //8 void n8(){ digitalWrite(pinA, HIGH); digitalWrite(pinB, HIGH); digitalWrite(pinC, HIGH); digitalWrite(pinD, HIGH); digitalWrite(pinE, HIGH); digitalWrite(pinF, HIGH); digitalWrite(pinG, HIGH); delay(1000); // wait for a second } //9 void n9(){ digitalWrite(pinA, HIGH); digitalWrite(pinB, HIGH); digitalWrite(pinC, HIGH); digitalWrite(pinD, HIGH); digitalWrite(pinE, LOW); digitalWrite(pinF, HIGH); digitalWrite(pinG, HIGH); delay(1000); // wait for a second } void s1(){ digitalWrite(D1, LOW); digitalWrite(D2, HIGH); digitalWrite(D3, HIGH); digitalWrite(D4, HIGH); } void s2(){ digitalWrite(D1, HIGH); digitalWrite(D2, LOW); digitalWrite(D3, HIGH); digitalWrite(D4, HIGH); } void s3(){ digitalWrite(D1, HIGH); digitalWrite(D2, HIGH); digitalWrite(D3, LOW); digitalWrite(D4, HIGH); } void s4(){ digitalWrite(D1, HIGH); digitalWrite(D2, HIGH); digitalWrite(D3, HIGH); digitalWrite(D4, LOW); } // the loop routine runs over and over again forever: void loop() { s1(); n0(); s2(); n1(); s3(); n2(); s4(); n3(); s3(); n4(); s2(); n5(); s1(); n6(); s2(); n7(); s3(); n8(); s4(); n9(); }
Anonymous user
2 years ago
:) can also make with "for int i" loop.. :)
Anonymous user
2 years ago
/* Showing number 0-9 on a Common Anode 7-segment LED display Displays the numbers 0-9 on the display, with one second inbetween. A --- F | | B | G | --- E | | C | | --- D This example code is in the public domain. */ // Pin 2-8 is connected to the 7 segments of the display. int pinA = 2; int pinB = 3; int pinC = 4; int pinD = 5; int pinE = 6; int pinF = 7; int pinG = 8; int D1 = 9; int D2 = 10; int D3 = 11; int D4 = 12; // the setup routine runs once when you press reset: void setup() { // initialize the digital pins as outputs. pinMode(pinA, OUTPUT); pinMode(pinB, OUTPUT); pinMode(pinC, OUTPUT); pinMode(pinD, OUTPUT); pinMode(pinE, OUTPUT); pinMode(pinF, OUTPUT); pinMode(pinG, OUTPUT); pinMode(D1, OUTPUT); pinMode(D2, OUTPUT); pinMode(D3, OUTPUT); pinMode(D4, OUTPUT); } // the loop routine runs over and over again forever: void loop() { digitalWrite(D1, HIGH); digitalWrite(D2, LOW); digitalWrite(D3, LOW); digitalWrite(D4, LOW); //0 digitalWrite(pinA, 1); digitalWrite(pinB, 1); digitalWrite(pinC, 1); digitalWrite(pinD, 1); digitalWrite(pinE, 1); digitalWrite(pinF, 1); digitalWrite(pinG, 0); delay(1000); digitalWrite(pinA, 0); digitalWrite(pinB, 0); digitalWrite(pinC, 0); digitalWrite(pinD, 0); digitalWrite(pinE, 0); digitalWrite(pinF, 0); digitalWrite(pinG, 0); //1 digitalWrite(pinA, 0); digitalWrite(pinB, 1); digitalWrite(pinC, 1); digitalWrite(pinD, 0); digitalWrite(pinE, 0); digitalWrite(pinF, 0); digitalWrite(pinG, 0); delay(1000); // wait for a second digitalWrite(pinA, 0); digitalWrite(pinB, 0); digitalWrite(pinC, 0); digitalWrite(pinD, 0); digitalWrite(pinE, 0); digitalWrite(pinF, 0); digitalWrite(pinG, 0); //2 digitalWrite(pinA, 1); digitalWrite(pinB, 1); digitalWrite(pinC, 0); digitalWrite(pinD, 1); digitalWrite(pinE, 1); digitalWrite(pinF, 0); digitalWrite(pinG, 1); delay(1000); // wait for a second digitalWrite(pinA, 0); digitalWrite(pinB, 0); digitalWrite(pinC, 0); digitalWrite(pinD, 0); digitalWrite(pinE, 0); digitalWrite(pinF, 0); digitalWrite(pinG, 0); //3 digitalWrite(pinA, 1); digitalWrite(pinB,1); digitalWrite(pinC, 1); digitalWrite(pinD, 1); digitalWrite(pinE, 0); digitalWrite(pinF, 0); digitalWrite(pinG, 1); delay(1000); // wait for a second digitalWrite(pinA, 0); digitalWrite(pinB, 0); digitalWrite(pinC, 0); digitalWrite(pinD, 0); digitalWrite(pinE, 0); digitalWrite(pinF, 0); digitalWrite(pinG, 0); //4 digitalWrite(pinA, 0); digitalWrite(pinB, 1); digitalWrite(pinC, 1); digitalWrite(pinD, 0); digitalWrite(pinE, 0); digitalWrite(pinF, 1); digitalWrite(pinG, 1); delay(1000); // wait for a second digitalWrite(pinA, 0); digitalWrite(pinB, 0); digitalWrite(pinC, 0); digitalWrite(pinD, 0); digitalWrite(pinE, 0); digitalWrite(pinF, 0); digitalWrite(pinG, 0); //5 digitalWrite(pinA, 1); digitalWrite(pinB, 0); digitalWrite(pinC, 1); digitalWrite(pinD, 1); digitalWrite(pinE, 0); digitalWrite(pinF, 1); digitalWrite(pinG, 1); delay(1000); // wait for a second digitalWrite(pinA, 0); digitalWrite(pinB, 0); digitalWrite(pinC, 0); digitalWrite(pinD, 0); digitalWrite(pinE, 0); digitalWrite(pinF, 0); digitalWrite(pinG, 0); //6 digitalWrite(pinA, 1); digitalWrite(pinB, 0); digitalWrite(pinC, 1); digitalWrite(pinD, 1); digitalWrite(pinE, 1); digitalWrite(pinF, 1); digitalWrite(pinG, 1); delay(1000); // wait for a second digitalWrite(pinA, 0); digitalWrite(pinB, 0); digitalWrite(pinC, 0); digitalWrite(pinD, 0); digitalWrite(pinE, 0); digitalWrite(pinF, 0); digitalWrite(pinG, 0); //7 digitalWrite(pinA, 1); digitalWrite(pinB, 1); digitalWrite(pinC, 1); digitalWrite(pinD, 0); digitalWrite(pinE, 0); digitalWrite(pinF, 0); digitalWrite(pinG, 0); delay(1000); // wait for a second digitalWrite(pinA, 0); digitalWrite(pinB, 0); digitalWrite(pinC, 0); digitalWrite(pinD, 0); digitalWrite(pinE, 0); digitalWrite(pinF, 0); digitalWrite(pinG, 0); //8 digitalWrite(pinA, 1); digitalWrite(pinB, 1); digitalWrite(pinC, 1); digitalWrite(pinD, 1); digitalWrite(pinE, 1); digitalWrite(pinF, 1); digitalWrite(pinG, 1); delay(1000); // wait for a second digitalWrite(pinA, 0); digitalWrite(pinB, 0); digitalWrite(pinC, 0); digitalWrite(pinD, 0); digitalWrite(pinE, 0); digitalWrite(pinF, 0); digitalWrite(pinG, 0); //9 digitalWrite(pinA, 1); digitalWrite(pinB, 1); digitalWrite(pinC, 1); digitalWrite(pinD, 1); digitalWrite(pinE, 0); digitalWrite(pinF, 1); digitalWrite(pinG, 1); delay(1000); // wait for a second digitalWrite(pinA, 0); digitalWrite(pinB, 0); digitalWrite(pinC, 0); digitalWrite(pinD, 0); digitalWrite(pinE, 0); digitalWrite(pinF, 0); digitalWrite(pinG, 0); }
Anonymous user
2 years ago
this thing does not work at all
Anonymous user
2 years ago
remember that a second is 100 milliseconds and the delay function uses milliseconds
Anonymous user
2 years ago
CAN YOU HELP BEGINNER HERE.. WHAT IS THE CODE IF I WHAT TO SHOW THE NUMBER 10,12,..OR 4 DIGITS AT SAME TIME IN DEFFERENT NUMBERS.. THANKS
Anonymous user
2 years ago
I guess this setup is too complicated to use as a 2 player scorer.. ? D1 + D2 digits for Player 1, D3 + D4 digits for Player 2 /with two buttons Though there is only the Analog 13 for one button, so that's the first problem, i guess.. where does the 2nd button go into? Then programming it, you'd have to change D2 or D4 depending on the button that is pressed, at least for the first 9 times, though its not a matter of just changing an integer. Each time you'd have to change what is displayed by either digit. const int buttonPin1 = 13; const int buttonPin2 = ?; void setup() { pinMode(buttonPin1, INPUT); pinMode(buttonPin2, INPUT); digitalWrite(D1, LOW); digitalWrite(D2, LOW); digitalWrite(D3, LOW); digitalWrite(D4, LOW) digitalWrite(pinA, HIGH); digitalWrite(pinB, HIGH); digitalWrite(pinC, HIGH); digitalWrite(pinD, HIGH); digitalWrite(pinE, HIGH); digitalWrite(pinF, HIGH); digitalWrite(pinG, LOW); } void press1() { if (buttonState == HIGH) { digitalWrite(pinA, LOW); digitalWrite(pinB, HIGH); digitalWrite(pinC, HIGH); digitalWrite(pinD, LOW); digitalWrite(pinE, LOW); digitalWrite(pinF, LOW); digitalWrite(pinG, LOW); digitalWrite(D1, LOW); digitalWrite(D2, HIGH); digitalWrite(D3, LOW); digitalWrite(D4, LOW) void press2(); } } void press2() { if (buttonState == HIGH) { ... ... .. .. void press3(); } } Something like that? Though there has to be any easier way to go about it? I guess it might be easier with a backpack?
Anonymous user
2 years ago
Hi Gorebert, I did a project like that in the past, I used a library saying that there were two 2 digits displays. I pass you all the programming
Anonymous user
2 years ago
Cheers
Anonymous user
2 years ago
//0 digitalWrite(pinA, LOW); digitalWrite(pinB, HIGH); digitalWrite(pinC, LOW); digitalWrite(pinD, LOW); digitalWrite(pinE, HIGH); digitalWrite(pinF, LOW); digitalWrite(pinG, LOW); delay(1); // wait for a second Are you sure this is 0?
Anonymous user
2 years ago
well...in the code you wrote it is 0 but it is 5/S.and 2 is A
Anonymous user
2 years ago
Yeah but he was thinking it corresponded to the 0 caracter
Anonymous user
2 years ago
//0 digitalWrite(pinA, LOW); digitalWrite(pinB, LOW); digitalWrite(pinC, LOW); digitalWrite(pinD, LOW); digitalWrite(pinE, LOW); digitalWrite(pinF, LOW); digitalWrite(pinG, HIGH); delay(1); // wait for a second This is 0. I tested. Good luck :D
SAnwandter1
2 years ago
Yes I'm sure. Everything in arduino language, if a line has this // it completely neutralizes what it's saying, that's why it's in gray
SAnwandter1
2 years ago
Yes, and?? I made it say santi because it's an abbreviation of my name but you can change it. In the code there is an example of a 7 segment number an it has all the letters you can simply change the code according to what you want to write
Anonymous user
2 years ago
I mean this code draws something like this — |_ _ |
Anonymous user
2 years ago
Just odered my first adruino - looking forward to learning. This looks like a good project to get my feet wet, make sure I can compile etc... kind of a "Hello, World" of embedded projects :-)
gilangkentjana
2 years ago
I second this. On my first try, I tried making it countdown from 9 to 0, and left it for a while to do other stuff. When I came back, the display was kind of hot
Anonymous user
2 years ago
Put some resistors between the Arduino and the 4 Digit pins or (not and) on the 8 segment lines. Pro tip I used back in the day, use a potentiometer on a lit segment and when you have it at the right level of dim then use an ohm meter on the pot and replace it with a resister as close as you can.
Anonymous user
2 years ago
If you are going to do that, make the illusion of scrolling. Also add resistors for the digit (pin 2-8), otherwise your display might burn out
Anonymous user
2 years ago
There should be a current limiting resistor of at least 100 ohms attached to the ground lead on this LED array to keep it from burning up.
shangyboyisawsome
2 years ago
thx for this Arduino project tutorial!
arduinowiec2005
2 years ago
cool project
Anonymous user
2 years ago
do u really think it's the right code? it's using 4digit 7segments but i think the code is for 1x4 7segments
Anonymous user
2 years ago
thanku so much
Emith1
2 years ago
it is not working f***.............!
Anonymous user
2 years ago
wrong pins:*
pajoll1978
2 years ago
CREATO IL NOME DI MIO FIGLIO ERSI LA MIA PRIMA PROGRAMMAZIONE Showing number 0-9 on a Common Anode 7-segment LED display Displays the numbers 0-9 on the display, with one second inbetween. A --- F | | B | G | --- E | | C | | --- D This example code is in the public domain. */ // Pin 2-8 is connected to the 7 segments of the display. int pinA = 2; int pinB = 3; int pinC = 4; int pinD = 5; int pinE = 6; int pinF = 7; int pinG = 8; int D1 = 9; int D2 = 10; int D3 = 11; int D4 = 12; int D5 = 13; // the setup routine runs once when you press reset: void setup() { // initialize the digital pins as outputs. pinMode(pinA, OUTPUT); pinMode(pinB, OUTPUT); pinMode(pinC, OUTPUT); pinMode(pinD, OUTPUT); pinMode(pinE, OUTPUT); pinMode(pinF, OUTPUT); pinMode(pinG, OUTPUT); pinMode(D1, OUTPUT); pinMode(D2, OUTPUT); pinMode(D3, OUTPUT); pinMode(D4, OUTPUT); pinMode(D5, OUTPUT); } // the loop routine runs over and over again forever: void loop() { digitalWrite(D1, LOW); //SESIONI 1 digitalWrite(D2, LOW); //SESIONI 1 digitalWrite(D3, HIGH); //SESIONI 1 digitalWrite(D4, LOW); //SESIONI 1 digitalWrite(D5, LOW); //SESIONI 1 //0 digitalWrite(pinA, LOW); // NDIZEN TE KATRA BARRAT HORIZONTALE LART digitalWrite(pinB, LOW); //NDIZEN TE KATRA BARRAT VERTIKALE LARTE DJATHTAS digitalWrite(pinC, LOW); //NDIZEN TE KATRA BARRAT VERTIKALE POSHT DJATHTAS digitalWrite(pinD, LOW); // NDIZEN TE KATRA BARRAT HORIZONTALE POSHT digitalWrite(pinE, HIGH); // NDIZEN TE KATRA BARRAT VERTIKALE MAJTAS POSHTE digitalWrite(pinF, HIGH); //NDIZEN TE KATRA BARRAT VERTIKALE MAJTAS SIPER digitalWrite(pinG, LOW); //NDIZEN TE KATRA BARRAT HORIZONTALE NE MES delay(1); // wait for a second digitalWrite(D1, LOW); //SEIONI 2 KUADRATI 1 digitalWrite(D2, HIGH); //SEIONI 2 KUADRATI 2 digitalWrite(D3, HIGH); //SEIONI 2 KUARATI 3 digitalWrite(D4, HIGH); //SEIONI 2 KUADRATI4 //1 digitalWrite(pinA, HIGH); // NDIZEN TE KATRA BARRAT HORIZONTALE LART digitalWrite(pinB, LOW); //NDIZEN TE KATRA BARRAT VERTIKALE LARTE DJATHTAS digitalWrite(pinC, LOW); //NDIZEN TE KATRA BARRAT VERTIKALE POSHT DJATHTAS digitalWrite(pinD, HIGH); // NDIZEN TE KATRA BARRAT HORIZONTALE POSHT digitalWrite(pinE, LOW); // NDIZEN TE KATRA BARRAT VERTIKALE MAJTAS POSHTE digitalWrite(pinF, HIGH); //NDIZEN TE KATRA BARRAT VERTIKALE MAJTAS SIPER digitalWrite(pinG, HIGH); //NDIZEN TE KATRA BARRAT HORIZONTALE NE MES delay(1); // wait for a second digitalWrite(D1, HIGH); // SESIONI 3 KUADRATI 1 digitalWrite(D2, LOW); // SESIONI 3 KUADRATI 2 digitalWrite(D3, HIGH); // SESIONI 3 KUADRATI 3 digitalWrite(D4, HIGH); //SESIONI 3 KUADRATI 4 //2 digitalWrite(pinA, HIGH); // NDIZEN TE KATRA BARRAT HORIZONTALE LART digitalWrite(pinB, HIGH); //NDIZEN TE KATRA BARRAT VERTIKALE LARTE DJATHTAS digitalWrite(pinC, HIGH); //NDIZEN TE KATRA BARRAT VERTIKALE POSHT DJATHTAS digitalWrite(pinD, LOW); // NDIZEN TE KATRA BARRAT HORIZONTALE POSHT digitalWrite(pinE, LOW); // NDIZEN TE KATRA BARRAT VERTIKALE MAJTAS POSHTE digitalWrite(pinF, HIGH); //NDIZEN TE KATRA BARRAT VERTIKALE MAJTAS SIPER digitalWrite(pinG, HIGH); //NDIZEN TE KATRA BARRAT HORIZONTALE NE MES delay(1); // wait for a second digitalWrite(D1, HIGH); // KUADRATI 1 SESIONI4 digitalWrite(D2, HIGH); // KUADRATI 2 SESIONI 4 digitalWrite(D3, LOW); // KUADRATI 3 SESIONI 4 digitalWrite(D4, HIGH); // KUADRATI 4 SESIONI4 //3 digitalWrite(pinA, HIGH); // NDIZEN TE KATRA BARRAT HORIZONTALE LART digitalWrite(pinB, LOW); //NDIZEN TE KATRA BARRAT VERTIKALE LARTE DJATHTAS digitalWrite(pinC, HIGH); //NDIZEN TE KATRA BARRAT VERTIKALE POSHT DJATHTAS digitalWrite(pinD, HIGH); // NDIZEN TE KATRA BARRAT HORIZONTALE POSHT digitalWrite(pinE, LOW); // NDIZEN TE KATRA BARRAT VERTIKALE MAJTAS POSHTE digitalWrite(pinF, HIGH); //NDIZEN TE KATRA BARRAT VERTIKALE MAJTAS SIPER digitalWrite(pinG, HIGH); //NDIZEN TE KATRA BARRAT HORIZONTALE NE MES delay(1); // wait for a second /*
Anonymous user
2 years ago
This was my very first project. Learnt heaps, made mistakes, proud of the finished product. Thank you:)
Anonymous user
2 years ago
Would it be possible to control this with the remote included in the elegoo super starter kit? If so how?
Anonymous user
2 years ago
To anyone who just sees random stuff showing up, switch every D1 - D4 pin to the opposite high or low. If that changes something, do the same for every individual LED. here's my modified code : /* Showing number 0-9 on a Common Anode 7-segment LED display Displays the numbers 0-9 on the display, with one second in between. A --- F | | B | G | --- E | | C | | --- D This example code is in the public domain. */ // Pin 2-8 is connected to the 7 segments of the display. int pinA = 2; int pinB = 3; int pinC = 4; int pinD = 5; int pinE = 6; int pinF = 7; int pinG = 8; int D1 = 9; int D2 = 10; int D3 = 11; int D4 = 12; // the setup routine runs once when you press reset: void setup() { // initialize the digital pins as outputs. pinMode(pinA, OUTPUT); pinMode(pinB, OUTPUT); pinMode(pinC, OUTPUT); pinMode(pinD, OUTPUT); pinMode(pinE, OUTPUT); pinMode(pinF, OUTPUT); pinMode(pinG, OUTPUT); pinMode(D1, OUTPUT); pinMode(D2, OUTPUT); pinMode(D3, OUTPUT); pinMode(D4, OUTPUT); } // the loop routine runs over and over again forever: void loop() { digitalWrite(D1, LOW); digitalWrite(D2, HIGH); digitalWrite(D3, HIGH); digitalWrite(D4, HIGH); //0 digitalWrite(pinA, HIGH); digitalWrite(pinB, HIGH); digitalWrite(pinC, HIGH); digitalWrite(pinD, HIGH); digitalWrite(pinE, HIGH); digitalWrite(pinF, HIGH); digitalWrite(pinG, LOW); delay(1); // wait for a second digitalWrite(D1, HIGH); digitalWrite(D2, LOW); digitalWrite(D3, HIGH); digitalWrite(D4, HIGH); //1 digitalWrite(pinA, LOW); digitalWrite(pinB, HIGH); digitalWrite(pinC, HIGH); digitalWrite(pinD, LOW); digitalWrite(pinE, LOW); digitalWrite(pinF, LOW); digitalWrite(pinG, LOW); delay(1); // wait for a second digitalWrite(D1, HIGH); digitalWrite(D2, HIGH); digitalWrite(D3, LOW); digitalWrite(D4, HIGH); //2 digitalWrite(pinA, LOW); digitalWrite(pinB, HIGH); digitalWrite(pinC, HIGH); digitalWrite(pinD, LOW); digitalWrite(pinE, LOW); digitalWrite(pinF, LOW); digitalWrite(pinG, LOW); delay(1); // wait for a second digitalWrite(D1, HIGH); digitalWrite(D2, HIGH); digitalWrite(D3, HIGH); digitalWrite(D4, LOW); //3 digitalWrite(pinA, LOW); digitalWrite(pinB, HIGH); digitalWrite(pinC, HIGH); digitalWrite(pinD, LOW); digitalWrite(pinE, LOW); digitalWrite(pinF, LOW); digitalWrite(pinG, LOW); delay(1); // wait for a second /* //4 digitalWrite(pinA, HIGH); digitalWrite(pinB, LOW); digitalWrite(pinC, LOW); digitalWrite(pinD, HIGH); digitalWrite(pinE, HIGH); digitalWrite(pinF, LOW); digitalWrite(pinG, LOW); delay(1000); // wait for a second //5 digitalWrite(pinA, LOW); digitalWrite(pinB, HIGH); digitalWrite(pinC, LOW); digitalWrite(pinD, LOW); digitalWrite(pinE, HIGH); digitalWrite(pinF, LOW); digitalWrite(pinG, LOW); delay(1000); // wait for a second //6 digitalWrite(pinA, LOW); digitalWrite(pinB, HIGH); digitalWrite(pinC, LOW); digitalWrite(pinD, LOW); digitalWrite(pinE, LOW); digitalWrite(pinF, LOW); digitalWrite(pinG, LOW); delay(1000); // wait for a second //7 digitalWrite(pinA, LOW); digitalWrite(pinB, LOW); digitalWrite(pinC, LOW); digitalWrite(pinD, HIGH); digitalWrite(pinE, HIGH); digitalWrite(pinF, HIGH); digitalWrite(pinG, HIGH); delay(1000); // wait for a second //8 digitalWrite(pinA, LOW); digitalWrite(pinB, LOW); digitalWrite(pinC, LOW); digitalWrite(pinD, LOW); digitalWrite(pinE, LOW); digitalWrite(pinF, LOW); digitalWrite(pinG, LOW); delay(1000); // wait for a second //9 digitalWrite(pinA, LOW); digitalWrite(pinB, LOW); digitalWrite(pinC, LOW); digitalWrite(pinD, HIGH); digitalWrite(pinE, HIGH); digitalWrite(pinF, LOW); digitalWrite(pinG, LOW); delay(1000); // wait for a second */ }
Anonymous user
2 years ago
Thanks, it was a great explanation!!! I'm new to arduino and used this as a start to create a scoreboard. The explanation of pins work great. For those complaining the code doesn't work, you should check how the wires are connected. And yes, you should add some resistors for the Digits, pretty simple to do if you look at any other video that uses them. I tried to clean up the code a little bit by moving away the logic for number printing, but wanted to keep the code legible for non coders, here's the working code (WARNING, check the PIN numbers at the top and how you connected them to your arduino): /* Showing number 0-9 on a Common Anode 7-segment LED display Displays the numbers 0-9 on the display, with one second in between. A --- F | | B | G | --- E | | C | | --- D This example code is in the public domain. High == ON LOW == OFF */ // Pin 2-8 is connected to the 7 segments of the display. (check the numbers besides each pin with the way you connected the wires). int pinA = 6; int pinB = 8; int pinC = 12; int pinD = 10; int pinE = 9; int pinF = 7; int pinG = 13; int D1 = 2; int D2 = 3; int D3 = 4; int D4 = 5; int dot = 11; // the setup routine runs once when you press reset: void setup() { // initialize the digital pins as outputs. pinMode(pinA, OUTPUT); pinMode(pinB, OUTPUT); pinMode(pinC, OUTPUT); pinMode(pinD, OUTPUT); pinMode(pinE, OUTPUT); pinMode(pinF, OUTPUT); pinMode(pinG, OUTPUT); pinMode(D1, OUTPUT); pinMode(D2, OUTPUT); pinMode(D3, OUTPUT); pinMode(D4, OUTPUT); pinMode(dot, OUTPUT); } // the loop routine runs over and over again forever: void loop() { digitalWrite(D1, LOW); digitalWrite(D2, LOW); digitalWrite(D3, LOW); digitalWrite(D4, LOW); digitalWrite(dot, LOW); printZero(); delay(500); printOne(); delay(500); printTwo(); delay(500); printThree(); delay(500); printFour(); delay(500); printFive(); delay(500); printSix(); delay(500); printSeven(); delay(500); printEight(); delay(500); printNine(); delay(500); } void printZero() { digitalWrite(pinA, HIGH); digitalWrite(pinB, HIGH); digitalWrite(pinC, HIGH); digitalWrite(pinD, HIGH); digitalWrite(pinE, HIGH); digitalWrite(pinF, HIGH); digitalWrite(pinG, LOW); } void printOne() { digitalWrite(pinA, LOW); digitalWrite(pinB, HIGH); digitalWrite(pinC, HIGH); digitalWrite(pinD, LOW); digitalWrite(pinE, LOW); digitalWrite(pinF, LOW); digitalWrite(pinG, LOW); } void printTwo() { digitalWrite(pinA, HIGH); digitalWrite(pinB, HIGH); digitalWrite(pinC, LOW); digitalWrite(pinD, HIGH); digitalWrite(pinE, HIGH); digitalWrite(pinF, LOW); digitalWrite(pinG, HIGH); } void printThree() { digitalWrite(pinA, HIGH); digitalWrite(pinB, HIGH); digitalWrite(pinC, HIGH); digitalWrite(pinD, HIGH); digitalWrite(pinE, LOW); digitalWrite(pinF, LOW); digitalWrite(pinG, HIGH); } void printFour() { digitalWrite(pinA, LOW); digitalWrite(pinB, HIGH); digitalWrite(pinC, HIGH); digitalWrite(pinD, LOW); digitalWrite(pinE, LOW); digitalWrite(pinF, HIGH); digitalWrite(pinG, HIGH); } void printFive() { digitalWrite(pinA, HIGH); digitalWrite(pinB, LOW); digitalWrite(pinC, HIGH); digitalWrite(pinD, HIGH); digitalWrite(pinE, LOW); digitalWrite(pinF, HIGH); digitalWrite(pinG, HIGH); } void printSix() { digitalWrite(pinA, HIGH); digitalWrite(pinB, LOW); digitalWrite(pinC, HIGH); digitalWrite(pinD, HIGH); digitalWrite(pinE, HIGH); digitalWrite(pinF, HIGH); digitalWrite(pinG, HIGH); } void printSeven() { digitalWrite(pinA, HIGH); digitalWrite(pinB, HIGH); digitalWrite(pinC, HIGH); digitalWrite(pinD, LOW); digitalWrite(pinE, LOW); digitalWrite(pinF, LOW); digitalWrite(pinG, LOW); } void printEight() { digitalWrite(pinA, HIGH); digitalWrite(pinB, HIGH); digitalWrite(pinC, HIGH); digitalWrite(pinD, HIGH); digitalWrite(pinE, HIGH); digitalWrite(pinF, HIGH); digitalWrite(pinG, HIGH); } void printNine() { digitalWrite(pinA, HIGH); digitalWrite(pinB, HIGH); digitalWrite(pinC, HIGH); digitalWrite(pinD, LOW); digitalWrite(pinE, LOW); digitalWrite(pinF, HIGH); digitalWrite(pinG, HIGH); }
335598
2 years ago
this is cool I want to make this
anteklego2007
2 years ago
don't work like this _ | | _
Anonymous user
2 years ago
I want to know how can i put DHT11 readings to show the temperature on the screen
Anonymous user
2 years ago
For people interested, I wrote this code to simplify all this (same connections). const int zero[7] = {HIGH, HIGH, HIGH, HIGH, HIGH, HIGH, LOW}; const int one[7] = {LOW, HIGH, HIGH, LOW, LOW, LOW, LOW}; const int two[7] = {HIGH, HIGH, LOW, HIGH, HIGH, LOW, HIGH}; const int three[7] = {HIGH, HIGH, HIGH, HIGH, LOW, LOW, HIGH}; const int four[7] = {LOW, HIGH, HIGH, LOW, LOW, HIGH, HIGH}; const int five[7] = {HIGH, LOW, HIGH, HIGH, LOW, HIGH, HIGH}; const int six[7] = {HIGH, LOW, HIGH, HIGH, HIGH, HIGH, HIGH}; const int seven[7] = {HIGH, HIGH, HIGH, LOW, LOW, LOW, LOW}; const int eight[7] = {HIGH, HIGH, HIGH, HIGH, HIGH, HIGH, HIGH}; const int nine[7] = {HIGH, HIGH, HIGH, LOW, LOW, HIGH, HIGH}; const int* digits[10] = {zero, one, two, three, four, five, six, seven, eight, nine}; const int firstSegmentPin = 2; const int lastSegmentPin = 8; const int firstMuxPin = 9; const int lastMuxPin = 12; const int displayDigitCount = 4; void resetDisplay() { for (int i = firstMuxPin; i <= lastMuxPin; ++i) { digitalWrite(i, HIGH); } } void writeDisplayDigit(int value, int index) { for (int i = 0; i < 7; ++i) { digitalWrite(i + firstSegmentPin, digits[value][i]); } digitalWrite(index + firstMuxPin, LOW); } void writeDisplay(int values[displayDigitCount]) { for (int i = 0; i < displayDigitCount; ++i) { resetDisplay(); writeDisplayDigit(values[i], i); delay(1); } } // the setup routine runs once when you press reset: void setup() { for (int i = firstSegmentPin; i <= lastMuxPin; ++i) { pinMode(i, OUTPUT); // initialize the digital pins as outputs. } resetDisplay(); } // the loop routine runs over and over again forever: void loop() { int values[4] = {1,3,3,7}; writeDisplay(values); }
manpreet13
2 years ago
hi i want to , integrate the 4 digit 7 segment display with ultrasonic sensor, can someone help me, i just write the code for ultrasonic sensor and buzzer, when a object is in the range of sensor the the buzzer make sound, but i dont able to show on display the cm of distance to the object
Anonymous user
2 years ago
do u really think it's the right code? it's using 4digit 7segments but i think the code is for 1x4 7segments
Anonymous user
3 years ago
how do you code 1/4 at a time? all digits are the same and i can't make them different
Anonymous user
3 years ago
Hello, I don't think the schematic used in this post is correct because the connections don't match the pin assignments in the code. The datasheet shows that pin 1 of the LED display (the pink wire connecting pin 6 on Arduino in the schematic used here) is for Digit 1 but the variable D1 (the blue wire connection to pin 9 of Arduino in the schematic) indicating digit 1 of LED in the code is connected to pin 16 of the display. Please take a note of this! Also, the pin numbering vary with the LED display. Make sure to check the datasheet for the right configuration. Link to the datasheet of the sparkfun seven segment LED used in this post - https://www.sparkfun.com/datasheets/Components/LED/7-Segment/YSD-439AB4B-35.pdf
Anonymous user
3 years ago
What if you want it to count a button press what do you do then?
pajoll1978
3 years ago
CREATO IL NOME DI MIO FIGLIO ERSI LA MIA PRIMA PROGRAMMAZIONE Showing number 0-9 on a Common Anode 7-segment LED display Displays the numbers 0-9 on the display, with one second inbetween. A --- F | | B | G | --- E | | C | | --- D This example code is in the public domain. */ // Pin 2-8 is connected to the 7 segments of the display. int pinA = 2; int pinB = 3; int pinC = 4; int pinD = 5; int pinE = 6; int pinF = 7; int pinG = 8; int D1 = 9; int D2 = 10; int D3 = 11; int D4 = 12; int D5 = 13; // the setup routine runs once when you press reset: void setup() { // initialize the digital pins as outputs. pinMode(pinA, OUTPUT); pinMode(pinB, OUTPUT); pinMode(pinC, OUTPUT); pinMode(pinD, OUTPUT); pinMode(pinE, OUTPUT); pinMode(pinF, OUTPUT); pinMode(pinG, OUTPUT); pinMode(D1, OUTPUT); pinMode(D2, OUTPUT); pinMode(D3, OUTPUT); pinMode(D4, OUTPUT); pinMode(D5, OUTPUT); } // the loop routine runs over and over again forever: void loop() { digitalWrite(D1, LOW); //SESIONI 1 digitalWrite(D2, LOW); //SESIONI 1 digitalWrite(D3, HIGH); //SESIONI 1 digitalWrite(D4, LOW); //SESIONI 1 digitalWrite(D5, LOW); //SESIONI 1 //0 digitalWrite(pinA, LOW); // NDIZEN TE KATRA BARRAT HORIZONTALE LART digitalWrite(pinB, LOW); //NDIZEN TE KATRA BARRAT VERTIKALE LARTE DJATHTAS digitalWrite(pinC, LOW); //NDIZEN TE KATRA BARRAT VERTIKALE POSHT DJATHTAS digitalWrite(pinD, LOW); // NDIZEN TE KATRA BARRAT HORIZONTALE POSHT digitalWrite(pinE, HIGH); // NDIZEN TE KATRA BARRAT VERTIKALE MAJTAS POSHTE digitalWrite(pinF, HIGH); //NDIZEN TE KATRA BARRAT VERTIKALE MAJTAS SIPER digitalWrite(pinG, LOW); //NDIZEN TE KATRA BARRAT HORIZONTALE NE MES delay(1); // wait for a second digitalWrite(D1, LOW); //SEIONI 2 KUADRATI 1 digitalWrite(D2, HIGH); //SEIONI 2 KUADRATI 2 digitalWrite(D3, HIGH); //SEIONI 2 KUARATI 3 digitalWrite(D4, HIGH); //SEIONI 2 KUADRATI4 //1 digitalWrite(pinA, HIGH); // NDIZEN TE KATRA BARRAT HORIZONTALE LART digitalWrite(pinB, LOW); //NDIZEN TE KATRA BARRAT VERTIKALE LARTE DJATHTAS digitalWrite(pinC, LOW); //NDIZEN TE KATRA BARRAT VERTIKALE POSHT DJATHTAS digitalWrite(pinD, HIGH); // NDIZEN TE KATRA BARRAT HORIZONTALE POSHT digitalWrite(pinE, LOW); // NDIZEN TE KATRA BARRAT VERTIKALE MAJTAS POSHTE digitalWrite(pinF, HIGH); //NDIZEN TE KATRA BARRAT VERTIKALE MAJTAS SIPER digitalWrite(pinG, HIGH); //NDIZEN TE KATRA BARRAT HORIZONTALE NE MES delay(1); // wait for a second digitalWrite(D1, HIGH); // SESIONI 3 KUADRATI 1 digitalWrite(D2, LOW); // SESIONI 3 KUADRATI 2 digitalWrite(D3, HIGH); // SESIONI 3 KUADRATI 3 digitalWrite(D4, HIGH); //SESIONI 3 KUADRATI 4 //2 digitalWrite(pinA, HIGH); // NDIZEN TE KATRA BARRAT HORIZONTALE LART digitalWrite(pinB, HIGH); //NDIZEN TE KATRA BARRAT VERTIKALE LARTE DJATHTAS digitalWrite(pinC, HIGH); //NDIZEN TE KATRA BARRAT VERTIKALE POSHT DJATHTAS digitalWrite(pinD, LOW); // NDIZEN TE KATRA BARRAT HORIZONTALE POSHT digitalWrite(pinE, LOW); // NDIZEN TE KATRA BARRAT VERTIKALE MAJTAS POSHTE digitalWrite(pinF, HIGH); //NDIZEN TE KATRA BARRAT VERTIKALE MAJTAS SIPER digitalWrite(pinG, HIGH); //NDIZEN TE KATRA BARRAT HORIZONTALE NE MES delay(1); // wait for a second digitalWrite(D1, HIGH); // KUADRATI 1 SESIONI4 digitalWrite(D2, HIGH); // KUADRATI 2 SESIONI 4 digitalWrite(D3, LOW); // KUADRATI 3 SESIONI 4 digitalWrite(D4, HIGH); // KUADRATI 4 SESIONI4 //3 digitalWrite(pinA, HIGH); // NDIZEN TE KATRA BARRAT HORIZONTALE LART digitalWrite(pinB, LOW); //NDIZEN TE KATRA BARRAT VERTIKALE LARTE DJATHTAS digitalWrite(pinC, HIGH); //NDIZEN TE KATRA BARRAT VERTIKALE POSHT DJATHTAS digitalWrite(pinD, HIGH); // NDIZEN TE KATRA BARRAT HORIZONTALE POSHT digitalWrite(pinE, LOW); // NDIZEN TE KATRA BARRAT VERTIKALE MAJTAS POSHTE digitalWrite(pinF, HIGH); //NDIZEN TE KATRA BARRAT VERTIKALE MAJTAS SIPER digitalWrite(pinG, HIGH); //NDIZEN TE KATRA BARRAT HORIZONTALE NE MES delay(1); // wait for a second /*
watro
3 years ago
Thanks, it was a great explanation!!! I'm new to arduino and used this as a start to create a scoreboard. The explanation of pins work great. For those complaining the code doesn't work, you should check how the wires are connected. And yes, you should add some resistors for the Digits, pretty simple to do if you look at any other video that uses them. I tried to clean up the code a little bit by moving away the logic for number printing, but wanted to keep the code legible for non coders, here's the working code (WARNING, check the PIN numbers at the top and how you connected them to your arduino): /* Showing number 0-9 on a Common Anode 7-segment LED display Displays the numbers 0-9 on the display, with one second in between. A --- F | | B | G | --- E | | C | | --- D This example code is in the public domain. High == ON LOW == OFF */ // Pin 2-8 is connected to the 7 segments of the display. (check the numbers besides each pin with the way you connected the wires). int pinA = 6; int pinB = 8; int pinC = 12; int pinD = 10; int pinE = 9; int pinF = 7; int pinG = 13; int D1 = 2; int D2 = 3; int D3 = 4; int D4 = 5; int dot = 11; // the setup routine runs once when you press reset: void setup() { // initialize the digital pins as outputs. pinMode(pinA, OUTPUT); pinMode(pinB, OUTPUT); pinMode(pinC, OUTPUT); pinMode(pinD, OUTPUT); pinMode(pinE, OUTPUT); pinMode(pinF, OUTPUT); pinMode(pinG, OUTPUT); pinMode(D1, OUTPUT); pinMode(D2, OUTPUT); pinMode(D3, OUTPUT); pinMode(D4, OUTPUT); pinMode(dot, OUTPUT); } // the loop routine runs over and over again forever: void loop() { digitalWrite(D1, LOW); digitalWrite(D2, LOW); digitalWrite(D3, LOW); digitalWrite(D4, LOW); digitalWrite(dot, LOW); printZero(); delay(500); printOne(); delay(500); printTwo(); delay(500); printThree(); delay(500); printFour(); delay(500); printFive(); delay(500); printSix(); delay(500); printSeven(); delay(500); printEight(); delay(500); printNine(); delay(500); } void printZero() { digitalWrite(pinA, HIGH); digitalWrite(pinB, HIGH); digitalWrite(pinC, HIGH); digitalWrite(pinD, HIGH); digitalWrite(pinE, HIGH); digitalWrite(pinF, HIGH); digitalWrite(pinG, LOW); } void printOne() { digitalWrite(pinA, LOW); digitalWrite(pinB, HIGH); digitalWrite(pinC, HIGH); digitalWrite(pinD, LOW); digitalWrite(pinE, LOW); digitalWrite(pinF, LOW); digitalWrite(pinG, LOW); } void printTwo() { digitalWrite(pinA, HIGH); digitalWrite(pinB, HIGH); digitalWrite(pinC, LOW); digitalWrite(pinD, HIGH); digitalWrite(pinE, HIGH); digitalWrite(pinF, LOW); digitalWrite(pinG, HIGH); } void printThree() { digitalWrite(pinA, HIGH); digitalWrite(pinB, HIGH); digitalWrite(pinC, HIGH); digitalWrite(pinD, HIGH); digitalWrite(pinE, LOW); digitalWrite(pinF, LOW); digitalWrite(pinG, HIGH); } void printFour() { digitalWrite(pinA, LOW); digitalWrite(pinB, HIGH); digitalWrite(pinC, HIGH); digitalWrite(pinD, LOW); digitalWrite(pinE, LOW); digitalWrite(pinF, HIGH); digitalWrite(pinG, HIGH); } void printFive() { digitalWrite(pinA, HIGH); digitalWrite(pinB, LOW); digitalWrite(pinC, HIGH); digitalWrite(pinD, HIGH); digitalWrite(pinE, LOW); digitalWrite(pinF, HIGH); digitalWrite(pinG, HIGH); } void printSix() { digitalWrite(pinA, HIGH); digitalWrite(pinB, LOW); digitalWrite(pinC, HIGH); digitalWrite(pinD, HIGH); digitalWrite(pinE, HIGH); digitalWrite(pinF, HIGH); digitalWrite(pinG, HIGH); } void printSeven() { digitalWrite(pinA, HIGH); digitalWrite(pinB, HIGH); digitalWrite(pinC, HIGH); digitalWrite(pinD, LOW); digitalWrite(pinE, LOW); digitalWrite(pinF, LOW); digitalWrite(pinG, LOW); } void printEight() { digitalWrite(pinA, HIGH); digitalWrite(pinB, HIGH); digitalWrite(pinC, HIGH); digitalWrite(pinD, HIGH); digitalWrite(pinE, HIGH); digitalWrite(pinF, HIGH); digitalWrite(pinG, HIGH); } void printNine() { digitalWrite(pinA, HIGH); digitalWrite(pinB, HIGH); digitalWrite(pinC, HIGH); digitalWrite(pinD, LOW); digitalWrite(pinE, LOW); digitalWrite(pinF, HIGH); digitalWrite(pinG, HIGH); }
Anonymous user
3 years ago
Would it be possible to control this with the remote included in the elegoo super starter kit? If so how?
Anonymous user
3 years ago
For people interested, I wrote this code to simplify all this (same connections). const int zero[7] = {HIGH, HIGH, HIGH, HIGH, HIGH, HIGH, LOW}; const int one[7] = {LOW, HIGH, HIGH, LOW, LOW, LOW, LOW}; const int two[7] = {HIGH, HIGH, LOW, HIGH, HIGH, LOW, HIGH}; const int three[7] = {HIGH, HIGH, HIGH, HIGH, LOW, LOW, HIGH}; const int four[7] = {LOW, HIGH, HIGH, LOW, LOW, HIGH, HIGH}; const int five[7] = {HIGH, LOW, HIGH, HIGH, LOW, HIGH, HIGH}; const int six[7] = {HIGH, LOW, HIGH, HIGH, HIGH, HIGH, HIGH}; const int seven[7] = {HIGH, HIGH, HIGH, LOW, LOW, LOW, LOW}; const int eight[7] = {HIGH, HIGH, HIGH, HIGH, HIGH, HIGH, HIGH}; const int nine[7] = {HIGH, HIGH, HIGH, LOW, LOW, HIGH, HIGH}; const int* digits[10] = {zero, one, two, three, four, five, six, seven, eight, nine}; const int firstSegmentPin = 2; const int lastSegmentPin = 8; const int firstMuxPin = 9; const int lastMuxPin = 12; const int displayDigitCount = 4; void resetDisplay() { for (int i = firstMuxPin; i <= lastMuxPin; ++i) { digitalWrite(i, HIGH); } } void writeDisplayDigit(int value, int index) { for (int i = 0; i < 7; ++i) { digitalWrite(i + firstSegmentPin, digits[value][i]); } digitalWrite(index + firstMuxPin, LOW); } void writeDisplay(int values[displayDigitCount]) { for (int i = 0; i < displayDigitCount; ++i) { resetDisplay(); writeDisplayDigit(values[i], i); delay(1); } } // the setup routine runs once when you press reset: void setup() { for (int i = firstSegmentPin; i <= lastMuxPin; ++i) { pinMode(i, OUTPUT); // initialize the digital pins as outputs. } resetDisplay(); } // the loop routine runs over and over again forever: void loop() { int values[4] = {1,3,3,7}; writeDisplay(values); }
Anonymous user
2 years ago
Would I be able to int time = millis () time == [w,x,y,z] and then somehow input those time array values into the int values [4] to create some sort of clock?
shangyboyisawsome
3 years ago
thx for this Arduino project tutorial!
Anonymous user
4 years ago
CAN YOU HELP BEGINNER HERE.. WHAT IS THE CODE IF I WHAT TO SHOW THE NUMBER 10,12,..OR 4 DIGITS AT SAME TIME IN DEFFERENT NUMBERS.. THANKS
Anonymous user
4 years ago
TWO WARNINGS: this project and code DOESN'T WORK and may it DAMAGE your Arduino and/or display! PLEASE @SAnwandter1, please fix this project to save many people hours of troubleshooting or worse; expense in damaged hardware! ——————————————————————————————————— . The wiring diagram doesn't include RESISTORS which means it may burn out your LEDs and/or Arduino. . The project's code outputs RUBBISH to the screen! See the comment and code by Maverick1701 — however even this code doesn't have the right digit code to output proper numbers! . The following code is working for me… displaying "0123" on the display. - /* A --- F | | B | G | --- E | | C | | --- D // This example code is in the public domain. // USE RESISTORS on the SEGMENT wires! (Arduino pins 2 to 8) */ // int pinA = 2; int pinB = 3; int pinC = 4; int pinD = 5; int pinE = 6; int pinF = 7; int pinG = 8; int D1 = 9; int D2 = 10; int D3 = 11; int D4 = 12; // // the setup routine runs once when you press reset: void setup() { // initialize the digital pins as outputs. pinMode(pinA, OUTPUT); pinMode(pinB, OUTPUT); pinMode(pinC, OUTPUT); pinMode(pinD, OUTPUT); pinMode(pinE, OUTPUT); pinMode(pinF, OUTPUT); pinMode(pinG, OUTPUT); pinMode(D1, OUTPUT); pinMode(D2, OUTPUT); pinMode(D3, OUTPUT); pinMode(D4, OUTPUT); } // the loop routine runs over and over again forever: void loop() { digitalWrite(D1, LOW); // NOTE that LOW denotes the active DIGIT digitalWrite(D2, HIGH); digitalWrite(D3, HIGH); digitalWrite(D4, HIGH); //0 digitalWrite(pinA, HIGH); // NOTE that HIGH denotes an active SEGMENT digitalWrite(pinB, HIGH); digitalWrite(pinC, HIGH); digitalWrite(pinD, HIGH); digitalWrite(pinE, HIGH); digitalWrite(pinF, HIGH); digitalWrite(pinG, LOW); delay(1); // wait for one millisecond digitalWrite(D1, HIGH); digitalWrite(D2, LOW); // NOTE that LOW denotes the active digit digitalWrite(D3, HIGH); digitalWrite(D4, HIGH); //1 digitalWrite(pinA, LOW); digitalWrite(pinB, HIGH); // NOTE that HIGH denotes an active SEGMENT digitalWrite(pinC, HIGH); digitalWrite(pinD, LOW); digitalWrite(pinE, LOW); digitalWrite(pinF, LOW); digitalWrite(pinG, LOW); delay(1); // wait for one millisecond digitalWrite(D1, HIGH); digitalWrite(D2, HIGH); digitalWrite(D3, LOW); // NOTE that LOW denotes the active DIGIT digitalWrite(D4, HIGH); //2 digitalWrite(pinA, HIGH); // NOTE that HIGH denotes an active SEGMENT digitalWrite(pinB, HIGH); digitalWrite(pinC, LOW); digitalWrite(pinD, HIGH); digitalWrite(pinE, HIGH); digitalWrite(pinF, LOW); digitalWrite(pinG, HIGH); delay(1); // wait for one millisecond digitalWrite(D1, HIGH); digitalWrite(D2, HIGH); digitalWrite(D3, HIGH); digitalWrite(D4, LOW); // NOTE that LOW denotes the active DIGIT //3 digitalWrite(pinA, HIGH); // NOTE that HIGH denotes an active SEGMENT digitalWrite(pinB, HIGH); digitalWrite(pinC, HIGH); digitalWrite(pinD, HIGH); digitalWrite(pinE, LOW); digitalWrite(pinF, LOW); digitalWrite(pinG, HIGH); delay(1); // wait for one millisecond // I've only include digits 0123 – I'm sure if you've got this far you can work out the rest. } -
Anonymous user
4 years ago
You could additionally create two variables one called `high` and another one called `low` to fix the issue with `HIGH` and `LOW` on `D1`, `D2`, `D3`, and `D4` like so: > _Place this on top of your code before `setup()` and `loop()`:_ ``` #define high = 0x0 #define LOW = 0x1 ``` It should work as C's variables are case-sensitive, which means `HIGH` isn't the same as `high` and `low` isn't the same as `LOW`.
siddharthhaldkar
4 years ago
thanku so much
335598
4 years ago
this is cool I want to make this
supercrashmaster3000
4 years ago
Good idea, try to update the project by adding a LCD to make a sort of visual display. (Try making it a game)
debanshudas23
4 years ago
Don;t we have to put resistors?
keegan656
5 years ago
great project for beginners . thanks alot
Anonymous user
5 years ago
So, I followed this tutorial and in reality - my 4th digit started to burn out. Brightness decreased. But I found another tutorial that instead added 220 ohm resistors on pin 2-8. So be careful if you are going to do this tutorial and add 8x 220 ohm resistors
Anonymous user
5 years ago
Im currently using Arduino and a 4 digit 7 segment display for an escape room timer. Instead of a traditional timer, that counts down from some number to zero, my timer is going to display the voltage of a battery (not actual but its going to keep the game moving as the voltage drops). The game will be a failure if the participants can not solve the room within the allotted time (I'm thinking 20-30 min) and the voltage will start dropping from 12.5V, 12.4, 12.3, 12.2... until when if falls below 11.5V the game is over. Thanks for the info, now I have a good place to start!
Anonymous user
5 years ago
I want to know how can i put DHT11 readings to show the temperature on the screen
Anonymous user
5 years ago
/* Showing number 0-9 on a Common Anode 7-segment LED display Displays the numbers 0-9 on the display, with one second inbetween. A --- F | | B | G | --- E | | C | | --- D This example code is in the public domain. */ // Pin 2-8 is connected to the 7 segments of the display. int pinA = 2; int pinB = 3; int pinC = 4; int pinD = 5; int pinE = 6; int pinF = 7; int pinG = 8; int D1 = 9; int D2 = 10; int D3 = 11; int D4 = 12; // the setup routine runs once when you press reset: void setup() { // initialize the digital pins as outputs. pinMode(pinA, OUTPUT); pinMode(pinB, OUTPUT); pinMode(pinC, OUTPUT); pinMode(pinD, OUTPUT); pinMode(pinE, OUTPUT); pinMode(pinF, OUTPUT); pinMode(pinG, OUTPUT); pinMode(D1, OUTPUT); pinMode(D2, OUTPUT); pinMode(D3, OUTPUT); pinMode(D4, OUTPUT); } // the loop routine runs over and over again forever: void loop() { digitalWrite(D1, HIGH); digitalWrite(D2, LOW); digitalWrite(D3, LOW); digitalWrite(D4, LOW); //0 digitalWrite(pinA, 1); digitalWrite(pinB, 1); digitalWrite(pinC, 1); digitalWrite(pinD, 1); digitalWrite(pinE, 1); digitalWrite(pinF, 1); digitalWrite(pinG, 0); delay(1000); digitalWrite(pinA, 0); digitalWrite(pinB, 0); digitalWrite(pinC, 0); digitalWrite(pinD, 0); digitalWrite(pinE, 0); digitalWrite(pinF, 0); digitalWrite(pinG, 0); //1 digitalWrite(pinA, 0); digitalWrite(pinB, 1); digitalWrite(pinC, 1); digitalWrite(pinD, 0); digitalWrite(pinE, 0); digitalWrite(pinF, 0); digitalWrite(pinG, 0); delay(1000); // wait for a second digitalWrite(pinA, 0); digitalWrite(pinB, 0); digitalWrite(pinC, 0); digitalWrite(pinD, 0); digitalWrite(pinE, 0); digitalWrite(pinF, 0); digitalWrite(pinG, 0); //2 digitalWrite(pinA, 1); digitalWrite(pinB, 1); digitalWrite(pinC, 0); digitalWrite(pinD, 1); digitalWrite(pinE, 1); digitalWrite(pinF, 0); digitalWrite(pinG, 1); delay(1000); // wait for a second digitalWrite(pinA, 0); digitalWrite(pinB, 0); digitalWrite(pinC, 0); digitalWrite(pinD, 0); digitalWrite(pinE, 0); digitalWrite(pinF, 0); digitalWrite(pinG, 0); //3 digitalWrite(pinA, 1); digitalWrite(pinB,1); digitalWrite(pinC, 1); digitalWrite(pinD, 1); digitalWrite(pinE, 0); digitalWrite(pinF, 0); digitalWrite(pinG, 1); delay(1000); // wait for a second digitalWrite(pinA, 0); digitalWrite(pinB, 0); digitalWrite(pinC, 0); digitalWrite(pinD, 0); digitalWrite(pinE, 0); digitalWrite(pinF, 0); digitalWrite(pinG, 0); //4 digitalWrite(pinA, 0); digitalWrite(pinB, 1); digitalWrite(pinC, 1); digitalWrite(pinD, 0); digitalWrite(pinE, 0); digitalWrite(pinF, 1); digitalWrite(pinG, 1); delay(1000); // wait for a second digitalWrite(pinA, 0); digitalWrite(pinB, 0); digitalWrite(pinC, 0); digitalWrite(pinD, 0); digitalWrite(pinE, 0); digitalWrite(pinF, 0); digitalWrite(pinG, 0); //5 digitalWrite(pinA, 1); digitalWrite(pinB, 0); digitalWrite(pinC, 1); digitalWrite(pinD, 1); digitalWrite(pinE, 0); digitalWrite(pinF, 1); digitalWrite(pinG, 1); delay(1000); // wait for a second digitalWrite(pinA, 0); digitalWrite(pinB, 0); digitalWrite(pinC, 0); digitalWrite(pinD, 0); digitalWrite(pinE, 0); digitalWrite(pinF, 0); digitalWrite(pinG, 0); //6 digitalWrite(pinA, 1); digitalWrite(pinB, 0); digitalWrite(pinC, 1); digitalWrite(pinD, 1); digitalWrite(pinE, 1); digitalWrite(pinF, 1); digitalWrite(pinG, 1); delay(1000); // wait for a second digitalWrite(pinA, 0); digitalWrite(pinB, 0); digitalWrite(pinC, 0); digitalWrite(pinD, 0); digitalWrite(pinE, 0); digitalWrite(pinF, 0); digitalWrite(pinG, 0); //7 digitalWrite(pinA, 1); digitalWrite(pinB, 1); digitalWrite(pinC, 1); digitalWrite(pinD, 0); digitalWrite(pinE, 0); digitalWrite(pinF, 0); digitalWrite(pinG, 0); delay(1000); // wait for a second digitalWrite(pinA, 0); digitalWrite(pinB, 0); digitalWrite(pinC, 0); digitalWrite(pinD, 0); digitalWrite(pinE, 0); digitalWrite(pinF, 0); digitalWrite(pinG, 0); //8 digitalWrite(pinA, 1); digitalWrite(pinB, 1); digitalWrite(pinC, 1); digitalWrite(pinD, 1); digitalWrite(pinE, 1); digitalWrite(pinF, 1); digitalWrite(pinG, 1); delay(1000); // wait for a second digitalWrite(pinA, 0); digitalWrite(pinB, 0); digitalWrite(pinC, 0); digitalWrite(pinD, 0); digitalWrite(pinE, 0); digitalWrite(pinF, 0); digitalWrite(pinG, 0); //9 digitalWrite(pinA, 1); digitalWrite(pinB, 1); digitalWrite(pinC, 1); digitalWrite(pinD, 1); digitalWrite(pinE, 0); digitalWrite(pinF, 1); digitalWrite(pinG, 1); delay(1000); // wait for a second digitalWrite(pinA, 0); digitalWrite(pinB, 0); digitalWrite(pinC, 0); digitalWrite(pinD, 0); digitalWrite(pinE, 0); digitalWrite(pinF, 0); digitalWrite(pinG, 0); }
Anonymous user
5 years ago
Nice detailed project. For controllers with more limited I/O, the SPI bus is a good alternative. There is an SPI-controlled backpack with 4 7-segement digits at 1wattlabs.com
Anonymous user
5 years ago
hi, i have a problem, my 0 looks like 5, 2 is A, and 3 is something like this /¨¨/ anyone has a problem like that?
Anonymous user
5 years ago
my display showed this,"9999" what is wrong? ;)
Anonymous user
2 years ago
:#
Anonymous user
2 years ago
:}
anteklego2007
5 years ago
don't work like this _ | | _
Emith1
5 years ago
it is not working f***.............!
Anonymous user
2 years ago
wrong pins:*
riklik
5 years ago
this thing does not work at all
riklik
5 years ago
remember that a second is 100 milliseconds and the delay function uses milliseconds
Anonymous user
6 years ago
My code makes this: _ _ _ _ I_I I_I _I I I _ I_ I_ I_
Anonymous user
6 years ago
no resistor needed?
Anonymous user
2 years ago
that is true,i had to get another auruino cuz the oter one was acting strange:<
Anonymous user
2 years ago
Yes a resistor is needed on every anode. If you just have one on the cathode then the brightness will change depending on how many segments are on at the same time. This circuit will damage your Arduino.
Anonymous user
6 years ago
Thanks. I've made nice thermometer with your help.. https://ibb.co/zr9WmP8 https://ibb.co/fN8DSKC https://ibb.co/fdm1gYz
Anonymous user
2 years ago
Wow! You should show people how to make that! That is really cool!
Anonymous user
6 years ago
There should be a current limiting resistor of at least 100 ohms attached to the ground lead on this LED array to keep it from burning up.
Anonymous user
6 years ago
JUST HAD TO LOG IN TO SAY A MASSIVE THANKS FOR SHARING !!!!!! HJGE Thanks for also keeping projects like this Open-Source and free for learning and getting people into the Arduino coding world, keep inspiring folks, well done and again - a "Large & in-Charge" Thanks ! PS; oh also, i had found an IC that can be hooked up to an arduino to save on pins, but its an SMD type component, the MAX7219 - i havent yet hooked it up to an Arduino yet but will endeavour to do so soon with the help of an adapter PCB to convert it to TH (Through-hole) so it can be bread-boarded easier, im sure there are better ones out there that are TH but i dont know of any as im always buying SMD parts, plus if you ever need any help making a PCB, gimmi a shout :)
Anonymous user
6 years ago
I guess this setup is too complicated to use as a 2 player scorer.. ? D1 + D2 digits for Player 1, D3 + D4 digits for Player 2 /with two buttons Though there is only the Analog 13 for one button, so that's the first problem, i guess.. where does the 2nd button go into? Then programming it, you'd have to change D2 or D4 depending on the button that is pressed, at least for the first 9 times, though its not a matter of just changing an integer. Each time you'd have to change what is displayed by either digit. const int buttonPin1 = 13; const int buttonPin2 = ?; void setup() { pinMode(buttonPin1, INPUT); pinMode(buttonPin2, INPUT); digitalWrite(D1, LOW); digitalWrite(D2, LOW); digitalWrite(D3, LOW); digitalWrite(D4, LOW) digitalWrite(pinA, HIGH); digitalWrite(pinB, HIGH); digitalWrite(pinC, HIGH); digitalWrite(pinD, HIGH); digitalWrite(pinE, HIGH); digitalWrite(pinF, HIGH); digitalWrite(pinG, LOW); } void press1() { if (buttonState == HIGH) { digitalWrite(pinA, LOW); digitalWrite(pinB, HIGH); digitalWrite(pinC, HIGH); digitalWrite(pinD, LOW); digitalWrite(pinE, LOW); digitalWrite(pinF, LOW); digitalWrite(pinG, LOW); digitalWrite(D1, LOW); digitalWrite(D2, HIGH); digitalWrite(D3, LOW); digitalWrite(D4, LOW) void press2(); } } void press2() { if (buttonState == HIGH) { ... ... .. .. void press3(); } } Something like that? Though there has to be any easier way to go about it? I guess it might be easier with a backpack?
Anonymous user
2 years ago
Cheers
Anonymous user
2 years ago
Hi Gorebert, I did a project like that in the past, I used a library saying that there were two 2 digits displays. I pass you all the programming
Anonymous user
6 years ago
No current limiting resistors for the LEDs?
arduinowiec2005
6 years ago
cool project
Anonymous user
6 years ago
Thanks for this - the video was the simplest + clearest explanation of how to control the 7-segment display. I'd just not understood it from the other projects I'd seen but this made it simple. I like your tidy garage/workshop too. All my stuff's in a heap on the kitchen table.
Kentoy
6 years ago
How to make countdown using this code sir?
iFrostizz67
6 years ago
Hi, try this code: /* Showing number 0-9 on a Common Anode 7-segment LED display Displays the numbers 0-9 on the display, with one second inbetween. A --- F | | B | G | --- E | | C | | --- D This example code is in the public domain. */ // Pin 2-8 is connected to the 7 segments of the display. int pinA = 2; int pinB = 3; int pinC = 4; int pinD = 5; int pinE = 6; int pinF = 7; int pinG = 8; int D1 = 9; int D2 = 10; int D3 = 11; int D4 = 12; // the setup routine runs once when you press reset: void setup() { // initialize the digital pins as outputs. pinMode(pinA, OUTPUT); pinMode(pinB, OUTPUT); pinMode(pinC, OUTPUT); pinMode(pinD, OUTPUT); pinMode(pinE, OUTPUT); pinMode(pinF, OUTPUT); pinMode(pinG, OUTPUT); pinMode(D1, OUTPUT); pinMode(D2, OUTPUT); pinMode(D3, OUTPUT); pinMode(D4, OUTPUT); } // the loop routine runs over and over again forever: void loop() { digitalWrite(D1, LOW); digitalWrite(D2, LOW); digitalWrite(D3, LOW); digitalWrite(D4, LOW); //0 digitalWrite(pinA, HIGH); digitalWrite(pinB, HIGH); digitalWrite(pinC, HIGH); digitalWrite(pinD, HIGH); digitalWrite(pinE, HIGH); digitalWrite(pinF, HIGH); digitalWrite(pinG, LOW); delay(1000); // wait for a second //1 digitalWrite(pinA, LOW); digitalWrite(pinB, HIGH); digitalWrite(pinC, HIGH); digitalWrite(pinD, LOW); digitalWrite(pinE, LOW); digitalWrite(pinF, LOW); digitalWrite(pinG, LOW); delay(1000); // wait for a second //2 digitalWrite(pinA, HIGH); digitalWrite(pinB, HIGH); digitalWrite(pinC, LOW); digitalWrite(pinD, HIGH); digitalWrite(pinE, HIGH); digitalWrite(pinF, LOW); digitalWrite(pinG, HIGH); delay(1000); // wait for a second //3 digitalWrite(pinA, HIGH); digitalWrite(pinB, HIGH); digitalWrite(pinC, HIGH); digitalWrite(pinD, HIGH); digitalWrite(pinE, LOW); digitalWrite(pinF, LOW); digitalWrite(pinG, HIGH); delay(1000); // wait for a second //4 digitalWrite(pinA, LOW); digitalWrite(pinB, HIGH); digitalWrite(pinC, HIGH); digitalWrite(pinD, LOW); digitalWrite(pinE, LOW); digitalWrite(pinF, HIGH); digitalWrite(pinG, HIGH); delay(1000); // wait for a second //5 digitalWrite(pinA, HIGH); digitalWrite(pinB, LOW); digitalWrite(pinC, HIGH); digitalWrite(pinD, HIGH); digitalWrite(pinE, LOW); digitalWrite(pinF, HIGH); digitalWrite(pinG, HIGH); delay(1000); // wait for a second //6 digitalWrite(pinA, HIGH); digitalWrite(pinB, LOW); digitalWrite(pinC, HIGH); digitalWrite(pinD, HIGH); digitalWrite(pinE, HIGH); digitalWrite(pinF, HIGH); digitalWrite(pinG, HIGH); delay(1000); // wait for a second //7 digitalWrite(pinA, HIGH); digitalWrite(pinB, HIGH); digitalWrite(pinC, HIGH); digitalWrite(pinD, LOW); digitalWrite(pinE, LOW); digitalWrite(pinF, LOW); digitalWrite(pinG, LOW); delay(1000); // wait for a second //8 digitalWrite(pinA, HIGH); digitalWrite(pinB, HIGH); digitalWrite(pinC, HIGH); digitalWrite(pinD, HIGH); digitalWrite(pinE, HIGH); digitalWrite(pinF, HIGH); digitalWrite(pinG, HIGH); delay(1000); // wait for a second //9 digitalWrite(pinA, HIGH); digitalWrite(pinB, HIGH); digitalWrite(pinC, HIGH); digitalWrite(pinD, HIGH); digitalWrite(pinE, LOW); digitalWrite(pinF, HIGH); digitalWrite(pinG, HIGH); delay(1000); // wait for a second }
Anonymous user
2 years ago
:) can also make with "for int i" loop.. :)
Anonymous user
2 years ago
int pinA = 2; int pinB = 3; int pinC = 4; int pinD = 5; int pinE = 6; int pinF = 7; int pinG = 8; int D1 = 9; int D2 = 10; int D3 = 11; int D4 = 12; // the setup routine runs once when you press reset: void setup() { // initialize the digital pins as outputs. pinMode(pinA, OUTPUT); pinMode(pinB, OUTPUT); pinMode(pinC, OUTPUT); pinMode(pinD, OUTPUT); pinMode(pinE, OUTPUT); pinMode(pinF, OUTPUT); pinMode(pinG, OUTPUT); pinMode(D1, OUTPUT); pinMode(D2, OUTPUT); pinMode(D3, OUTPUT); pinMode(D4, OUTPUT); } //NUMBERS: //0 void n0(){ digitalWrite(pinA, HIGH); digitalWrite(pinB, HIGH); digitalWrite(pinC, HIGH); digitalWrite(pinD, HIGH); digitalWrite(pinE, HIGH); digitalWrite(pinF, HIGH); digitalWrite(pinG, LOW); delay(1000); // wait for a second } //1 void n1(){ digitalWrite(pinA, LOW); digitalWrite(pinB, HIGH); digitalWrite(pinC, HIGH); digitalWrite(pinD, LOW); digitalWrite(pinE, LOW); digitalWrite(pinF, LOW); digitalWrite(pinG, LOW); delay(1000); // wait for a second } //2 void n2(){ digitalWrite(pinA, HIGH); digitalWrite(pinB, HIGH); digitalWrite(pinC, LOW); digitalWrite(pinD, HIGH); digitalWrite(pinE, HIGH); digitalWrite(pinF, LOW); digitalWrite(pinG, HIGH); delay(1000); // wait for a second } //3 void n3(){ digitalWrite(pinA, HIGH); digitalWrite(pinB, HIGH); digitalWrite(pinC, HIGH); digitalWrite(pinD, HIGH); digitalWrite(pinE, LOW); digitalWrite(pinF, LOW); digitalWrite(pinG, HIGH); delay(1000); // wait for a second } //4 void n4(){ digitalWrite(pinA, LOW); digitalWrite(pinB, HIGH); digitalWrite(pinC, HIGH); digitalWrite(pinD, LOW); digitalWrite(pinE, LOW); digitalWrite(pinF, HIGH); digitalWrite(pinG, HIGH); delay(1000); // wait for a second } //5 void n5(){ digitalWrite(pinA, HIGH); digitalWrite(pinB, LOW); digitalWrite(pinC, HIGH); digitalWrite(pinD, HIGH); digitalWrite(pinE, LOW); digitalWrite(pinF, HIGH); digitalWrite(pinG, HIGH); delay(1000); // wait for a second } //6 void n6(){ digitalWrite(pinA, HIGH); digitalWrite(pinB, LOW); digitalWrite(pinC, HIGH); digitalWrite(pinD, HIGH); digitalWrite(pinE, HIGH); digitalWrite(pinF, HIGH); digitalWrite(pinG, HIGH); delay(1000); // wait for a second } //7 void n7(){ digitalWrite(pinA, HIGH); digitalWrite(pinB, HIGH); digitalWrite(pinC, HIGH); digitalWrite(pinD, LOW); digitalWrite(pinE, LOW); digitalWrite(pinF, LOW); digitalWrite(pinG, LOW); delay(1000); // wait for a second } //8 void n8(){ digitalWrite(pinA, HIGH); digitalWrite(pinB, HIGH); digitalWrite(pinC, HIGH); digitalWrite(pinD, HIGH); digitalWrite(pinE, HIGH); digitalWrite(pinF, HIGH); digitalWrite(pinG, HIGH); delay(1000); // wait for a second } //9 void n9(){ digitalWrite(pinA, HIGH); digitalWrite(pinB, HIGH); digitalWrite(pinC, HIGH); digitalWrite(pinD, HIGH); digitalWrite(pinE, LOW); digitalWrite(pinF, HIGH); digitalWrite(pinG, HIGH); delay(1000); // wait for a second } void s1(){ digitalWrite(D1, LOW); digitalWrite(D2, HIGH); digitalWrite(D3, HIGH); digitalWrite(D4, HIGH); } void s2(){ digitalWrite(D1, HIGH); digitalWrite(D2, LOW); digitalWrite(D3, HIGH); digitalWrite(D4, HIGH); } void s3(){ digitalWrite(D1, HIGH); digitalWrite(D2, HIGH); digitalWrite(D3, LOW); digitalWrite(D4, HIGH); } void s4(){ digitalWrite(D1, HIGH); digitalWrite(D2, HIGH); digitalWrite(D3, HIGH); digitalWrite(D4, LOW); } // the loop routine runs over and over again forever: void loop() { s1(); n0(); s2(); n1(); s3(); n2(); s4(); n3(); s3(); n4(); s2(); n5(); s1(); n6(); s2(); n7(); s3(); n8(); s4(); n9(); }
Anonymous user
6 years ago
How can I do to put 10 or 11 or 12 or 24?
Anonymous user
7 years ago
To anyone who just sees random stuff showing up, switch every D1 - D4 pin to the opposite high or low. If that changes something, do the same for every individual LED. here's my modified code : /* Showing number 0-9 on a Common Anode 7-segment LED display Displays the numbers 0-9 on the display, with one second in between. A --- F | | B | G | --- E | | C | | --- D This example code is in the public domain. */ // Pin 2-8 is connected to the 7 segments of the display. int pinA = 2; int pinB = 3; int pinC = 4; int pinD = 5; int pinE = 6; int pinF = 7; int pinG = 8; int D1 = 9; int D2 = 10; int D3 = 11; int D4 = 12; // the setup routine runs once when you press reset: void setup() { // initialize the digital pins as outputs. pinMode(pinA, OUTPUT); pinMode(pinB, OUTPUT); pinMode(pinC, OUTPUT); pinMode(pinD, OUTPUT); pinMode(pinE, OUTPUT); pinMode(pinF, OUTPUT); pinMode(pinG, OUTPUT); pinMode(D1, OUTPUT); pinMode(D2, OUTPUT); pinMode(D3, OUTPUT); pinMode(D4, OUTPUT); } // the loop routine runs over and over again forever: void loop() { digitalWrite(D1, LOW); digitalWrite(D2, HIGH); digitalWrite(D3, HIGH); digitalWrite(D4, HIGH); //0 digitalWrite(pinA, HIGH); digitalWrite(pinB, HIGH); digitalWrite(pinC, HIGH); digitalWrite(pinD, HIGH); digitalWrite(pinE, HIGH); digitalWrite(pinF, HIGH); digitalWrite(pinG, LOW); delay(1); // wait for a second digitalWrite(D1, HIGH); digitalWrite(D2, LOW); digitalWrite(D3, HIGH); digitalWrite(D4, HIGH); //1 digitalWrite(pinA, LOW); digitalWrite(pinB, HIGH); digitalWrite(pinC, HIGH); digitalWrite(pinD, LOW); digitalWrite(pinE, LOW); digitalWrite(pinF, LOW); digitalWrite(pinG, LOW); delay(1); // wait for a second digitalWrite(D1, HIGH); digitalWrite(D2, HIGH); digitalWrite(D3, LOW); digitalWrite(D4, HIGH); //2 digitalWrite(pinA, LOW); digitalWrite(pinB, HIGH); digitalWrite(pinC, HIGH); digitalWrite(pinD, LOW); digitalWrite(pinE, LOW); digitalWrite(pinF, LOW); digitalWrite(pinG, LOW); delay(1); // wait for a second digitalWrite(D1, HIGH); digitalWrite(D2, HIGH); digitalWrite(D3, HIGH); digitalWrite(D4, LOW); //3 digitalWrite(pinA, LOW); digitalWrite(pinB, HIGH); digitalWrite(pinC, HIGH); digitalWrite(pinD, LOW); digitalWrite(pinE, LOW); digitalWrite(pinF, LOW); digitalWrite(pinG, LOW); delay(1); // wait for a second /* //4 digitalWrite(pinA, HIGH); digitalWrite(pinB, LOW); digitalWrite(pinC, LOW); digitalWrite(pinD, HIGH); digitalWrite(pinE, HIGH); digitalWrite(pinF, LOW); digitalWrite(pinG, LOW); delay(1000); // wait for a second //5 digitalWrite(pinA, LOW); digitalWrite(pinB, HIGH); digitalWrite(pinC, LOW); digitalWrite(pinD, LOW); digitalWrite(pinE, HIGH); digitalWrite(pinF, LOW); digitalWrite(pinG, LOW); delay(1000); // wait for a second //6 digitalWrite(pinA, LOW); digitalWrite(pinB, HIGH); digitalWrite(pinC, LOW); digitalWrite(pinD, LOW); digitalWrite(pinE, LOW); digitalWrite(pinF, LOW); digitalWrite(pinG, LOW); delay(1000); // wait for a second //7 digitalWrite(pinA, LOW); digitalWrite(pinB, LOW); digitalWrite(pinC, LOW); digitalWrite(pinD, HIGH); digitalWrite(pinE, HIGH); digitalWrite(pinF, HIGH); digitalWrite(pinG, HIGH); delay(1000); // wait for a second //8 digitalWrite(pinA, LOW); digitalWrite(pinB, LOW); digitalWrite(pinC, LOW); digitalWrite(pinD, LOW); digitalWrite(pinE, LOW); digitalWrite(pinF, LOW); digitalWrite(pinG, LOW); delay(1000); // wait for a second //9 digitalWrite(pinA, LOW); digitalWrite(pinB, LOW); digitalWrite(pinC, LOW); digitalWrite(pinD, HIGH); digitalWrite(pinE, HIGH); digitalWrite(pinF, LOW); digitalWrite(pinG, LOW); delay(1000); // wait for a second */ }
Timpl
7 years ago
How to make a timer of the same wiring from this project?
Anonymous user
2 years ago
The millis() returns the time since the code started. You can take the output to turn into numbers.
Anonymous user
7 years ago
Your settings for the delay in your code is incorrect for the first 3-4 characters. You have delay(1) and it should be delay(1000). (for those wondering why it may not be working). Also, your code was incorrect for 0 through 3. Given your diagram of the digits at the top of the code... "HIGH" means "OFF". That being the case, "ZERO" should have "G" set as HIGH and the rest set to LOW. This will make the middle line "G" turn off and the rest A,B,C,D,E,F to LOW in which will turn on the lights needed. I have also noted in the code // to show what code "Moves" to the next digit until finaly staying on the last. GOOD WORK and the effort is MUCH appreciated! // Pin 2-8 is connected to the 7 segments of the display. int pinA = 2; int pinB = 3; int pinC = 4; int pinD = 5; int pinE = 6; int pinF = 7; int pinG = 8; int D1 = 9; int D2 = 10; int D3 = 11; int D4 = 12; // the setup routine runs once when you press reset: void setup() { // initialize the digital pins as outputs. pinMode(pinA, OUTPUT); pinMode(pinB, OUTPUT); pinMode(pinC, OUTPUT); pinMode(pinD, OUTPUT); pinMode(pinE, OUTPUT); pinMode(pinF, OUTPUT); pinMode(pinG, OUTPUT); pinMode(D1, OUTPUT); pinMode(D2, OUTPUT); pinMode(D3, OUTPUT); pinMode(D4, OUTPUT); } // the loop routine runs over and over again forever: void loop() { // THIS MOVES BELOW CODE TO THE NEXT LCD BLOCK digitalWrite(D1, HIGH); digitalWrite(D2, LOW); digitalWrite(D3, LOW); digitalWrite(D4, LOW); //THIS ENDS THE MOVEMENT AND REMAINS ON THE LAST BLOCK FOR THE FOLLOWING DIGITS //0 digitalWrite(pinA, LOW); digitalWrite(pinB, LOW); digitalWrite(pinC, LOW); digitalWrite(pinD, LOW); digitalWrite(pinE, LOW); digitalWrite(pinF, LOW); digitalWrite(pinG, HIGH); delay(1000); // wait for a second // THIS MOVES BELOW CODE TO THE NEXT LCD BLOCK digitalWrite(D1, LOW); digitalWrite(D2, HIGH); digitalWrite(D3, LOW); digitalWrite(D4, LOW); //THIS ENDS THE MOVEMENT AND REMAINS ON THE LAST BLOCK FOR THE FOLLOWING DIGITS //1 digitalWrite(pinA, HIGH); digitalWrite(pinB, LOW); digitalWrite(pinC, LOW); digitalWrite(pinD, HIGH); digitalWrite(pinE, HIGH); digitalWrite(pinF, HIGH); digitalWrite(pinG, HIGH); delay(1000); // wait for a second // THIS MOVES BELOW CODE TO THE NEXT LCD BLOCK digitalWrite(D1, LOW); digitalWrite(D2, LOW); digitalWrite(D3, HIGH); digitalWrite(D4, LOW); //THIS ENDS THE MOVEMENT AND REMAINS ON THE LAST BLOCK FOR THE FOLLOWING DIGITS //2 digitalWrite(pinA, LOW); digitalWrite(pinB, LOW); digitalWrite(pinC, HIGH); digitalWrite(pinD, LOW); digitalWrite(pinE, LOW); digitalWrite(pinF, HIGH); digitalWrite(pinG, LOW); delay(1000); // wait for a second // THIS MOVES BELOW CODE TO THE NEXT LCD BLOCK digitalWrite(D1, LOW); digitalWrite(D2, LOW); digitalWrite(D3, LOW); digitalWrite(D4, HIGH); //THIS ENDS THE MOVEMENT AND REMAINS ON THE LAST BLOCK FOR THE FOLLOWING DIGITS //3 digitalWrite(pinA, LOW); digitalWrite(pinB, LOW); digitalWrite(pinC, LOW); digitalWrite(pinD, LOW); digitalWrite(pinE, HIGH); digitalWrite(pinF, HIGH); digitalWrite(pinG, LOW); delay(1000); // wait for a second //4 digitalWrite(pinA, HIGH); digitalWrite(pinB, LOW); digitalWrite(pinC, LOW); digitalWrite(pinD, HIGH); digitalWrite(pinE, HIGH); digitalWrite(pinF, LOW); digitalWrite(pinG, LOW); delay(1000); // wait for a second //5 digitalWrite(pinA, LOW); digitalWrite(pinB, HIGH); digitalWrite(pinC, LOW); digitalWrite(pinD, LOW); digitalWrite(pinE, HIGH); digitalWrite(pinF, LOW); digitalWrite(pinG, LOW); delay(1000); // wait for a second //6 digitalWrite(pinA, LOW); digitalWrite(pinB, HIGH); digitalWrite(pinC, LOW); digitalWrite(pinD, LOW); digitalWrite(pinE, LOW); digitalWrite(pinF, LOW); digitalWrite(pinG, LOW); delay(1000); // wait for a second //7 digitalWrite(pinA, LOW); digitalWrite(pinB, LOW); digitalWrite(pinC, LOW); digitalWrite(pinD, HIGH); digitalWrite(pinE, HIGH); digitalWrite(pinF, HIGH); digitalWrite(pinG, HIGH); delay(1000); // wait for a second //8 digitalWrite(pinA, LOW); digitalWrite(pinB, LOW); digitalWrite(pinC, LOW); digitalWrite(pinD, LOW); digitalWrite(pinE, LOW); digitalWrite(pinF, LOW); digitalWrite(pinG, LOW); delay(1000); // wait for a second //9 digitalWrite(pinA, LOW); digitalWrite(pinB, LOW); digitalWrite(pinC, LOW); digitalWrite(pinD, HIGH); digitalWrite(pinE, HIGH); digitalWrite(pinF, LOW); digitalWrite(pinG, LOW); delay(1000); // wait for a second }
SAnwandter1
2 years ago
Thanks for your contribution and for pointing out that mistake, I'll try to fix it. Glad you liked it!
Anonymous user
7 years ago
Hello, Thank you for doing this project. I have set up my wiring on my half-size breadboard just like your schematic says, and I also copied the code with the link provided, into my Arduino program and uploaded to my Arduino UNO. However, I'm not displaying the number correctly like you show... I posted a link in a forum with pictures here https://forum.arduino.cc/index.php?topic=510062.0 Thanks for your help and time.
SAnwandter1
2 years ago
Did you watch the video for the connections?? If you did than it might be that your LED display is different than mine. It's a little hard to explain through chat, thanks for asking, sorry for the inconvenients
VanillaSlicePie
7 years ago
This was my very first project. Learnt heaps, made mistakes, proud of the finished product. Thank you:)
mzacharin
7 years ago
//0 digitalWrite(pinA, LOW); digitalWrite(pinB, HIGH); digitalWrite(pinC, LOW); digitalWrite(pinD, LOW); digitalWrite(pinE, HIGH); digitalWrite(pinF, LOW); digitalWrite(pinG, LOW); delay(1); // wait for a second Are you sure this is 0?
Theopoint18
2 years ago
Yeah but he was thinking it corresponded to the 0 caracter
SAnwandter1
2 years ago
Yes, and?? I made it say santi because it's an abbreviation of my name but you can change it. In the code there is an example of a 7 segment number an it has all the letters you can simply change the code according to what you want to write
SAnwandter1
2 years ago
Yes I'm sure. Everything in arduino language, if a line has this // it completely neutralizes what it's saying, that's why it's in gray
mzacharin
2 years ago
I mean this code draws something like this — |_ _ |
Anonymous user
2 years ago
well...in the code you wrote it is 0 but it is 5/S.and 2 is A
Anonymous user
2 years ago
//0 digitalWrite(pinA, LOW); digitalWrite(pinB, LOW); digitalWrite(pinC, LOW); digitalWrite(pinD, LOW); digitalWrite(pinE, LOW); digitalWrite(pinF, LOW); digitalWrite(pinG, HIGH); delay(1); // wait for a second This is 0. I tested. Good luck :D
Tom_The_Bomb
8 years ago
Just odered my first adruino - looking forward to learning. This looks like a good project to get my feet wet, make sure I can compile etc... kind of a "Hello, World" of embedded projects :-)
Anonymous user
2 years ago
Put some resistors between the Arduino and the 4 Digit pins or (not and) on the 8 segment lines. Pro tip I used back in the day, use a potentiometer on a lit segment and when you have it at the right level of dim then use an ohm meter on the pot and replace it with a resister as close as you can.
gilangkentjana
2 years ago
I second this. On my first try, I tried making it countdown from 9 to 0, and left it for a while to do other stuff. When I came back, the display was kind of hot
Anonymous user
2 years ago
If you are going to do that, make the illusion of scrolling. Also add resistors for the digit (pin 2-8), otherwise your display might burn out
SAnwandter1
14 Followers
•4 Projects
215
153
Programming 4 Digit 7 Segment LED Display | Arduino Project Hub
chito1623
7 months ago
Yes I agree no limiting current resistors to each segment which will ruin the arduino board. Just add a limiting resistors to each digit will help.