answer.
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]
1 year 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]1 year 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
Select all the activities Samil could so through his banking app.
lisabon 2012 [21]

Answer:

Make a deposit

Talk to a representative

Transfer money

Check account balances

Explanation:

3 0
1 year ago
Read 2 more answers
a. a large central network that connects other networks in a distance spanning exactly 5 miles. b. a group of personal computers
ki77a [65]

Complete Question:

A local area network is:

Answer:

b. a group of personal computers or terminals located in the same general area and connected by a common cable (communication circuit) so they can exchange information such as a set of rooms, a single building, or a set of well-connected buildings.

Explanation:

A local area network (LAN) refers to a group of personal computers (PCs) or terminals that are located within the same general area and connected by a common network cable (communication circuit), so that they can exchange information from one node of the network to another. A local area network (LAN) is typically used in small or limited areas such as a set of rooms, a single building, school, hospital, or a set of well-connected buildings.

Generally, some of the network devices or equipments used in a local area network (LAN) are an access point, personal computers, a switch, a router, printer, etc.

4 0
1 year ago
Jefferson is interested in starting his own business. He plans to borrow money from the local bank in order to finance the busin
sweet [91]
A business plan and a <u>financial plan</u> to show the both his plan to make money, and how much money he will make, spend, use.
8 0
1 year ago
Read 2 more answers
Import java.util.scanner; public class sumofmax { public double findmax(double num1, double num2) { double maxval; // note: if-e
jeyben [28]

Here you go,


Import java.util.scanner

public class SumOfMax {

   public static double findMax(double num1, double num2) {

       double maxVal = 0.0;

       // Note: if-else statements need not be understood to

       // complete this activity

       if (num1 > num2) { // if num1 is greater than num2,

           maxVal = num1; // then num1 is the maxVal.

       }

       else { // Otherwise,

           maxVal = num2; // num2 is the maxVal.

       }

       return maxVal;

   }

   public static void main(String[] args) {

       double numA = 5.0;

       double numB = 10.0;

       double numY = 3.0;

       double numZ = 7.0;

       double maxSum = 0.0;

       /* Your solution goes here */

       maxSum = findMax(numA, numB); // first call of findMax

       maxSum = maxSum + findMax(numY, numZ); // second call

       System.out.print("maxSum is: " + maxSum);

       return;

   }

}

/*

Output:

maxSum is: 17.0

*/

6 0
2 years ago
Write any 5 activities that help to remove bad events from the society?​
vova2212 [387]

Answer:

1. Awareness program

2. Education

3. women empowerment

6 0
1 year ago
Read 2 more answers
Other questions:
  • The memory allocated for a float value is ____ bytes.
    9·1 answer
  • Which computer applications can Mr. Crowell use to make the classroom learning more stimulating and interesting? Mr. Crowell has
    9·2 answers
  • Write a copy constructor for carcounter that assigns origcarcounter.carcount to the constructed object's carcount. sample output
    15·2 answers
  • c++ Consider this data sequence: "3 11 5 5 5 2 4 6 6 7 3 -8". Any value that is the same as the immediately preceding value is c
    14·2 answers
  • When trying to improve performance of a slow system, you notice in Task Manager that the superfetch service is using a high perc
    11·1 answer
  • The icacls.exe command adds __________, which are visible by clicking the Advanced button in the folder Properties dialog box
    15·1 answer
  • The Pentium 4 Prescott processor, released in 2004, had a clock rate of 3.6 GHz and voltage of 1.25 V. Assume that, on average,
    8·1 answer
  • With respect to the general classes of computers, a ________ is the most expensive and most powerful kind of computer, which is
    7·1 answer
  • You need to design a data storage scheme for Hayseed Heaven library data system. There are several hundred thousand large data r
    8·1 answer
  • Write a method called printRangeOfNumbers that accepts a minimum, maximum numbers as parameters and prints each number from mini
    6·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!