\n"); } else { header("Content-type: text/html; charset=utf-8"); } ?> CSCI 903 Assignment 7

CSCI-903 Assignment 7

Assigned Videos

Reading

You should have finished reading at least through Chapter 7 of the Gleick book by now. For Tuesday, the question is, “how can you measure the randomness of a sequence of events?”

Coding Assignment

Program your Teagueduino board so the five outputs will display all combinations of 5-bits, in binary counting order. A button or switch (not an analog input) connected to input #1 is to cause the outputs to advance to the next step in the sequence each time it is pressed. After the sequence reaches 111112, the sequence is to go back to 000002 again.

To avoid extra steps when the input is operated due to contact bounce, insert a 20 msec delay after each waituntil() step.

Algorithm

Use five variables to hold the current value of each of the five bits. Set each of these variables to zero during the setup phase.

During the loop phase, repeat the following steps:

  1. Output the values of the five variables to the five Teagueduino outputs.
  2. Wait for the button to be pressed
  3. Use a nested set of if statements to set the values of the five variables to the next state value.

    Each bit changes state (from 1 => 0 or from 0 => 1) when all the bits to the right of it are ones. The rightmost bit changes state every time. Hint: a variable x that has a value of either 0 or 1 changes to the opposite value if you assign the value 1 - x to it.

Note: To make sure your counter goes just one step per button press, the code has to detect button releases too!