Question

1. Which input conditions cause the IF statement to evaluate as true? (some may be more...

1. Which input conditions cause the IF statement to evaluate as true? (some may be more than 1 input pin)

if ( (PINB & 0x20) != 0 ) EXAMPLE: PB5 = 1

if ( (PINC & 0x80) == 0 )

if ( (PIND & 0x01) != 0 )

if ( (PINB & 0x03) == 0 )

if ( (PINB & 0x06) == 4 )

Write a complete program (without Arduino commands) to toggle LED-PD6 if PB0 is pressed, and toggle LED-PD7 if PB1 is pressed.

Homework Answers

Answer #1

Answer :-

if ( (PINB & 0x20) != 0 ) EXAMPLE: PB5 = 1, because 0x20 = 0010_0000 so PB5 must be 1, then only if condition will be true.

if ( (PINC & 0x80) == 0 ) , 0x80 = 1000_0000 so PC7 bit must be 0, then we will get AND operation result as zero. Hence if condition will be true.

if ( (PIND & 0x01) != 0 ), 0x01 = 0000_0001 so PD0 pin must be 1, then AND operation results as 1. Hence if condition will be true.

if ( (PINB & 0x03) == 0 ), 0x03 = 0000_0011 so PB0 and PB1 both should be 0 then AND operation results 0. Hence if condition will be true.

if ( (PINB & 0x06) == 4 ), 0x06 = 0000_0110 so PB1 must be 1 and PB2 must be 0 then AND operation will result 4. Hence if condition will be true.

Dear student, please make me clear about " Not Using Arduino Command". Is it not using arduino functions like "digitalRead() or digitalWrite()". You can comment on this. Thank You.

Know the answer?
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
Similar Questions
Problem 1 Consider the discrete-time LTI system characterized by the following difference equation with input and...
Problem 1 Consider the discrete-time LTI system characterized by the following difference equation with input and initial conditions specified: y[n] - 2 y[n-1] – 3 y[n-2] = x[n] , with y[0] = -1 and y[1] = 0, x[n] = (-1/2)n u[n-2]. ? Write a MATLAB program to simulate this difference equation. You may try the commands ‘filter’ or ‘filtic’ or create a loop to compute the values recursively. ? Printout and plot the values of the input signal, x[n] and...
Evaluate these two statement given; is it true or false statement. Explain why your answer. 1....
Evaluate these two statement given; is it true or false statement. Explain why your answer. 1. Elastic potential energy can be either positive, zero or negative 2. When a spring is stretched by 2 cm, it has more elastic potential energy than when it is compressed by 2 cm.
Which statement about tuberculosis (TB) is true? 1.Meningitis is the leading cause of death from tuberculosis....
Which statement about tuberculosis (TB) is true? 1.Meningitis is the leading cause of death from tuberculosis. 2.Chemotherapy, if made widely available, could eradicate the disease. 3.TB is a common co-morbidity in HIV patients 4.The TB bacillus is difficult to isolate.
Write a method which takes as input an integer, returns true if the integer is prime,...
Write a method which takes as input an integer, returns true if the integer is prime, and returns false otherwise. Do not import anything. If the input is negative, 0 or 1, false should be returned. If the input x is greater than 1, you can test if it is prime (inefficiently) by checking if it is divisible by any integer from 2 up to half of x. If it is not divisible by any of these numbers, then it...
1. In underground mining, a mine drift usually undergoes some deformation, which may cause stability problems...
1. In underground mining, a mine drift usually undergoes some deformation, which may cause stability problems to the drift if the ground is not supported properly. a) What is the main objective of providing ground support for stress induced deformation? b) Discuss the interaction between the rockmass and ground support in terms of stress and deformation. c) List the following commonly used ground support systems and their applications: mechanical bolt, grouted bolt, frictional bolt, cable bolt, shotcrete/wire mech. Pay attention...
Which of the following is true with regard to a P-value? (More than one answer may...
Which of the following is true with regard to a P-value? (More than one answer may be correct.) a. The P-value is generated under the assumption that the null hypothesis is true. b. The P- value may be negative in some tests. c. If the P-Value is below 5% in a 5% significance level, then the null hypothesis will be rejected. d. In a left-tailed test if the P-Value is 100%, the sample statistic equals the population value as stated...
Is each statement True or False: 1) Prions are smaller than viruses, which are affected by...
Is each statement True or False: 1) Prions are smaller than viruses, which are affected by radiation. 2) Prions do not contain genetic information, which is affected by ionizing radiation. 3) Denaturants may affect the tertiary structure of prions. 4)Prions are proteins
Question 3 (1 point) Which of the following reasons is why SR latches are not used...
Question 3 (1 point) Which of the following reasons is why SR latches are not used to store modern memory? Question 3 options: Ability to store 1 bit. Immune to timing issues. Ability to be implemented with gates. Timing issues. Question 4 (1 point) Which of the following differentiates a latch and a flip flop? Question 4 options: Usage of a clock. Cannot toggle. Significantly less gates needed for implementation. Ability to store more than one bit. Question 5 (1...
Write the function has duplicate() which takes as input a vector v and outputs true if...
Write the function has duplicate() which takes as input a vector v and outputs true if there is a re- peated element in v and false if there is no repeated elements. Below is the algorithm which you should implement. default output is 0 for elt1 in v: for elt2 later in v than elt1: if elt1==elt2, make output 1, break, end end end Checking if elt1==elt2 counts as one step. Setting the output value also counts as one step....
Part A. Input Validation (Name your C program yourLastName_yourFirstName_Lab4a.c) 1. Place the code you developed in...
Part A. Input Validation (Name your C program yourLastName_yourFirstName_Lab4a.c) 1. Place the code you developed in Lab 2 to obtain a diameter value from the user and compute the volume of a sphere (we assumed that to be the shape of a balloon) in a new program, and implement the following restriction on the user’s input: the user should enter a value for the diameter which is at least 8 inches but not larger than 60 inches. Using an if-else...