Given the following code snippet how long is the interval be

Given the following code snippet, how long is the interval between the LED flashing on and off? Answer with a number. Assume units = ms. Var b = require(\'bonescript\'); var led = \"P8_13\"; var state = 0; b.pinMode (led, \'out\'); toggleLED = function() {state = state ? 0: 1; b.digitalWrite (led, state);}; timer = setInterval (toggleLED, 100); stopTimer = function() {clearInterval (timer);}; setTimeout (stopTimer, 30000);

Solution

function returns 1 to variable toggleLED because state = state is flase so it returns 1 and timer set in the interval 1-100 milliseconds

Therefore between ON and OFF 100 milliseconds will be taken.

 Given the following code snippet, how long is the interval between the LED flashing on and off? Answer with a number. Assume units = ms. Var b = require(\'bone

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site