Question

In: Computer Science

TASK: Your task is as follows: (1) Place SN74LS42N (4 to 10 decoder) on a breadboard;...

TASK: Your task is as follows:
(1) Place SN74LS42N (4 to 10 decoder) on a breadboard;
(2) Connect IC pin 8 to GND and IC pin 16 to +5 V for IC to get powered;
(3) Connect GPIO pins to BCD inputs, as follows:
- connect GPIO pin 12 to IC pin 12 (8’s column),
- connect GPIO pin 16 to IC pin 13 (4’s column),
- connect GPIO pin 20 to IC pin 14 (2’s column) and
- connect GPIO pin 21 to IC pin 15 (1’s column).
(4) Connect GPIO pins to DEC Outputs, as follows:
- connect GPIO pin 25 to IC pin 9,
- connect GPIO pin 8 to IC pin 10,
- connect GPIO pin 7 to IC pin 11,
- connect GPIO pin 26 to IC pin 1,
- connect GPIO pin 19 to IC pin 2,
- connect GPIO pin 13 to IC pin 3,
- connect GPIO pin 6 to IC pin 4,
- connect GPIO pin 5 to IC pin 5,
- connect GPIO pin 11 (SCLK) to IC pin 6 and
- connect GPIO pin 9 (MISO) to IC pin 7.
(5) Connect LEDs and resisters, as follows:
- connect LEDs’ anode (+) to GPIO pins 12, 16, 20 and 21,
- connect LEDs’ cathode (-) to one end of resisters and
- connect the other end of resisters to GND.
(6) Develop a python program to generate a random number using random.randint(0,9) (you need import random) and assign this generated number to DEC, instead of manual input. Convert the random number DEC to a 4-bit binary number and generate the binary signal based on the binary number. Check which decimal outputs D0 – D9 are true/false (on/off).

Solutions

Expert Solution

PROGRAM :

import random
import RPi.GPIO as GPIO # import RPi.GPIO module
GPIO.setmode(GPIO.BCM) # choose BCM or BOARD
GPIO.setup(12, GPIO.OUT) # set a port/pin as an output
GPIO.setup(16, GPIO.OUT) # set a port/pin as an output
GPIO.setup(20, GPIO.OUT) # set a port/pin as an output
GPIO.setup(21, GPIO.OUT) # set a port/pin as an output
GPIO.setup(25, GPIO.IN) # set a port/pin as an Input
GPIO.setup(8, GPIO.IN) # set a port/pin as an Input
GPIO.setup(7, GPIO.IN) # set a port/pin as an Input
GPIO.setup(26, GPIO.IN) # set a port/pin as an Input
GPIO.setup(19, GPIO.IN) # set a port/pin as an Input
GPIO.setup(13, GPIO.IN) # set a port/pin as an Input
GPIO.setup(6, GPIO.IN) # set a port/pin as an Input
GPIO.setup(5, GPIO.IN) # set a port/pin as an Input
GPIO.setup(11, GPIO.IN) # set a port/pin as an Input
GPIO.setup(9, GPIO.IN) # set a port/pin as an Input


  

DEC=random.randint(0,9)


binary= [int(i) for i in bin(DEC)[2:]] # Decimal to binary number conversion

while(len(binary)<4): #adding bit 0 in left to make it 4 bit
  
binary.insert(0,0)

lst=[12,16,20,21]
j=0
for i in binary: #Loading Binary value to DEC input pins
if i==0:
GPIO.output(lst[j], 0) # set port/pin value to 0/GPIO.LOW/False

else:
GPIO.output(lst[j], 1) # set port/pin value to 1/GPIO.HIGH/True

print("The Decimal outputs are (25,8,7,26,19,13,6,5,11,9)respctively ")
print GPIO.input(25)
print GPIO.input(8)
print GPIO.input(7)
print GPIO.input(26)
print GPIO.input(19)
print GPIO.input(13)
print GPIO.input(6)
print GPIO.input(5)
print GPIO.input(11)
print GPIO.input(9)

Note :This programm use gpio pins hence i have imported raspberry pi 's GPIO library as a model but you can import library of your board if yor not using raspberry pi.


Related Solutions

Code a 2:4 decoder with registered out. Also write a testbench of the decoder.
Code a 2:4 decoder with registered out. Also write a testbench of the decoder.
Your task is to place your spacecraft in circular orbit about Mars with an orbital period...
Your task is to place your spacecraft in circular orbit about Mars with an orbital period of 8 hours and 40 minutes. The mass of Mars is 6.45 x 1023 kg, and the radius of Mars is 3394 km. What will be the radius of your circular orbit?
Design a decoder counter MOD '10' that counts from 0-9 using 4 flip flops and a...
Design a decoder counter MOD '10' that counts from 0-9 using 4 flip flops and a NAND gate.
Task 4 . . . . . . . . . . . . . ....
Task 4 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Consider a disk drive with 2,000 tracks, numbered 0 to 1,999. The...
Task 1: [10 Marks] Write a function “reverse” in your queue class (linked list implementation) that...
Task 1: [10 Marks] Write a function “reverse” in your queue class (linked list implementation) that reverses the whole queue. In your driver file (main.cpp), create an integer queue, push some values in it, call the reverse function to reverse the queue and then print the queue.
Perform each task, given the following sample data. (Round your answers to one decimal place.) 7...
Perform each task, given the following sample data. (Round your answers to one decimal place.) 7 11 12 12 11 18 6 (a) Use the Sample Variance Definition to find the variance and standard deviation of the data. variance     standard deviation     (b) Use the Alternative Formula for Sample Variance to find the variance and standard deviation of the data. variance     standard deviation    
1.) FIFO 2.) LIFO 3.) WEIGHTED AVERAGE 4.) SPECIFIC ITEM So your task to start this...
1.) FIFO 2.) LIFO 3.) WEIGHTED AVERAGE 4.) SPECIFIC ITEM So your task to start this discussion is to define each AND give an example
Create a 4-bit Register This is very similar to your flip-flop design from lab task 1....
Create a 4-bit Register This is very similar to your flip-flop design from lab task 1. Ensure that your 4-bit register has inputs “D” (dat, “CLK” (the clock), and “RST” (an asynchronous reset), and an output “Q”. [3 pts] Create a test bench and ensure that your 4-bit register operates correctly (test your reset signal and ensure that you can store a couple different values in the register). If your output behavior is correct, then copy your VHDL design code...
If you only had 4:16 One Hot Decoder and an OR gate with the number of...
If you only had 4:16 One Hot Decoder and an OR gate with the number of inputs of your choosing, fill in the blanks to explain how you would implement the function with the hardware you were provided. There are 4 inputs for this function, 1) I would choose an OR gate with (2, 3, 4, ..., 16) inputs 2) For input  , I would connect it to input (0, 1, 2, 3) of the decoder 3) For input , I...
If you only had 4:16 One Hot Decoder and an OR gate with the number of...
If you only had 4:16 One Hot Decoder and an OR gate with the number of inputs of your choosing, fill in the blanks to explain how you would implement the function x 3 x 2 x 1 ¯ + x 3 ¯ x 2 ¯ x 0 with the hardware you were provided. There are 4 inputs for this function, x 3 − x 0 1) I would choose an OR gate with (2, 3, 4, ..., 16) inputs...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT