Question

In C, if you are using interrupts for when a button is pressed, how would you...

In C, if you are using interrupts for when a button is pressed, how would you use the value you stored in interrupt 1 when (button 1 was pressed) to interrupt 2 when (button 2 was pressed)?

Homework Answers

Answer #1

const byte ledPin = 1;
const byte interruptPin = 2;
volatile byte state = LOW;

void setup() {
  pinMode(ledPin, OUTPUT);
  pinMode(interruptPin, INPUT_PULLUP);
  attachInterrupt(digitalPinToInterrupt(interruptPin), blink1, CHANGE);
}

void loop() {
  digitalWrite(ledPin, state);
}

void blink1() {
state = !state;
}

see the first line, by setting the appropriate value of button numbers, and associtating related interrupting fuctions we can achieve the said functionality

this is simplest code for the said problem, but based on more information enhanced code can be developed.

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
In C, if you are using interrupts for when a button is pressed, how would you...
In C, if you are using interrupts for when a button is pressed, how would you use the value you stored in interrupt 1 when (button 1 was pressed) to interrupt 2 when (button 2 was pressed)? example, If I press button 1, and the value I have is 5. How would I transfer the value (v = 5) in interrupt 1 to interrupt 2 when I press the button 2 to place in an equation T = 26 +...
Using pulse width modulation and interrupts create a code in adruino where you will push a...
Using pulse width modulation and interrupts create a code in adruino where you will push a button on the MCU which triggers an interrupt. Once triggered, the LED on the development board must fade-in (min to max intensity) for 2 seconds, stay at maximum brightness for 5 seconds, and then fade-out (max brightness to off) with a duration again of two seconds. cannot make use of "delay" or equivalent routines to implement the 2 or 5 second intervals but must...
JavaScript When the button is pressed, the application should prompt the user to enter a string...
JavaScript When the button is pressed, the application should prompt the user to enter a string or ‘***’ to quit, and then remove all instances of the following substring “erd” in the input string. Assume no spaces in the string. Make the entire string lowercase to start with. It should show the parsed string (with the words already removed) in the text area. The application should then again do the above, clearing out the text area before each iteration of...
Could someone explain how to use Interrupts in C? I really do not understand it
Could someone explain how to use Interrupts in C? I really do not understand it
Use principles of physics to solve the problem and then verify your answer using the simulation....
Use principles of physics to solve the problem and then verify your answer using the simulation. (a) What is the voltage of the battery in this simulation? V (b) When the simulation is first loaded the time constant is 8.0 seconds. What happens in this time? Select all the statements below that apply. Take V0 to be the battery voltage. If the capacitor starts off completely discharged, the time constant is the time required to fully charge the capacitor once...
Explean: 1-When connecting a button to Arduino, explain why a pull down resistor is required for...
Explean: 1-When connecting a button to Arduino, explain why a pull down resistor is required for correct operation? 2-digitalWritre (pin, state): have mention what type of value the variable state and pin can take? 3-Briefly explain the purpose of setup()and loop()function in an Arduino program? 4-Briefly explain what comparator does? 5- Briefly explain how button debouneing can affect the input read from Arduino?
1.) If you pressed a stethoscope diaphragm firmly on a volunteer's skin at the following locations...
1.) If you pressed a stethoscope diaphragm firmly on a volunteer's skin at the following locations on the right side of the body: Inferior to the clavicle (this is the 1st intercostal space) In a more inferior intercostal space Along the medial border of the scapula What type of sounds are you listening for? [a] 2.) If you located a volunteer’s larynx. Then pressed the stethoscope diaphragm on the skin just inferior to the subject’s larynx.   What type of sounds...
Problems: 1-How many nodes would you expect to find when n=3? Where would you expect the...
Problems: 1-How many nodes would you expect to find when n=3? Where would you expect the maxima to be (psi)? 2- What is the minimum n value where you could start finding (psi) with a value < 0? 3-What is the minimum n value where you could start finding (psi)^2 with a value < 0?
1. Thoroughly explain how you would go about charging an object by using induction. Include as...
1. Thoroughly explain how you would go about charging an object by using induction. Include as many details as possible to get full credit. Include diagrams if you wish. 2. An unbalanced electric dipole consists of two charges: q1 = +13.1 nC and q2 = -4.4 nC, which are separated by 55.0 μm. What is the total electric potential energy stored in this system of charges? 3. Explain the primary purpose of a lightning rod, and describe how it works.
1.How would you analyze real options? 2.What type of projects would be in need of using...
1.How would you analyze real options? 2.What type of projects would be in need of using real options? Name an example of a project where the use of real options analysis would be beneficial.
ADVERTISEMENT
Need Online Homework Help?

Get Answers For Free
Most questions answered within 1 hours.

Ask a Question
ADVERTISEMENT