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
solmaris [256]
3 years ago
15

Write a program to control the operation of the RED/GREEN/BLUE LED (LED2) as follows: 1. If no button is pressed, the LED should

remain OFF. 2. When only Button 1 is pressed, the BLUE LED should blink ON and OFF with a 1 second period. The RED and GREEN LEDs should remain OFF. 3. When only Button 2 is pressed, the RED LED should blink ON and OFF with a 4 second period. The GREEN and BLUE LEDs should remain OFF. 4. When both Buttons are pressed, the GREEN LED should blink ON and OFF with a 2 second period. The RED and BLUE LEDs should remain OFF. 5. At no time should two LEDs be on. The states of the Buttons and LEDs are described in Ta
Engineering
1 answer:
aalyn [17]3 years ago
4 0

Answer:

See explaination

Explanation:

int RED=10; int BLUE=11; int GREEN=12; int BUTTON1=8; int BUTTON2=9; void setup() { pinMode(RED, OUTPUT); pinMode(BLUE, OUTPUT); pinMode(GREEN, OUTPUT); pinMode(BUTTON1, INPUT); pinMode(BUTTON2, OUTPUT); } void loop() { int BTN1_STATE=digitalRead(BUTTON1); int BTN2_STATE=digitalRead(BUTTON2); if(BTN1_STATE==HIGH) { digitalWrite(BLUE, HIGH); delay(1000); // Wait for 1 second digitalWrite(BLUE, LOW); } if(BTN2_STATE==HIGH) { digitalWrite(RED, HIGH); delay(4000); // Wait for 4 seconds digitalWrite(RED, LOW); } if(BTN1_STATE==HIGH && BTN2_STATE==HIGH) { digitalWrite(GREEN, HIGH); delay(2000); // Wait for 2 second digitalWrite(GREEN, LOW); } }

You might be interested in
Write a iterative function that finds the n-th integer of the Fibonacci sequence. Then build a minimal program (main function) t
Natasha2012 [34]

Answer:

Codes for each of the problems are explained below

Explanation:

PROBLEM 1 IN C++:

#include<iostream>

using namespace std;

//fib function that calculate nth integer of the fibonacci sequence.

void fib(int n){

  // l and r inital fibonacci values for n=1 and n=2;

  int l=1,r=1,c;

 

  //if n==1 or n==2 then print 1.

  if(n==1 || n==2){

      cout << 1;

      return;

  }

  //for loop runs n-2 times and calculates nth integer of fibonacci sequence.

  for(int i=0;i<n-2;i++){

      c=l+r;

      l=r;

      r=c;

      cout << "(" << i << "," << c << ") ";

  }

  //prints nth integer of the fibonacci sequence stored in c.

  cout << "\n" << c;

}

int main(){

  int n; //declared variable n

  cin >> n; //inputs n to find nth integer of the fibonacci sequence.

  fib(n);//calls function fib to calculate and print fibonacci number.

}

PROBLEM 2 IN PYTHON:

def fib(n):

   print("fib({})".format(n), end=' ')

   if n <= 1:

       return n

   else:

       return fib(n - 1) + fib(n - 2)

if __name__ == '__main__':

   n = int(input())

   result = fib(n)

   print()

   print(result)

7 0
3 years ago
Read 2 more answers
What is the diffrence between a small block and a big block lets see if yall know
ivann1987 [24]

Answer:

The difference in weight and size?

Explanation:

It explains itself :P

5 0
1 year ago
Create a flowchart that describes the following algorithm and then write Python code to implement the algorithm. Write the Pytho
Naya [18.7K]

Answer:

<em>Python code is as follows: </em>

********************************************************************************

#function to get number up to any number of decimal places

def toFixed(value, digits):

return "%.*f" % (digits, value)

print("Enter the price: ", end='', flush=True) #prompt for the input of price

price = float(input()) #taken input

totalCost = price + 0.05 * price #calculating cost

print("Total Cost after the sales tax of 5% is applied: " + toFixed(totalCost,2)) #print and output totalCost

************************************************************************************

3 0
3 years ago
8. When supplying heated air for a building, one often chooses to mix in some fresh outside air with air that has been heated fr
Afina-wow [57]

Answer:

Check the explanation

Explanation:

Kindly check the attached images below to see the step by step explanation to the question above.

5 0
3 years ago
Given the following access-control list: access-list 90 deny 10.168.7.0 0.0.0.255 access-list 90 permit host 10.168.7.10 access-
Yuri [45]

Answer:

D. Both hosts 10.168.7.10 and 10.168.7.11 will be permitted

Explanation:

access-list 90

deny 10.168.7.0 0.0.0.255

permit 10.168.7.10

permit 10.168.7.11

permit 10.168.7.12

deny any

7 0
3 years ago
Other questions:
  • Input signal to a controller is​
    9·1 answer
  • Air enters a well-insulated turbine operating at steady, state with negligible velocity at 4 MPa, 300°C. The air expands to an e
    10·1 answer
  • Name the important trees of tropical monsoon forest​
    11·1 answer
  • An alloy is evaluated for potential creep deformation in a short-term laboratory experiment. The creep rate is found to be 1% pe
    7·1 answer
  • A 230 V shunt motor has a nominal armature current of 60 A. If the armature resistance is 0.15 ohm, calculate the following: a.
    5·1 answer
  • Has anyone lost faith in humanity ✌️
    7·1 answer
  • The website of a bank that an organization does business with has been reported as untrusted by the organization's web browser.
    12·1 answer
  • A particular cloud-to-ground lightning strike lasts 500 µµsec and delivers 30 kA across a potential difference of 100 MV. Assu
    14·1 answer
  • Close to 16 billion pounds of ethylene glycol (EG) were produced in 2013. It previously ranked as the twenty-sixth most produced
    8·1 answer
  • Andy is a carpenter and wants to make various articles using engineered wood. Which of these wood types can he use?
    8·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!