1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
ANTONII [103]
3 years ago
13

Write a program in C that reads a 3-bit desired light pattern from the 3 input switches connected to pins P2.3-P2.5 and displays

the pattern on the 8 LEDs (pins P1.0-P1.7) with some ""light playing"" options based on the input from other 3 switches (pins P2.0-P2.2).
Computers and Technology
1 answer:
laiz [17]3 years ago
8 0

Answer:

Check the explanation

Explanation:

#include<stdio.h>

main()

{ int k=1,p,l,i;

int p2[8],p1[8];

for(i=0;i<8;i++){

p1[i]=0;

p2[i]=0;

}

while(k==1)

{

printf("enter the pin inputs from p2.3-p2.5:");

scanf("%d%d%d",&p2[3],&p2[4],&p2[5]);

 

printf("Press Logic 0 for on and 1 for off on switch port p2.0\n");

scanf("%d",&l);

p1[3]=p2[3];

p1[4]=p2[4];

p1[5]=p2[5];

if(l==0)

{p=1;

for(i=0;i<8;i++)

printf("p1.%d : %d\n",i,p2[i]);

printf("\n press either 1 to continue or 0 to stop :");

scanf("%d",&p);

printf("\n");

while(p==1)

{ printf("enter the pin inputs from p2.3-p2.5:");

scanf("%d%d%d",&p2[3],&p2[4],&p2[5]);

p1[3]=p2[3];

p1[4]=p2[4];

p1[5]=p2[5];

for(i=0;i<8;i++)

printf("p1.%d : %d\n",i,p2[i]);

printf("\n press either 1 to continue or 0 to stop :");

scanf("%d",&p);

printf("\n");

}

}

else

{

printf("After Rotation of pattern :\n");

for(i=0;i<8;i++)

{ if(p2[i]==0)

printf("p1.%d : 1\n",i);

else

printf("p1.%d : 0\n",i);

}

}

printf("press 0 for on and 1 for off on switch port p2.1 :\n");

scanf("%d",&l);

if(l==0)

{ printf("\nLeft Rotation of pattern from read mode :\n");

printf("p1.0 : %d\n",p1[0]);

printf("p1.1 : %d\n",p1[5]);

printf("p1.2 : %d\n",p1[6]);

printf("p1.3 : %d\n",p1[3]);

printf("p1.4 : %d\n",p1[2]);

printf("p1.5 : %d\n",p1[1]);

printf("p1.7 : %d\n",p1[6]);

printf("p1.7 : %d\n",p1[7]);

}

else

{printf("\nRight rotation of pattern from read mode: \n");

printf("p1.0 : %d\n",p1[0]);

printf("p1.1 : %d\n",p1[1]);

printf("p1.2 : %d\n",p1[2]);

printf("p1.3 : %d\n",p1[7]);

printf("p1.4 : %d\n",p1[6]);

printf("p1.5 : %d\n",p1[5]);

printf("p1.7 : %d\n",p1[4]);

printf("p1.7 : %d\n",p1[3]);

}

printf("press 0 for on and 1 for off on switch port p2.2 :\n");

scanf("%d",&l);

if(l==0)

printf("Make Rotation fast\n");

else

printf("Make Rotation slow\n");

printf("Enter 1 to continue or 0 to exit:");

scanf("%d",&k);

printf("\n");

}

}

You might be interested in
What is the basic unit for storing data in exel
PtichkaEL [24]
A cell is the basic unit for storing data in exel
7 0
3 years ago
What are the limits of hashing and verifying that files haven’t changed?
earnstyle [38]

The hashing function can take any number of key-value pairs and there is no specific limit to it.

<h3>What is hashing?</h3>

Hashing is a file-based algorithm for producing a fixed-length bit string value. A file is essentially a collection of data blocks. The length of the data is reduced by hashing to a fixed number or key that represents the original string.

When hashing is employed, the hash function may plot all of the keys and values to what the real size of the table is, demonstrating that the hashing function can take any number of key-value pairs with no restriction.

However, if the passwords are hashed in encryption, recovering the passwords is extremely difficult.

Thus, the hashing function can take any number of key-value pairs and there is no specific limit to it.

Learn more about the hashing here:

brainly.com/question/13106914

#SPJ1

5 0
1 year ago
Which team won the first World Series ?
Ulleksa [173]
Boston Red Sox, Boyo
5 0
3 years ago
Read 2 more answers
Consider the following code:
weqwewe [10]

Answer:

252

Explanation:

I tested the code and it outputted 252

hope i helped :D

4 0
3 years ago
Which education level has the highest return on investment (ROI)? AHigh School Diploma BROI is equal for all of the above. CSeni
KonstantinChe [14]
A is the best choice , because if you dont graduate high school , there is no chance you can be anything 
6 0
3 years ago
Other questions:
  • Algorithm for converting decimal into binary.
    7·1 answer
  • What is a way to minimize technical problems with computer
    13·1 answer
  • Convert the following pseudi code to C++ code. BE sure to define the apprpriat evariables.
    9·1 answer
  • Which option marks all modification made within a document? Review Comment Track Changes Balloons
    15·2 answers
  • 3. What are the first steps that you should take if you are unable to get onto the Internet? (1 point)
    15·1 answer
  • May someone type this down below just like how it is shown in the picture.
    7·1 answer
  • A firm offers virtual local area networks and firewalls as an on-demand cloud service. Which service does the firm offer?
    11·2 answers
  • Which Artificial Intelligence (AI) term is used to describe extracting information from unstructured text using algorithms?
    8·1 answer
  • Consumers who wish to make a purchase from other consumer on ebay need tl
    10·1 answer
  • How to convert binary to decimal <br> Please it’s so hard and what is digital and analogue
    9·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!