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]
4 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]4 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
How can I unblock Brainly?
aleksley [76]
Idk use another email or something
4 0
4 years ago
Read 2 more answers
Difference between windows 2000 professional and service pack
Rudiy27
The difference between a Windows 2000 Professional and a Service Pack is a Windows 2000 Professional has a better running quality than the Windows 2000 Service Pack. 

Higher quality

better storage 

by better i mean BIGGER STORAGE

HOPE THIS HELPS
5 0
4 years ago
Which asynchronous electronic community is also known as a forum?
Semmy [17]
What are the choices?
Message Boarding is the asynchronous electronic that is know as a forum.
3 0
4 years ago
Read 2 more answers
All the network nodes are connected to each other
Shalnov [3]
It’s a mesh topology
7 0
3 years ago
And this also please. help​
gregori [183]

Answer:

1. Scanner = reading passports.

2. Barcode reader = automatic stock control.

3. pH sensor = monitor soil in a greenhouse.

4. Microphone = voice recognition.

Explanation:

1. Scanner: Copies paper documents and converts the text and pictures into a computer-readable form. Therefore, it can be used for reading passports.

2. Barcode reader: reads labels containing parallel dark and light lines using laser light or LEDs; the width of each line represents a binary code. Therefore, it is used for automatic stock control.

3. pH sensor: detect changes in acidity levels; data is often in analogue form. Thus, it is typically used to monitor soil in a greenhouse.

4. Microphone: allows audio signals to be converted into electric signals; these can be interpreted by a computer after being converted into digital form. Microphones are used for voice recognition.

5 0
3 years ago
Other questions:
  • Determine the value of base x of (211)x=(152)8
    8·2 answers
  • If you like to interact with the game’s environment rather than with its inhabitants, which Bartle player type would you conform
    12·2 answers
  • Which one of the following terms is defined as the material and surfaces upon which an artist works?
    9·1 answer
  • ______________ helps you see how your document will appear on the paper. ​
    10·1 answer
  • Write a program that displays a menu allowing the user to select air water, or steel. After the user has made a selection, the n
    10·1 answer
  • Is the Internet dangerous?
    10·2 answers
  • Complete the function to return the factorial of the parameter,
    9·2 answers
  • In design and implementation of any _____ reasoning application, there are 4 Rs involved: retrieve, reuse, revise, and retain.
    7·1 answer
  • Which of these is a standard for describing a wifi network?
    14·1 answer
  • What facilitates the automation and management of business processes and controls the movement of work through the business proc
    9·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!