The voltage measuring lab was pretty straight up. I had previously soldered the power connector and pot.
The only unexpected behaviour i had was in step 4: I noticed that the LEDs varied in brightness. This was due to the fact that i used LEDs from different packages and they varied in expected volts. Also unexpected was when connecting a pot to LEDs in parallel: Here only the first LED lights up.
Taking the F-train back and forth to the city yesterday i attempted the observation exercise. It was difficult getting any sort of controlled data, but i'll average each trip:
F-Train - Carrol Street -> 42nd, 4pm - 4:30pm
16 unique riders engaging phone , most likely for text or other reasons 17 riders with headphones 3 riders playing some form of video game 1 rider reading an electronic book
F-Train - 42nd -> Carrol Street, 5:45pm - 6:15pm
21-26 unique riders engaging phone 22 riders with headphones 2 riders playing some form of video game
I began this lab by setting up the demo, which required first soldering the pot. Easy enough:
To build the "luv-o-meter" i decided to use an ultrasonic range finder that i had previously attempted to get working w/ a PIC chip (w/ less success).
With the arduino board it was fairly easy to read: I read one of the output pins on the range finder to the analog input. The stream of data is the time it takes the pulse from the range finder to bounce off an object and return to the sensor.
For the meter, I take this data and determine the magnitude within the max and min range, and divide this by the 6 readout LEDs, then display this on the scale:
I'm not yet sure how this meter can demonstrate a user's sex appeal or love making prowess ... still working on this part.
------------- Arduino Code: -------------
int potPin = 5; // Analog input pin that the potentiometer is attached to int val = 0;
int highWall = 70; int lowWall = 32;
int bracket = (highWall - lowWall) / 6;
void setup() { // initialize serial communications at 9600 bps: Serial.begin(9600);
pinMode(8, OUTPUT); // set the red LED pin to be an pinMode(9, OUTPUT); pinMode(10, OUTPUT); pinMode(11, OUTPUT); pinMode(12, OUTPUT); pinMode(13, OUTPUT);
For this lab, i decided to build a combination lock to try to get a little more familiar with programming for Arduino. I started by building a simple 3-button array:
The basic functionality is that a red LED is lit untill the 3-button code is attempted. On the first button entry, the LED is turned off. After 3 buttons are pushed, if the combination is correct (a simple array of the button order: button2, button3, button1), I turn on the greed LED. If not, I lite the red LED and the flow starts over.
Below is the Arduino code. The main functional problem i had was buttons occasionally registering twice. There are definitely more subtleties in programming w/ physical inputs versus the computer programming i am used to, which will require another round of debugging. I found that below worked as expected about 75% of the time.
// declare variables: int switchPin1 = 6; int switchPin2 = 5; int switchPin3 = 2; // digital input pin for a switch
int yellowLedPin = 3; // digital output pin for an LED int redLedPin = 4; // digital output pin for an LED
int pin1; int pin2; int pin3;
int count = 0; int cleared = 1; int totalPinCount = 0; int pushed = 0;
int combination[] = {switchPin3, switchPin2, switchPin1}; int combinationIndex = 0; int combinationLength = 3; int hold = 0;
void setup() {
// open the serial port at 9600 bps: Serial.begin(9600);
pinMode(switchPin1, INPUT); // set the switch pin to be an input pinMode(switchPin2, INPUT); // set the switch pin to be an input pinMode(switchPin3, INPUT); // set the switch pin to be an input
pinMode(yellowLedPin, OUTPUT); // set the yellow LED pin to be an output pinMode(redLedPin, OUTPUT); // set the red LED pin to be an
This lab was again pretty straighforward, following the schematic. Only odd behavior was getting a USB power usage warning on my Mac. I have not seen this since the lab, so wonder if i had something incorrectly wired while getting this up and going.
This was pretty straightforward once i purchased the "Diecimila" board. I started w/ the Arduino Mini board and a usb adapter board and was unable to load a script w/o errors, despite following the directions on the Arduino site. I plan to debug soon, but figured it would be worth going to the "Diecimila" to get up and going.