ID:q4vC. Study the following diagram and code: boolean light_on = false; boolean interruptFired = false; int counter = 0; void setup() { Serial.begin(9600); attachInterrupt(0, interruptServiceRoutine, FALLING); pinMode(10, OUTPUT); pinMode(11, OUTPUT); pinMode(12, OUTPUT); pinMode(13, OUTPUT); pinMode(2, INPUT); } void loop() { delay(1000); if (interruptFired) { interruptFired = false; counter = counter + 1; Serial.print("Current Count "); Serial.print(counter); Serial.println(";"); } digitalWrite(10, bitRead(counter, 0)); digitalWrite(11, bitRead(counter, 1)); digitalWrite(12, bitRead(counter, 2)); digitalWrite(13, bitRead(counter, 3)); } void interruptServiceRoutine() { interruptFired = true; } This circuit is intended to count each button press, displaying the current count on the terminal and in unsigned binary on the LEDs. Suppose the button is pressed 5 times, with each button press occurring at regular 500ms intervals. The first button press occurs 5 ms after the loop function starts executing for the first time (5 ms into the delay(1000) line). You can neglect the time it takes to execute statements other than 'delay()' in the function 'void loop()'. What is the final value of the variable counter? Write your answer in decimal. Note that the code and question are different from your tutorial activities.简答题

登录即可查看完整答案
我们收录了全球超50000道真实原题与详细解析,现在登录,立即获得答案。
类似问题
Inspect circuit and code. boolean light_on; volatile int counter; volatile boolean updateFlag; void setup() { Serial.begin(9600); attachInterrupt(0, interruptServiceRoutine, FALLING); pinMode(10, OUTPUT); pinMode(11, OUTPUT); pinMode(12, OUTPUT); pinMode(13, OUTPUT); pinMode(2, INPUT); counter = 0; updateFlag = false; } void loop() { if (updateFlag) { updateFlag = false; Serial.print("Current Count "); Serial.print(counter); Serial.println(";"); } digitalWrite(10, bitRead(counter, 3)); digitalWrite(11, bitRead(counter, 2)); digitalWrite(12, bitRead(counter, 1)); digitalWrite(13, bitRead(counter, 0)); // least significant bit delay(200); } void interruptServiceRoutine() { counter = (counter + 1) % 16; updateFlag = true; } You can assume that void setup() takes 0.1s to execute. You can neglect the time it takes to execute statements other than 'delay(200);' in the function 'void loop()'. Select all correct choices (0 or more).
Inspect circuit and code. boolean light_on; volatile int counter; volatile boolean updateFlag; void setup() { Serial.begin(9600); attachInterrupt(0, interruptServiceRoutine, FALLING); pinMode(10, OUTPUT); pinMode(11, OUTPUT); pinMode(12, OUTPUT); pinMode(13, OUTPUT); pinMode(2, INPUT); counter = 0; updateFlag = false; } void loop() { if (updateFlag) { updateFlag = false; Serial.print("Current Count "); Serial.print(counter); Serial.println(";"); } digitalWrite(10, bitRead(counter, 3)); digitalWrite(11, bitRead(counter, 2)); digitalWrite(12, bitRead(counter, 1)); digitalWrite(13, bitRead(counter, 0)); // least significant bit delay(200); } void interruptServiceRoutine() { counter = (counter + 1) % 16; updateFlag = true; } You can assume that void setup() takes 0.1s to execute. You can neglect the time it takes to execute statements other than 'delay(200);' in the function 'void loop()'. Select all correct choices (0 or more).
ID:q4vC. Study the following diagram and code: boolean light_on = false; boolean interruptFired = false; int counter = 0; void setup() { Serial.begin(9600); attachInterrupt(0, interruptServiceRoutine, FALLING); pinMode(10, OUTPUT); pinMode(11, OUTPUT); pinMode(12, OUTPUT); pinMode(13, OUTPUT); pinMode(2, INPUT); } void loop() { delay(1000); if (interruptFired) { interruptFired = false; counter = counter + 1; Serial.print("Current Count "); Serial.print(counter); Serial.println(";"); } digitalWrite(10, bitRead(counter, 0)); digitalWrite(11, bitRead(counter, 1)); digitalWrite(12, bitRead(counter, 2)); digitalWrite(13, bitRead(counter, 3)); } void interruptServiceRoutine() { interruptFired = true; } This circuit is intended to count each button press, displaying the current count on the terminal and in unsigned binary on the LEDs. Suppose the button is pressed 7 times, with each button press occurring at regular 200ms intervals. The first button press occurs 5 ms after the loop function starts executing for the first time (5 ms into the delay(1000) line). You can neglect the time it takes to execute statements other than 'delay()' in the function 'void loop()'. What is the final value of the variable counter? Write your answer in decimal. Note that the code and question are different from your tutorial activities.
Name the Supreme Court decision that removed financial constraints on PACs.
更多留学生实用工具
希望你的学习变得更简单
加入我们,立即解锁 海量真题 与 独家解析,让复习快人一步!