Question

Write a program using a counter that performs the following operation: 1. Turn on PL1 when the count is 6. 2. Turn ON PL2 when the count is 12- at which time PL1 should turn off. 3. Turn ON PL3 when the count is between 16 to 20- at which time PL2 should 4. 5. turn off. Turn off all the lights for count values greater than 20 and less than 25. Reset the counter to O when count is 25.
0 0
Add a comment Improve this question Transcribed image text
Answer #1

As per above image, You have not specified any language to code it.

I am writing this code in java language.

//java program

public class Lights{

public static int PL1=0,PL2=0,PL3=0;

static void PL1(){

PL1=1;

}

static void PL2(){

PL1=0;

PL2=1;

}

static void PL3(){

PL1=0;

PL2=0;

PL3=1;

}

static void PL4(){

PL1=0;

PL2=0;

PL3=0;

}

public static void main(String args[]){

for(int i=0;i<=25;i++){

if(i==6) {

PL1();

System.out.println("Counter:"+i+" PL1:"+Lights.PL1+" PL2:"+PL2+" PL3:"+PL3);

}

else if(i==12) {

PL2();

System.out.println("Counter:"+i+" PL1:"+PL1+" PL2:"+PL2+" PL3:"+PL3);

}

else if(i>=16 && i<=20) {

PL3();

System.out.println("Counter:"+i+" PL1:"+PL1+" PL2:"+PL2+" PL3:"+PL3);

}

else if(i>20 && i<25){

PL4();

System.out.println("Counter:"+i+" PL1:"+PL1+" PL2:"+PL2+" PL3:"+PL3);

}

else if(i==25){

System.out.println("Counter:"+i);

i=0;

System.out.println("Resetting Counter to:"+i);

break;

}

else{

System.out.println("Counter:"+i+" PL1:"+PL1+" PL2:"+PL2+" PL3:"+PL3);  

}

}

}

}

Add a comment
Know the answer?
Add Answer to:
Write a program using a counter that performs the following operation: 1. Turn on PL1 when...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • 9. Consider a PLC system with the following inputs and outputs. Design a ladder diagram that...

    9. Consider a PLC system with the following inputs and outputs. Design a ladder diagram that does the following: • A timer counts up to 1.5 seconds, resets itself, and then repeats Every time S1 is on and the timer makes it to 1.5 seconds, a counter increments its accumulated value. PL1 turns on any time that the count of the counter is 20 or higher. The counter should be reset whenever PL1 is first turned on (i.e. transitions from...

  • Consider a PLC system with the following inputs and outputs. Design a ladder diagram using one an...

    Consider a PLC system with the following inputs and outputs. Design a ladder diagram using one and only one counter instruction and as many timers as you need that does the following: 9. Every time S1 is turned from off to on, it causes a counter to increment its accumulated value. . Any time that S1 stays on for 10 seconds, PL1 should light until $1 is turned back off " Any time that S1 is on, PL2 flashes on...

  • Write a program that will turn a light on when a count reaches 20. The light...

    Write a program that will turn a light on when a count reaches 20. The light is then to go off when a count of 30 is reached. (You must use two counters for this problem, and provide a reset function for the counters).

  • Write a program that will turn a light on when a count reaches 20. The light...

    Write a program that will turn a light on when a count reaches 20. The light is then to go off when a count of 30 is reached. (You must use two counters for this problem, and provide a reset function for the counters).

  • Assume you are hired to write a program for a company that manufactures electronic components. The...

    Assume you are hired to write a program for a company that manufactures electronic components. The system is shown in the figure below. A controller stops the take-up spool at a predetermined amount of resistors (75). A worker on the floor then cuts the resistor strip and places it in a kit. Write a program to count and control the number of resistors placed into each kit. THIS HAS TO BE WRITTEN IN LADDER LOGIC. The controller operates as follows:...

  • Prime Number Programing in C Note: The program is to be written using the bitwise operation....

    Prime Number Programing in C Note: The program is to be written using the bitwise operation. Use an integer array (not a Boolean array) and a bit length (for instance 32 bits). In this program you will write a C program to find all prime numbers less than 10,000. You should use 10,000 bits to correspond to the 10,000 integers under test. You should initially turn all bits on (off) and when a number is found that is not prime,...

  • Microcontroller programming exercises by practice on Arduino: Write a program that lights a green LED attached...

    Microcontroller programming exercises by practice on Arduino: Write a program that lights a green LED attached to pin 3. The green LED should turn off after a button attached to pin4 has been pushed and released 3 times. Each time the button is pushed it will turn on a red LED attached to pin 7 and turn off a yellow LED attached to pin 9. When the button is not pushed the red LED will be off and the yellow...

  • Write a C++ Program that simulates a basic calculator using functions which performs the operations of...

    Write a C++ Program that simulates a basic calculator using functions which performs the operations of Addition, Subtraction, multiplication, and Division. ( make sure you cover the case to avoid division by a zero) Display a menu for list of operations that can be calculated and get the input from user about his choice of calculation. Based on user choice of operation, take the input of number/numbers from user. Assume all input values are of type double. Calculations must be...

  • Write a C++ Program that simulates a basic calculator using functions which performs the operations of...

    Write a C++ Program that simulates a basic calculator using functions which performs the operations of Addition, Subtraction, multiplication, and Division. ( make sure you cover the case to avoid division by a zero) Display a menu for the list of operations that can be calculated and get the input from the user about his choice of calculation. Based on user choice of operation, take the input of number/numbers from user. Assume all input values are of type double. Calculations...

  • Write a python program and pseudocode The Program Using Windows Notepad (or similar program), create a...

    Write a python program and pseudocode The Program Using Windows Notepad (or similar program), create a file called Numbers.txt in your the same folder as your Python program. This file should contain a list on floating point numbers, one on each line. The number should be greater than zero but less than one million. Your program should read the following and display: The number of numbers in the file (i.e. count them) (counter) The maximum number in the file (maximum)...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT