|
|
|
|
for(uint8_t i = 0; i < 255; i++){ asm volatile("nop"); }You should then experiment until you come up with values that make the LED stay on for somewhere between 5 and 15 seconds. This is sufficiently long that you can get a good estimate of how long each iteration takes by timing this overall time with a stopwatch. Note that for the 8-bit and 16-bit variables you may need to nest loops to delay for a sufficiently long period. In this case you can ignore any overhead that the nesting may cause. In addition to enabling you to time operation overhead, this will also give you an alternative, albeit less accurate, way to delay for a specific period of time as opposed to using the Arduino delay(...) function. Checkoff: Write a program that uses each of the different unsigned integer types (8-, 16-, 32-bit) to turn on the red, green, and blue LEDs for 1 second each, respectively. In other words, use a uint8_t to turn on the red LED for 1 second, followed by turning on the green one for 1 second using a delay loop with the uint16_t, and finally 1 second with the blue on using a uint32_t.