u s i n g a 4 d i g i t , 7 s e g m e n t d i s p l a y, w ... … · if you connected the display...

12
let's make Explore (/tag/typeid/) Publish (/about/create.jsp) Classes NEW! (/classes/) Login (/account/login/) | Sign Up (/account/gopro) Featured: 3D Printing Class (https://www.instructables.com/class/3DPrintingClass/) Arduino (/tag/typeid/categorytechnology/channelarduino/) Sewing (https://www.instructables.com/tag/typeid/categorycraft/channelsewing/) In this tutorial I will be showing you how to use a 7 segment display with 4 digits using arduino. Some basic things I would like to point out is that this takes up almost all of the digital pins on the arduino uno, leonardo, the boards with 13 digital pins. Most displays have 12 breakout pins that connect either directly to the arduino, or through a resistor. Also, I would like to point out that these displays have no need for Ground, 5V, or 3.3V to be connected. So, let's get started... Step 1: Materials (/file/F8EVUS9IBTF50FR/) About This Instructable 32,729 views 51 favorites License: Public Domain (/member/chickeneater/) chickeneater (/member/chickeneater/) (https://plus.google.com/1125537 Follow 13 More by chickeneater: (/id/Parachute Dropper/) (/id/Inland RFIDlearningkit/) (/id/TransmitterReceiverArduino/) (/) Download Favorite I Made it! Collection Using a 4 digit, 7 segment display, with arduino by chickeneater (/member/chickeneater/) in arduino (/tag/typeid/categorytechnology/channelarduino/) 7 Steps Share (/id/Usinga4digit7segmentdisplaywitharduino/) share what you make Check out our new classes! >> (/classes/?utm_medium=cta&utm_source=banner) ×

Upload: others

Post on 25-Sep-2020

0 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: U s i n g a 4 d i g i t , 7 s e g m e n t d i s p l a y, w ... … · If you connected the display correctly, uploaded the code correctly, and copied the coded just right, then your

let's make Explore (/tag/type­id/) Publish (/about/create.jsp)

Classes NEW! (/classes/)

Login (/account/login/) | Sign Up (/account/gopro)

Featured: 3D Printing Class (https://www.instructables.com/class/3D­Printing­Class/) Arduino (/tag/type­id/category­technology/channel­arduino/)

Sewing (https://www.instructables.com/tag/type­id/category­craft/channel­sewing/)

In this tutorial I will be showing you how to use a 7 segment display with 4 digitsusing arduino. Some basic things I would like to point out is that this takes upalmost all of the digital pins on the arduino uno, leonardo, the boards with 13digital pins. Most displays have 12 breakout pins that connect either directly tothe arduino, or through a resistor. Also, I would like to point out that thesedisplays have no need for Ground, 5V, or 3.3V to be connected. So, let's getstarted...

Step 1: Materials

(/file/F8EVUS9IBTF50FR/)

About This Instructable

8 32,729 views

51 favorites

License:PublicDomain

(/member/chickeneater/)

chickeneater(/member/chickeneater/)(https://plus.google.com/112553770731458774591)

Follow 13

More by chickeneater:

(/id/Parachute­

Dropper/) (/id/Inland­

RFID­learning­kit/)

(/id/TransmitterReceiver­Arduino/)

(/)

Download

Favorite I Made it! Collection

Using a 4 digit, 7 segment display, with arduino bychickeneater (/member/chickeneater/) in arduino (/tag/type­id/category­technology/channel­arduino/)

7 Steps .

Share

h (/id/Using­a­4­digit­7­segment­display­with­arduino/)

share what you make

Check out our new classes! >> (/classes/?utm_medium=cta&utm_source=banner)×

Page 2: U s i n g a 4 d i g i t , 7 s e g m e n t d i s p l a y, w ... … · If you connected the display correctly, uploaded the code correctly, and copied the coded just right, then your

Using a display of this kind requires almost no materials.

­ 4 x 330Ω resistors

­ 12 x Male to male jumper wires

­ 1 x Arduino

­ 1 x breadboard of any size (they don't need the power rails)

No tools are required in order to make a prototype of this design. However, asoldering iron and a pcb board would be needed for a more permanent use.

Step 2: Breadboard Layout

(/file/F0UVPQWIBTF50WP/)

(/file/FHR0EWPIBTF50WT/) (/file/FFFWHBBIA0WGKJ9/)

Check out our new classes! >> (/classes/?utm_medium=cta&utm_source=banner)×

Page 3: U s i n g a 4 d i g i t , 7 s e g m e n t d i s p l a y, w ... … · If you connected the display correctly, uploaded the code correctly, and copied the coded just right, then your

Just to give you some context i will explain the usage of each pin. 8 out of the 12pins on the display are used for the 8 segments. There are 7 segments used toform any digit while one controls the decimal point. The other 4 out of the 12pins control each of the 4 digits on the display. Any pin that has a resistor on it isone of the 4 digit pins, otherwise they are the segment pins.

The above design I created from fritzing in order to show the connectionbetween the display and the arduino. Note the placement of where the resistorsare because if you connect the resistor to the wrong pin on the display, eitherthat digit will not work or that segment will not work, FOREVER...

***IMPORTANT NOTE***

When setting up the circuit switch the yellow and the purple wires (I messed upmy circuit diagram).

Step 3: Installing the Library

The library linked below is from the arduino website for easily controlling adisplay. The link goes to github. If you have never been on github listen carefully,if you have read the next paragraph. When you get onto the website look at theright side of the window and look down until you see, "Download Zip". Click thatbutton and watch it appear in your downloads.

Now you have to load the previously installed library into your libraries folder. Ifyou now how to do this then skip to the next step, otherwise keep on reading.First go into finder and locate the "documents" folder, and open it. Then, locatethe "arduino" folder, and open it. Then, locate the libraries folder, and open it.Finally drag and drop the installed library into the just opened libraries folder.

IMPORTANT. If your arduino application was opened and running while youwhere putting the library into the libraries folder, the arduino won't recognize thelibrary. You just have to quit the application and open it again.

https://github.com/DeanIsMe/SevSeg

(/file/F1ZZJYVIBTF513Q/)

Check out our new classes! >> (/classes/?utm_medium=cta&utm_source=banner)×

Page 4: U s i n g a 4 d i g i t , 7 s e g m e n t d i s p l a y, w ... … · If you connected the display correctly, uploaded the code correctly, and copied the coded just right, then your

Step 4: The Code

The code for actually displaying something is listed below.

#include "SevSeg.h"

SevSeg sevseg; //Initiate a seven segment controller object

void setup()

byte numDigits = 4;

byte digitPins[] = 2, 3, 4, 5;

byte segmentPins[] = 6, 7, 8, 9, 10, 11, 12, 13;

sevseg.begin(COMMON_CATHODE, numDigits, digitPins, segmentPins);

sevseg.setBrightness(90);

void loop()

sevseg.setNumber(3141, 3);

sevseg.refreshDisplay(); // Must run repeatedly

Step 5: The Result

If you connected the display correctly, uploaded the code correctly, and copiedthe coded just right, then your display should be displaying pi (only 3.141).

If not then, read step six for whatever is happening wrong.

If you did get it right, then I suggest reading going further in step seven.

Step 6: Troubleshooting

Here i have listed two possible things that could have happend to your displaythat could have messed it up. Sadly only one of the two is fixable.

­ Your display is displaying 8888

(/file/FZXURL3IBTF53YY/)

Check out our new classes! >> (/classes/?utm_medium=cta&utm_source=banner)×

Page 5: U s i n g a 4 d i g i t , 7 s e g m e n t d i s p l a y, w ... … · If you connected the display correctly, uploaded the code correctly, and copied the coded just right, then your

We have a be nice comment policy. Please be positive and constructive. w I Made it! Add Images Post Comment

Replya month ago

Do not worry this is the problem that is fixable, just follow these steps

1. Locate in the code " sevseg.begin(COMMON_CATHODE, numDigits,digitPins, segmentPins); "

2. Change "COMMON CATHODE" to "COMMON ANODE"

3. Upload the code again

­ Your display is displaying 3. 41 or .141 or 3.1 1 or 3.14 without the other 1

Sadly, this problem can either be fixable or not :.(... (thats my crying face)

1. Check your connections and make sure everything IS plugged in and nothanging out

2. Check the schematic again, because you most likely plugged it in wrong

3. Locate the line in void loop where it says to display (3.141, 3) and change3.141 to 8888 and see if one of the 8 are missing

4. If so one of the wires might have not had a resistor when it should have hadone meaning that one of the digits had burned out. You can check this bylooking at the back of the display. If you see any black near one of the pins youdid overpower one of the digit places. Sadly this IS NOT fixable and you wouldwant to buy another display.

5. If you do not see a black mark anywhere than you switched up wires thatcan't get overpowered so check the schematic and plug then in correctly andchange the code back from 8888 to 3.141.

Step 7: Going Further

One method of using a few pins on the arduino to control multiple LEDs thatwould otherwise require alot of pin is a tri­state 8 pin shift­register. So instead ofdirectly connecting the 8 segment pins to arduino you can plug them into theshift register and figure out how to do that.

It is just an idea that I came up with but I do not know how to do or if it is evenpossible with the arduino and the display's library, but hey, food for thought forthe curious.

Have fun with your display and i hope you liked this instructable because it is thefirst that i have actually finished out of the many i have in my drafts.

Geocrafter. (/member/Geocrafter.)

Any idea why the decimal poitns wont work for me? tried on multiple displays.Pin #3 is DP and even if i puill it nothing happens. Just dosent light upCheck out our new classes! >> (/classes/?utm_medium=cta&utm_source=banner)×

Page 6: U s i n g a 4 d i g i t , 7 s e g m e n t d i s p l a y, w ... … · If you connected the display correctly, uploaded the code correctly, and copied the coded just right, then your

Reply

a month ago

Replya month ago8

Reply

a month ago

Reply

a month ago

Replya month ago

Reply3 months ago

Reply2 months ago

Geocrafter. (/member/Geocrafter.) . Geocrafter. (/member/Geocrafter.)

and how would i use 2 displays using one arduino?

chickeneater (/member/chickeneater) (author) . Geocrafter. (/member/Geocrafter.)

Might be something wrong with your arduino board.You can determine if this is the case my light a single led with the pin onthe arduino that lights up the decimal point. Use a simple LED blink sketchand if the LED does not light up that means your arduino is broken. If thisis the case you can just change the code and the schematic so that ituses a different pin. If it does work then double check the code. OtherwiseI have no idea.

Geocrafter. (/member/Geocrafter.) . chickeneater (/member/chickeneater)

Experimented, only my third decimal point on all my displayswork, tried on both my arduinos. Also how would I use multiple displayson my mega?

TimC211 (/member/TimC211) . Geocrafter. (/member/Geocrafter.)

I don't know

notapremium (/member/notapremium)

It seems there are some problems with the library. I'm just guessing since Ihave no related experience. Having tested a few number combinations in whicheither 3.141or 8888 was presented as expected, however, any combinations interm of 008X wouldn't be verified by IDE(windows), the error message is"invalid digit "8" in octal constant". Also, there are largely chances gettingincorrect display when set the first digit to "0". For example, the number 1.037can be displayed exactly, but 0137 or 0037 can't.

SantiagoS42 (/member/SantiagoS42)

It prints 8888 perfectly, but it has problems showing the 2 and the 3. If i type2222, 3333, 3141, 2141, 2888, 3888 etc wherever i put the 3 or the 2 it willshow a 0 missing the lower left segment

НиколайП16 (/member/НиколайП16) . SantiagoS42 (/member/SantiagoS42)

Confirm the problem all digits except 2 and 3 isworking fine. Instead 3 showing breaking 0 (see the photo). Maybe this isa problem with library or this model of display not supported by library?Note: i'm using not original Arduino, but chinese copy of this fromAliexpress. Model is: E40361­I­BL­O­W 1043 9

Check out our new classes! >> (/classes/?utm_medium=cta&utm_source=banner)×

Page 7: U s i n g a 4 d i g i t , 7 s e g m e n t d i s p l a y, w ... … · If you connected the display correctly, uploaded the code correctly, and copied the coded just right, then your

Reply2 months ago8

Reply3 months ago8

(https://cdn.instructables.com/FVS/Z1NX/IWH3GXOM/FVSZ1NXIWH3GXOM.LARGE.jpg)

(https://cdn.instructables.com/F0Z/L0MB/IWH3GXOZ/F0ZL0MBIWH3GXOZ.LARGE.jpg)

(https://cdn.instructables.com/FCW/C86T/IWH3GXPD/FCWC86TIWH3GXPD.LARGE.jpg)

(https://cdn.instructables.com/F8L/W4VX/IWH3GXPT/F8LW4VXIWH3GXPT.LARGE.jpg)

chickeneater (/member/chickeneater) (author) . НиколайП16 (/member/НиколайП16)

It isn't a problem with the library but it is a problem with the code becausewhen I first got this I had to match the segments to the way that thelibraries turned on each segment for each number. So I had to try a wholebunch of variations until I found what I THOUGHT was the right variation.Because you guys are having this problem I am guessing that I found thewrong one.

Shouldn't be to hard to fix. I will try to fix it ASAP which might not be untilthe weekend (school).

Thanks for informing me of your problems.

chickeneater (/member/chickeneater) (author) . SantiagoS42(/member/SantiagoS42)

"If i type 2222, 3333, 3141, 2141, 2888, 3888 etc wherever i put the 3 orthe 2 it will show a 0 missing the lower left segment."

I am a little lost when you say "it will show a 0 missing" because there isno 0 in the numbers 2222, 3333, 3141, etc....

Are you saying that one of the segments are not on?

If so which segment?Check out our new classes! >> (/classes/?utm_medium=cta&utm_source=banner)×

Page 8: U s i n g a 4 d i g i t , 7 s e g m e n t d i s p l a y, w ... … · If you connected the display correctly, uploaded the code correctly, and copied the coded just right, then your

Reply4 months ago

Reply3 months ago

Reply3 months ago8

Reply4 months ago

Reply4 months ago

Reply6 months ago

Reply8 months ago

Reply8 months ago

Reply8 months ago8

_

I _ I

I _ I

GiannisK20 (/member/GiannisK20)

Helloo ! I do not own 330Ohm resistors.. i only have 220Ohm , 1k Ohm and 10kOhm ! should any of them work? #Beginners_question

gliderpilotnat (/member/gliderpilotnat) . GiannisK20 (/member/GiannisK20)

220 should be fine, I've used 220 before#I'mAnElectronicEngineer

chickeneater (/member/chickeneater) (author) . gliderpilotnat(/member/gliderpilotnat)

Yeah I agree, 220Ω are fine just brighter i think.

smarduino (/member/smarduino)

Quick naive question from a beginner, how come there is no GND connection?

genuino (/member/genuino)

Quick naive question from a beginner, how come there is no GND connection?

SebbithecoolH (/member/SebbithecoolH)

AWESOME!!!! worked on my first try!

Floxyf (/member/Floxyf)

In the 2nd step (Breadboard Layout) i noticed you have used 5 resistors now in1st step (Materials) you told us that we will need 4x 330ohm resistors did youmake a mistake in the 1st step (Materials) or in the 2nd step (BreadboardLayout)?

Floxyf (/member/Floxyf) . Floxyf (/member/Floxyf)

It's hiden in between pin 2 and 6

chickeneater (/member/chickeneater) (author) . Floxyf (/member/Floxyf)

oh no. I didn't even see that there. I must have put itthere and forgot to take it out. There are only supposed to be the 4resistors. Thanks for telling me.

cliptwings (/member/cliptwings)Check out our new classes! >> (/classes/?utm_medium=cta&utm_source=banner)×

Page 9: U s i n g a 4 d i g i t , 7 s e g m e n t d i s p l a y, w ... … · If you connected the display correctly, uploaded the code correctly, and copied the coded just right, then your

Reply9 months ago

Reply9 months ago8

Reply

9 months ago

Reply9 months ago8

Reply10 months ago

Reply10 months ago8

Reply11 months ago

Reply11 months ago8

Thank you for the excellent demonstration. However, whenI used the fritzing schematic to set up my breadboardlayout, the display showed one segment out of place. I discovered that thedisplay's number 5 pin (segment g) and number 10 pin (segment f) wereswitched. When I connected the number 5 pin to arduino's number 12 pin, andattached the number 10 pin to arduiono's number 11 pin, the display workedperfectly. You might want to check your fritzing setup.

chickeneater (/member/chickeneater) (author) . cliptwings (/member/cliptwings)

Which color wires on the Fritzing picture are youtalking about?

cliptwings (/member/cliptwings) . chickeneater (/member/chickeneater)

Purple and yellow

chickeneater (/member/chickeneater) (author) . cliptwings (/member/cliptwings)

ok that makes sense because what I ended up doingwas switching the pin placement of everything for the number segmentsuntil they worked for every number, but I guess that I messed up. Nicecatch and thank you for telling me.

arunk63 (/member/arunk63)

i wonder how multiple digit able to display when you can give one number at atime ?

chickeneater (/member/chickeneater) (author) . arunk63 (/member/arunk63)

im confused about your question, can you clarify?

Thanks!

(https://cdn.instructables.com/FKA/U49C/IMDZDCNT/FKAU49CIMDZDCNT.LARGE.jpg)

chickeneater (/member/chickeneater) (author) . ВиталийЗ2 (/member/ВиталийЗ2)

Happy to help!

ВиталийЗ2 (/member/ВиталийЗ2) made it!

Check out our new classes! >> (/classes/?utm_medium=cta&utm_source=banner)×

Page 10: U s i n g a 4 d i g i t , 7 s e g m e n t d i s p l a y, w ... … · If you connected the display correctly, uploaded the code correctly, and copied the coded just right, then your

Reply11 months ago

Reply11 months ago

Replya year ago8

Replya year ago

Reply2 years ago

Reply2 years ago8

Reply2 years ago

Reply2 years ago8

But one question, from your picture it doesn't look like you are using anyresistors, am I correct or just going crazy? Because usually that burns outthe LEDs within the display.

ВиталийЗ2 (/member/ВиталийЗ2) . chickeneater (/member/chickeneater)

I'm using 7 segment KYX­3461AS Ifm=20mA, Vr=5v

ВиталийЗ2 (/member/ВиталийЗ2) . chickeneater (/member/chickeneater)

I'm just going crazy ))).

But it's working.

chickeneater (/member/chickeneater) (author)

np

GroundZero (/member/GroundZero)

Tnx for this tutorial :) it was very useful

julowsky (/member/julowsky)

If 8 320k resistors are used, which pins on the display would the 8 resistorsconnect to?

chickeneater (/member/chickeneater) (author) . julowsky (/member/julowsky)

Probably the segment pins which are the ones that arenot connected to a resistor in my schematic.

BTW if you connect those 8 resistors you wont need to connect the 4 thatare connected in my schematic

Thanks! I've just made it following your tutorial. I can confirm that the tutorialworks fine.

(https://cdn.instructables.com/FAT/I8GR/ICID28SD/FATI8GRICID28SD.LARGE.jpg)

mat_fr (/member/mat_fr)

curiosul (/member/curiosul) made it!

Check out our new classes! >> (/classes/?utm_medium=cta&utm_source=banner)×

Page 11: U s i n g a 4 d i g i t , 7 s e g m e n t d i s p l a y, w ... … · If you connected the display correctly, uploaded the code correctly, and copied the coded just right, then your

Reply2 years agoX|8

Reply2 years ago8

Nice. Note that with only 4 resistors on the common anode/cathode you limit thecurrent flowing through the whole digit, not the single segment. This means thatthe "8" digit having all segments ON will share the same current as the "1" digitwhich only has 2 segments ON. The result will be that the 8 digit will appeardimmer than the 1 digit. To resolve this "issue" you have to use a resistor on each segment, not eachdigit. This means using 7 or 8 (if you have a dot on the display) resistors, but itwill make the digits evenly bright.

tomatoskins (/member/tomatoskins)

7 segment displays are so helpful and fun to use! Thanks for sharing andwelcome to the community!

chickeneater (/member/chickeneater) (author) . tomatoskins(/member/tomatoskins)

No Problem.

If you or anyone else have any questions about this display, single digitdisplays, or Arduino and electronics in general, feel free to ask me.

­­Chickeneater Out­­

FEATURED CHANNELS

Woodworking(/tag/type­id/category­

workshop/channel­woodworking/)

Paper(/tag/type­id/category­craft/channel­

paper/)

Kitchen Hacks(/tag/type­id/keyword­

kitchen%20hacks/?sort=FAVORITES)

Puzzles(/tag/type­id/category­play/channel­puzzles/)

Laser Cutting(/tag/type­id/category­

workshop/channel­laser­cutting/)

Space(/tag/type­id/keyword­astronomy/?

sort=FAVORITES)

Homesteading(/tag/type­id/category­

home/channel­homesteading/)

3D Printing(/tag/type­id/category­

technology/channel­3D­Printing/)

Sewing(/tag/type­id/category­craft/channel­

sewing/)NewsletterJoin 2 million + to receive instantDIY inspiration in your inbox.

I'm in!

About UsWho We Are (/about/)Advertise (/advertise/)Contact (/about/contact.jsp)Jobs (/community/Positions­available­at­Instructables/)Help (/id/how­to­write­a­great­instructable/)

Find UsFacebook (http://www.facebook.com/instructables)

Youtube (http://www.youtube.com/user/instructablestv)

Twitter (http://www.twitter.com/instructables)

Pinterest (http://www.pinterest.com/instructables)

Google+ (https://plus.google.com/+instructables)

ResourcesFor Teachers (/teachers/)Artists in Residence (/air)Gift Premium Account (/account/give?sourcea=footer)Forums (/community/)Answers (/tag/type­question/?sort=RECENT)Sitemap (/sitemap/)

enter email

Terms of Service (http://usa.autodesk.com/adsk/servlet/item?siteID=123112&id=21959721) |Privacy Statement (http://usa.autodesk.com/adsk/servlet/item?siteID=123112&id=21292079) |Legal Notices & Trademarks (http://usa.autodesk.com/legal­notices­trademarks/) | Mobile Site (https://www.instructables.com)Check out our new classes! >> (/classes/?utm_medium=cta&utm_source=banner)×

Page 12: U s i n g a 4 d i g i t , 7 s e g m e n t d i s p l a y, w ... … · If you connected the display correctly, uploaded the code correctly, and copied the coded just right, then your

(http://usa.autodesk.com/adsk/servlet/pc/index?id=20781545&siteID=123112)© 2016 Autodesk, Inc.

Check out our new classes! >> (/classes/?utm_medium=cta&utm_source=banner)×