Digital Input & Output, Analog Input Labs

This week’s labs brought with them some issues, but I seem to have a handle on successfully wiring the breadboard at this point.  The digital input/output lab asked for a slightly more complicated LED and switch configuration than we ran through in class, but I didn’t find it too difficult to figure out.

Digital Input/Output Lab – ITP PComp from Ian Gibson on Vimeo.

Next was to develop an application for a digital input/output setup. I went with a combo lock, using a combination of 2 switches to turn off a red LED and turn on a green one. Programming this was a challenge. In the end I assigned each switch a variable and incremented them each time it was pressed; this seemed to work most of the time, but was prone to errors given the very rapid rate at which the loop executes.

A question I have: what is the best way to keep track of something like a specific sequence of switches opening/closing in IDE? The ways I could think to do it all seemed to have some drawback.

Combination Lock – ITP PComp from Ian Gibson on Vimeo.

The analog input lab circuit wasn’t terribly difficult to figure out.

Analog Input Lab – ITP PComp from Ian Gibson on Vimeo.

Finally, I used the same FSR with 4 LEDs to create a test-of-strength game. I used several if statements to check whether the value of the resistance across the FSR had met certain thresholds, and turned on the lights in turn when they were met. I included a final else statement to turn them all off again once the force was removed from the FSR.

Strength Tester – ITP PComp from Ian Gibson on Vimeo.

Code:

strength-test-code

Serial output:

strength-test-serial-output

Leave a Reply

Your email address will not be published.