connect@howdiyworld.com
|

7 Segment Display

What is Needed?

7 Segment Display
Jumpers
HowDIY

BLOCK DIAGRAM

Procedure

  1. 7 Segment Display
  2. Connections
  3. Program
  4. Output

7 Segment Display

The 7segment displays are really just seven LEDs lined up in a particular pattern.

Seven-segment displays are widely used in digital clocks, electronic meters, basic calculators, and other electronic devices that display numerical information.

Connection

·       Connect the 7 Segment’s E to 24th pin.

·       Connect the 7 Segment’s D to 26th pin.

·       Connect the 7 Segment’s C to 31st pin.

·       Connect the 7 Segment’s G to 29th pin.

·       Connect the 7 Segment’s B to 33rd pin.

·       Connect the 7 Segment’s A to 35th pin.

·       Connect the 7 Segment’s F to 37th pin.

·       Connect the 7 Segment’s Common to 39th pin.

Program

import RPi.GPIO as GPIO

import time

GPIO.setwarnings(False)

GPIO.setmode(GPIO.BOARD)

GPIO.setup(24,GPIO.OUT)    #E

GPIO.setup(26,GPIO.OUT)    #D

GPIO.setup(29,GPIO.OUT)    #G

GPIO.setup(31,GPIO.OUT)    #C

GPIO.setup(33,GPIO.OUT)    #B

GPIO.setup(35,GPIO.OUT)    #A

GPIO.setup(37,GPIO.OUT)    #F

GPIO.output(24,False)    #E

GPIO.output(26,False)    #D

GPIO.output(29,False)    #G

GPIO.output(31,False)    #C

GPIO.output(35,False)    #A

GPIO.output(37,False)    #F

GPIO.output(33,False)    #B

def get_input(a):

if a==’1′:

one()

if a==’2′:

two()

if a==’3′:

three()

if a==’4′:

four()

if a==’5′:

five()

if a==’6′:

six()

if a==’7′:

seven()

if a==’8′:

eight()

if a==’9′:

nine()

if a==’0′:

zero()

if a=="ALL":

one()

two()

three()

four()

five()

six()

seven()

eight()

nine()

zero()

def one():

GPIO.output(33,True)

GPIO.output(31,True)

time.sleep(2)

GPIO.output(33,False)

GPIO.output(31,False)

def two():

GPIO.output(35,True)

GPIO.output(33,True)

GPIO.output(29,True)

GPIO.output(24,True)

GPIO.output(26,True)

time.sleep(2)

GPIO.output(35,False)

GPIO.output(33,False)

GPIO.output(29,False)

GPIO.output(24,False)

GPIO.output(26,False)

def three():

GPIO.output(26,True)    #D

GPIO.output(29,True)    #G

GPIO.output(31,True)    #C

GPIO.output(33,True)    #B

GPIO.output(35,True)    #A

time.sleep(2)

GPIO.output(26,False)    #D

GPIO.output(29,False)    #G

GPIO.output(31,False)    #C

GPIO.output(33,False)    #B

GPIO.output(35,False)    #A

def four():

GPIO.output(29,True)    #G

GPIO.output(31,True)    #C

GPIO.output(33,True)    #B

GPIO.output(37,True)    #F

time.sleep(2)

GPIO.output(29,False)    #G

GPIO.output(31,False)    #C

GPIO.output(33,False)    #B

GPIO.output(37,False)    #F

def five():

GPIO.output(26,True)    #D

GPIO.output(29,True)    #G

GPIO.output(31,True)    #C

GPIO.output(35,True)    #A

GPIO.output(37,True)    #F

time.sleep(2)

GPIO.output(26,False)    #D

GPIO.output(29,False)    #G

GPIO.output(31,False)    #C

GPIO.output(35,False)    #A

GPIO.output(37,False)    #F

def six():

GPIO.output(24,True)    #E

GPIO.output(26,True)    #D

GPIO.output(29,True)    #G

GPIO.output(31,True)    #C

GPIO.output(35,True)    #A

GPIO.output(37,True)    #F

time.sleep(2)

GPIO.output(24,False)    #E

GPIO.output(26,False)    #D

GPIO.output(29,False)    #G

GPIO.output(31,False)    #C

GPIO.output(35,False)    #A

GPIO.output(37,False)    #F

def seven():

GPIO.output(35,True)    #A

GPIO.output(33,True)    #B

GPIO.output(31,True)    #C

time.sleep(2)

GPIO.output(35,False)    #A

GPIO.output(33,False)    #B

GPIO.output(31,False)    #C

def eight():

GPIO.output(24,True)    #E

GPIO.output(26,True)    #D

GPIO.output(29,True)    #G

GPIO.output(31,True)    #C

GPIO.output(35,True)    #A

GPIO.output(37,True)    #F

GPIO.output(33,True)    #B

time.sleep(2)

GPIO.output(24,False)    #E

GPIO.output(26,False)    #D

GPIO.output(29,False)    #G

GPIO.output(31,False)    #C

GPIO.output(35,False)    #A

GPIO.output(37,False)    #F

GPIO.output(33,False)    #B

def nine():

GPIO.output(26,True)    #D

GPIO.output(29,True)    #G

GPIO.output(31,True)    #C

GPIO.output(35,True)    #A

GPIO.output(37,True)    #F

GPIO.output(33,True)    #B

time.sleep(2)

GPIO.output(26,False)    #D

GPIO.output(29,False)    #G

GPIO.output(31,False)    #C

GPIO.output(35,False)    #A

GPIO.output(37,False)    #F

GPIO.output(33,False)    #B

def zero():

GPIO.output(24,True)    #E

GPIO.output(26,True)    #D

GPIO.output(31,True)    #C

GPIO.output(35,True)    #A

GPIO.output(37,True)    #F

GPIO.output(33,True)    #B

time.sleep(2)

GPIO.output(24,False)    #E

GPIO.output(26,False)    #D

GPIO.output(31,False)    #C

GPIO.output(35,False)    #A

GPIO.output(37,False)    #F

GPIO.output(33,False)    #B

Output

Now in this screen you can set numbers from 0 to 9 and the number will be shown in the 7 segment display and if you click all button a countdown from 0 to 9 will start.

Social media & sharing icons powered by UltimatelySocial
Facebook
Twitter
YouTube
LinkedIn
Instagram