Strength Testing Game

Group Members

Jeff Snyder (jasnyder@)
Clay Whetung (cwhetung@)
Michael Newman (menewman@)
Neil Chatterjee (neilc@)

Description

We built a “strongman game” that uses a flex sensor to measure a player’s “digital” strength. As the player flexes the sensor, the amount of flex is categorized into one of five strength levels, and we use three LEDs and a speaker to demonstrate which level has been reached. Within each level, the brightness of the brawniest LED reached is varied with pulse-width modulation to match the player’s exertions. At the lowest level, none of the LEDs are lit and the speaker produces no noise. At the next-lowest level, the green LED lights up. At the middle level, the green and yellow LEDs light up. At the second-highest strength level, the green, yellow, and red LEDs light up. At max strength, all three LEDs light up and celebratory music plays from the speaker. We chose to build this because we wanted a way to demonstrate our finger-flexing prowess, and the game’s cheerful blinking lights and victory song brightened our day while affirming our digital swole. In general, the project was a success, and we were especially pleased with the jingle. For future improvement we might want to change the kind of sensor being used (for example, a pressure sensor that measures the force from the strike of a comically large hammer) and/or the number of lights and tunes available (and consequently, the number of strength categories available).

Video

Arduino Strength Tester

Each Strength Level

First Strength Level

Strength Level One

Second Strength Level

Strength Level Two

Third Strength Level

Strength Level Three

 

Design Sketches and Final Build

Night Light

First Design – Night Light

Clapping Binary Counter

Second Design – Clapping Binary Counter

Strength Tester

Third Design – Strength Tester

Strength Tester

Final Strength Tester Design

 

Parts Used

– 3 LEDS (green, yellow, red)
– 1 speaker
– 1 flex resistor
– 1 Arduino
– jumper wires
– 2 breadboards
– 3 330-ohm resistors
– 1 100-ohm resistor
– 1 10k-ohm resistor
– 1 laptop with usb cable
– 1 wax paper diffuser

Instructions

1. Set up the LEDs in a line on a breadboard next to the flex sensor. Place the speaker across the center divider of the other breadboard. You may find it helpful to connect ground and +5V to the power rails of the breadboard for the following steps.

2. Make the following connections:
– Connect the anode of the red LED to pin 6 of the Arduino, the anode of the yellow LED to pin 11, and the anode of the green LED to pin 11.
– Connect the cathode of each LED to ground via a 330 ohm resistor.
– Connect one pin of the speaker to pin 8 and the other to ground via a 100 ohm resistor.
– Connect one side of the flex sensor to a +5V pin.
– Connect the other side both to A0 and to ground via a 10 kilo-ohm resistor.

3. Check the values output by the flex sensor using the serial monitor and the Serial.println() function. In the code, change the FLEX_MAX and FLEX_MIN values as appropriate.

4. Mount the wax paper diffuser in front of the three LEDs.

5. Test your brawn!

Source Code

/* 
  Authors: jasnyder, cwhetung, menewman, neilc
  Date: 2/11/2013
  COS 436 Lab L0: The Strength Test

  Test the user's strength with a flex sensor. Display the
  results to LEDs and play them a tune if they are truly
  powerful.
*/
#include "pitches.h"

const int FALSE = 0;
const int TRUE = 1;

//  Input / Output Constants
const int FLEX_MIN = 150;  //  set me as appropriate!
const int FLEX_MAX = 348;  //  set me as appropriate!
const int NUM_STAGES = 6;
const int STAGE_SIZE = ((FLEX_MAX - FLEX_MIN) / NUM_STAGES);
const int ANALOG_MAX = 255;

//  Possible States
const int SONG = 0;
const int ALL_ON = 1;
const int TWO_ON = 2;
const int ONE_ON = 3;
const int ALL_OFF = 4;

//  Musical Constants
const int NOTE_DELAY = 300; // (ms)
const int NOTE_DUR = 250;

//  Pin Connection Constants
const int green = 11;
const int red = 6;
const int yellow = 10;
const int flex = A0;
const int speaker = 8;

//  Variables
int flexvalue = 0;  //  value returned by flex sensor
int stage = 0;  //  current state of LEDs / sensor
int play = 0;  //  have we already played the tune?
int pwmout = 0;  //  dimming value

//  Set internal pull-ups for output on LED pins
void setup()
{
  pinMode(green, OUTPUT);
  pinMode(red, OUTPUT);
  pinMode(yellow, OUTPUT);
}

void loop() {

  //  Grab the bend value and map it to one of the stages
  flexvalue = analogRead(flex);
  stage = map(flexvalue, FLEX_MIN, FLEX_MAX, 0, NUM_STAGES - 1);

  //  Within each stage, dim the "last" LED to the approximate
  //  progression through the stage 
  pwmout = (flexvalue - FLEX_MIN) % STAGE_SIZE;
  pwmout = map(pwmout, 0, STAGE_SIZE, 0, ANALOG_MAX);

  //  Turn all LEDS on and play the song once
  if (stage == SONG) {
    digitalWrite(green, HIGH);
    digitalWrite(yellow, HIGH);
    digitalWrite(red, HIGH);

    //  If we have already played the song, do nothing
    if (play == FALSE)
    {
      playACongratulatoryTune();
      play = TRUE;
    }
  }

  //  All on, red variable
  if (stage == ALL_ON) {
    play = FALSE;  //  reset the song
    digitalWrite(green, HIGH);
    digitalWrite(yellow, HIGH);
    analogWrite(red, pwmout);
  }

  //  Green and yellow on, yellow variable
  if (stage == TWO_ON) {
    play = FALSE;
    digitalWrite(green, HIGH);
    analogWrite(yellow, pwmout);
    digitalWrite(red, LOW);
  }

  //  Green on and variable
  if (stage == ONE_ON) {
    play = FALSE;
    analogWrite(green, pwmout);
    digitalWrite(yellow, LOW);
    digitalWrite(red, LOW); 
  }

  //  All leds off
  if (stage == ALL_OFF) {
    play = FALSE;
    digitalWrite(green, LOW);
    digitalWrite(yellow, LOW);
    digitalWrite(red, LOW); 
  }
}

//  Play a classic little ditty!
void playACongratulatoryTune() {
  tone(speaker, NOTE_G4, NOTE_DUR);
  delay(NOTE_DELAY);
  tone(speaker, NOTE_C5, NOTE_DUR);
  delay(NOTE_DELAY);
  tone(speaker, NOTE_E5, NOTE_DUR);
  delay(NOTE_DELAY);
  tone(speaker, NOTE_G5, NOTE_DUR);
  delay(NOTE_DELAY*2);
  tone(speaker, NOTE_E5, NOTE_DUR);
  delay(NOTE_DELAY);
  tone(speaker, NOTE_G5, NOTE_DUR*4);
  delay(NOTE_DELAY*5); 
}

Lab 0

Aside

Brian Matejek (bmatejek)
Matt Dolan (mdolan)
Ed Kelley (ekelley)
Josh Prager (jprager)

Date: 2/11/2013

Idea: We want to use the flex sensor to adjust the brightness and frequency of two LED lights. If the flex sensor bends in one direction, one of the lights turns on and the other off. If the flex sensor bends in the other direction, the other light turns on and other off. We want to create a game of visual laser tag. We taped the flex sensor to Ed’s thumb (see diagram and video), and one LED light to his index finger and another LED light to his middle finger. The red LED goes on when Ed bends the flex sensor to lower the resistance, and the green LED turns on when Ed bends the flex sensor to raise the resistance. The red LED is on the index finger and the green LED is on the middle finger. We can play a game of virtual laser tag, where one shoots by bending his thumb in a direction that either increases or decreases the resistance of the flex sensor. In the video, Ed shoots by bending the flex sensor to lower the resistance and turn the red light on. We covered the lights in a plastic cup.

Design Sketches:
Initial Design:
photo (3)
Schematic Design:
photo (2) (2)
Final Design
photo (1) (2)

Demo:
http://www.youtube.com/watch?v=cTny9olE80E

photo

photo (1)

Code:
Code Here!

Materials:
1 Arduino
1 Flex Sensor
1 Breadboard
1 Small Secondary Breadboard
Assorted extra wires
2 LED lights
1 Plastic Cup
2 330 Ohm resistors
1 10K Ohm resistor

Instructions:
-Connect digital output pin 3 to a 330 ohm resistor.
-Connect the resistor to the positive terminal of an LED and connect the negative terminal of the LED to ground.
-Repeat the above two steps on pin 6.
-Connect a 10K ohm resistor to the 5V output on the Arduino. Connect the end of the resistor to both the anaolg input pin 2 and the flex sensor.
-Connect the other end of the flex sensor to ground.
-Mount the LED and flex sensors on a control surface (e.g. a golve or your hand).
-Have fun!

Expressive Cyborg Glasses

Krithin Sitaram (krithin@)
Amy Zhou (amyzhou@)
Daniel Chyan (dchyan@)
Jonathan Neilan (jneilan@)
Thomas Truongchau (ttruongc@)

Expressive Cyborg Shades:

We positioned four LED lights on each lens and mimicked four emotions: evil (\ /), happy (^ ^), surprised (o o), and sleepy (v v). The emotions depend on ambient light (i.e. Bright ambient light evokes “happy”, a lack of ambient light evokes “evil” or “sleepy”). When the cyborg is turned on, it is happy. When ambient light is below a certain threshold, the cyborg becomes evil. As soon as light strikes above the threshold, the cyborg becomes surprised for two seconds, and then gets happy. We were inspired by evil animated furbies that have scary eyes. We also wanted to mimic human emotions in response to darkness and light, in a way in which the emotion matched the level of ambient light. Overall, we believe the project was a resounding success! Our cyborg responds well to varying ambient light levels. However, it is currently not wearable. What we like the most in our final result is that it responds and interacts with us well, inspiring great joy in us all. In the future, we will need more LED’s to get more expressive emotions and more variety of emotions. We can also use more compact circuitry using transparent circuit boards.

Photos/Videos & Captions

Parts Used:
– Arduino
– 1 photocell
– 8 LED lights
– 1 100 Ohm resistor
– 1 variable resistor
– 1 long grounding wire
– 5 alligator clips
– Wires
– Styrofoam
– Sunglasses

Instructions for Recreating:

We first cut the styrofoam to fit behind the glasses, and poked the legs of the LEDs through. All the LEDs were connected in parallel. The ground pins of the LEDs were bent to make them flush with the surface of the styrofoam, and a single bare copper ground wire was hooked around them all and connected to a ground pin on the Arduino. Then the other pins of the LEDs were hooked up to the Arduino in pairs, with one light from each eye connected to a single analog output pin on the Arduino as indicated in the diagram.

The light sensor was connected in series with a fixed 100 Ohm resistor and an appropriately tuned potentiometer, and the 3.3V output of the Arduino was set across these. A tap was connected to measure the potential difference across the light sensor at analog input A0 of the Arduino.

Source Code:

/***
Pin numbers for left and right eye

   3      3
 5   6   6  5
   9      9
*/

int lightsensor = 0;
int threshold = 150;
int surprisedcounter = 0;
int surprisedlength = 2;
int sleepiness = 0;
int sleepaftertime = 10;

void setup() {
  Serial.begin(9600);
  happy();
}

void happy() {
  analogWrite(3, HIGH);
  analogWrite(6, HIGH);
  analogWrite(5, HIGH);    
  analogWrite(9, LOW);
}
void evil() {
  analogWrite(5, HIGH);
  analogWrite(9, HIGH);
  analogWrite(3, LOW);    
  analogWrite(6, LOW);
}
void surprised() {
  for (int i = 1; i < 14; i++) {
    analogWrite(i, HIGH);
  }
}
void sleep() {
  analogWrite(9, LOW);
  analogWrite(6, HIGH);
  analogWrite(5, HIGH);    
  analogWrite(3, LOW);
}

void loop() {
  Serial.println(analogRead(lightsensor));
  if (analogRead(lightsensor) < threshold) {
    sleepiness = 0;
    if (surprisedcounter > 0) {
      surprised();
      surprisedcounter--;
    } else {
      happy();
    }
  } else {
    if (sleepiness > sleepaftertime) {
      sleep();
    } else {
      sleepiness++;
      surprisedcounter = surprisedlength;
      evil();
    }
  }
  delay(1000);
}

 

Uploading Video Files

This blog has been enhanced with the ability to upload videos to the campus Kaltura video management system. This system facilitates the use of video by streamlining the transcoding and streamed delivery of video materials. Streamed videos play much quicker and more smoothly because they do not need to be downloaded before playback can begin.

kaltura-iconTo upload a video from your computer while editing a post or page, click the orange Add Interactive Video icon just above the text entry area.

In the resulting window, make sure the Video tab is selected and select Upload from the left-hand menu. Click Browse to navigate to the video file on your computer. Note that you may also select multiple video files if you wish.

upload

After the video files appear in the list, click the Upload button in the bottom-right hand corner of the window.

After the file has finished uploading, click Next to begin the conversion of the file into a format suitable for presentation on the web.

In the next window, you may select any specifics about the design of the player on the page, but the default settings should be fine.

Click Insert into Post to insert the necessary codes into the post and to begin the conversion process.

Don’t forget to click Publish (or Update if you are editing an existing post) to save your post.

Please be aware that the conversion process can take quite a while depending on the size of the video.  When the video has finished processing, it will be available for viewing.