Final Project

1. Goals and Specifications

I will be making a robot that can play (and hopefully beat) Bop-It. It will have three robotic arms that allow it to appropriately respond to the commands given by the Bop-It.

2. Planned Capabilities

I plan to have a robot that is able to listen and respond to Bop-It commands. The robot will be able to differentiate between the Bop-It commands, and move the appropriate arm in response to each. It will also have to be able to move/respond fast enough to the commands.

3. Parts Needed

  • Stepper Motor x3
  • Microphone
  • Materials to construct robotic arms

4. Topics

  • Using an Oscilloscope
  • Interrupts
  • Sound: Microphone
  • Motors: Stepper
  • Robotics

5. Timeline of Milestones

Intermediate Project 1 Plan

For my first intermediate project, I plan to make a keypad controlled lock, using buttons, a homemade switch, and  a piezo buzzer, among other things.

The way this will work is as follows:

You will type in a code using the buttons. If the code is correct, it will allow the “door” to be opened. When the door is open, the connection made by the switch is broken. If the code is incorrect, or if someone just tries to open the door without entering a code, the piezo buzzer will sound. I am also considering including an LCD screen to say things like “(in)correct code,” “alarm on/off,” etc.

 

Project Plans

Topics I Have Covered So Far:

  • Arrays
  • DC motors (kind of)

Topics I Plan to Explore:

  • Soldering
  • Using an oscilloscope
  • Microphones
  • Stepper motors
  • Robotics
  • Interrupts
  • LRD
  • Temperature sensor
  • LCD screen
  • LED matrix & shift registers

Game Plan

I plan to use soldering, an oscilloscope, a microphone, stepper motors, and robotics in my final project.

As for the rest, my plan right now is to just toy around with the equipment and see what I want to use. I feel like the LCD and the LED matrix are similar and so are the light-dependent resistor and the temperature sensor regarding input. Therefore, I will most likely only be choosing one topic from each of those two categories to explore.

Project 2- Crank it Up to Light it Up

For our second Physical Computing project, we were required to demonstrate mastery of the use of analog inputs and outputs, through the creation of a competitive game from which the winner is clearly indicated in some way.

Design

Coming up with a design for this project proved to be a little more difficult for me than coming up with an idea for project 1 had been. I always strive to create something unique, but I was having a hard time thinking outside the box his time. I felt like the potential uses for the majority of the analog sensors we were given were either too hard to integrate into a game or the ways in which they could be integrated were too obvious. However, after some thinking and some questions, I decided that I wanted to use DC motors, but I wanted to use it as an input instead of an output. I was warned that it might be hard, but lo and behold, the motors worked quite nicely as an input. And finally, I decided that I would use LEDs as my analog outputs to indicate which player was able to crank their motor faster.

One thing I wanted to do but wasn’t able was to make the lights sort of light up at different levels. For example when the input value was between 0 and some arbitrary x, I wanted the brightness of light 1 to correspond with that value, and when the value was greater than x, I wanted it to stay on fully lit. Therefore when the input value was between x and some y, I wanted light 1 to be fully lit and the brightness of light 2 to correspond to the input value. The same idea applies for light three. I tried to change my ranges in the manual tune function and add some if statements, but neither seemed to work. If I figure it out after some more tinkering, I’ll be sure to let you all know!

Parts

To create my crank game, I used the following equipment:

  • RedBoard by Sparkfun
  • Half-breadboard
  • Wires x15
  • Blue LED x3
  • Red LED x3
  • 330 Ohm Resister x6
  • DC Motor x2 (with handles for cranking. I used some wooden sticks and wooden spools from the craft store plus some hot glue and electric tape.)

Circuit DiagramProject 2 Circuit Diagram

See the circuit diagram to the right for reference. The circuit diagram was created with Fritzing.

To construct the crank game, I first had to figure out how to make DC motors, which are typically outputs, into inputs. I hooked it up in the most obvious way, with the motors connected to ground and analog input pins, and hoped for the best. Surprisingly enough, my setup worked! I then connected my LED lights (in series with a resister) to their own output pins. I did this because, as I mentioned earlier, my intention was to make the brightness of each light dependent upon the input values from the motor but independent from one another.

Code

The code I used was pretty simple and is as follows:

/*Project 2- Crank it Up to Light it Up
Playing with Analog Inputs and Outputs*/
// assigns variables to crank (DC motor) inputs
const int crank1 = A0;
const int crank2 = A5;

//assigns varaibles to LED outputs
const int player1LED1 = 11;
const int player1LED2 = 10;
const int player1LED3 = 9;
const int player2LED1 = 3;
const int player2LED2 = 5;
const int player2LED3 = 6;

//assigns variables to be used later
int brightness11;
int brightness12;
int brightness13;
int brightness21;
int brightness22;
int brightness23;

void setup()
{ 

  //assigns player one's output pins
  pinMode(player1LED1, OUTPUT);
  pinMode(player1LED2, OUTPUT);
  pinMode(player1LED3, OUTPUT);

  //assigns player two's output pins
  pinMode(player2LED1, OUTPUT);
  pinMode(player2LED2, OUTPUT);
  pinMode(player2LED3, OUTPUT);
}

void loop()
{
  //the brightness of these three lights is dependent on input from crank 1
  brightness11 = analogRead(crank1);
  brightness12 = analogRead(crank1);
  brightness13 = analogRead(crank1);

  //the brightness of these three lights is dependent on input from crank 2
  brightness21 = analogRead(crank2);
  brightness22 = analogRead(crank2);
  brightness23 = analogRead(crank2);

  manualTune(); //"activates" manual tune function

  analogWrite(player1LED1, brightness11);
  analogWrite(player1LED2, brightness12);
  analogWrite(player1LED3, brightness13);

  analogWrite(player2LED1, brightness21);
  analogWrite(player2LED2, brightness22);
  analogWrite(player2LED3, brightness23);

}

void manualTune()
{

  //map() changes the input range of values to the output range of vlaues
  //constrain() will force numbers outside range into range

  brightness11 = map(brightness11, 0, 256, 0, 255);
  brightness11 = constrain(brightness11, 0, 255);

  brightness12 = map(brightness12, 0, 512, 0, 255);
  brightness12 = constrain(brightness12, 0, 255);

  brightness13 = map(brightness13, 0, 1023, 0, 255);
  brightness13 = constrain(brightness13, 0, 255);

  brightness21 = map(brightness21, 0, 256, 0, 255);
  brightness21 = constrain(brightness21, 0, 255);

  brightness22 = map(brightness22, 0, 512, 0, 255);
  brightness22 = constrain(brightness22, 0, 255);

  brightness23 = map(brightness23, 0, 1023, 0, 255);
  brightness23 = constrain(brightness23, 0, 255);

}

In the beginning, I assigned global variables for the LEDs, the motors, and the brightness levels of the LEDs to be used throughout the program. In the setup function, I assigned the LED pins to be outputs. In the loop function I made the brightnesses of the LEDs dependent upon the input values coming from the motors. I then introduced the manual tune function into the loop. The manual tune function contains the map function, which takes values from the input range and converts them to values for the output range, and the constrain function forces all the values that come in outside the range back into the range. The map function is also what allowed me to make the light closest to the player get the brightest the fastest and the one farthest away to brighten the slowest.

Improvements/Modifications

There are a couple improvements I think this game would benefit having. The first is that it can be more sensitive. When using the lights to judge, it wasn’t always obvious who was cranking faster. I also think the game can use a timer of sorts. Playing a game with no declared winner isn’t as much fun. Therefore, I think there should be a time limit in the game, and it will tell the player who had the best average crank speed or the player who had the highest speed overall that they are the winner.

 

 

CPR with AVR

https://lh4.googleusercontent.com/rsO2y4P-Sv-hNWV78NbO5lE_nDG-tFAHDLbj4_5p2_d-C60_lslV1s0VFkLzmWf_LbhzMzohuyoOSRVjQFs_z7a3KkMP7ywjM-30OBYVoFm2-p2r77GUlFAyFX98cSM_eAThis dummy is actually pretty smart. He, with the help of a couple microcontrollers, some sensors, and an LCD screen, teaches basic CPR. He was created by three students from Cornell University, Rameez Qurashi, Sungjoon Park, and Haoyuan Chen, as a final project for one of their Electrical and Computer Engineering classes in the fall of 2012.

The trio’s goal was to make a CPR training dummy. They thought it was important to create a system like this one, a system that allows people to learn CPR on their own with both instruction and hands-on practice; typical dummies and live instructors can be expensive, and not everyone lives in an area in which CPR classes are offered.

How does he work?

To put it simply, the dummy is rigged with sensors that allow a person performing CPR to be guided through the process and critiqued along the way.

When programming the dummy and deciding which sensors to use, the students focused on the two main components that CPR is broken down into: chest compressions and ventilations. Sensors in the chest of the dummy monitor the strength, frequency, and number of compressions. And sensors behind the face of the dummy monitor the openness of the airway, the number and frequency of breaths, and whether or not the nose is being pinched shut.

The creators also programmed the dummy with 2 modes: practice mode and test mode. When in practice mode, a trainee will be guided through the CPR process step by step. When in test mode, the quality of the CPR will be directly assessed.

Want to learn more about this project? Just click here!

Project 1 – My Name in Lights

 

For our first Physical Computing project, wewere required to demonstrate mastery of programming basics, variables, and digital input and output, while using a switch of our own design, an RGB LED, and any other parts of our choice.

DesignCS111 Project1

For this project, I decided right away
that I wanted to use single color LED lights to create letters. I made a grid using twelve LED lights: three blue, three green, three red, and three yellow; the grid is four lights tall and three lights wide. Due to space constraints on my breadboard and a limited number of digital output pins on my RedBoard, I was limited in the letters I was able to make. Therefore, I decided to simply spell my nickname, Ally, with the LEDs. Followed by clockwise blinking of each LED composing the perimeter of the grid in sequence.

I did encounter a few hiccups along the way, but I was able to resolve them. The first issue I ran into came with arrays. Essentially, the lights were cycling nearly correctly but not quite, and the loop did not run continuously. This was because when trying to use arrayA, I had accidently written the limits outside of what was in arrayA. This was remidied as soon as I corrected the limits. Another issue was that all the LEDs were running through the loop properly, but the light they were emitting was very dim. In this case, I had mistakenly deleted the part in the void setup () function in which output pins are assigned. Similarly to the other problem, this was fixed with very simple corrections in the coding. I also ran out of pins to output to so the red LED in the middle column is not wired to. Luckily, none of the letters required that LED for their construction.

Parts

To create my LED board, I used the following equipment:

  • RedBoard by SparkFun
  • Half-Breadboard
  • Wire x23
  • Blue LED x4
  • Green LED x4
  • Red LED x4
  • Yellow LED x4
  • RGB LED
  • 330Ω Resistor x 12
  • 12kΩ Resistor
  • Switch (Pop can and tab)

CircuitProject 1 Circuit Board

See the circuit diagram to the right for reference. The circuit diagram was created with Fritzing.

To start, I connected a single LED and a 330Ω resistor in series to pins 2-5 and 7-13. I then connected one anode prong of the RGB LED in parallel with each of the three blue LED lights in the grid. This way, when a blue pin is lit, its corresponding RGB LED will also become lit. Additionally, I created my switch using a pop can and tab. The tab is connected directly to the 5V power source, while the can is connected to pin 6 as well as a grounded 10kΩ resistor. When the switch is closed, the wire into pin 6 and the 10kΩ resistor are in parallel; however, since the resistance of the wire going into pin 6 is so much smaller compared to the grounded path with the 10kΩ resistor, nearly 5V of electricity will reach pin 6. And when the switch is open, the grounded 10kΩ will draw any remaining electricity away from pin 6.

Code

The code I used for this project is as follows:

int blue1 = 13;    //blue light in first column
int blue2 = 12;    //blue light in second column
int blue3 = 11;    //blue light in third column
int green1 = 10;   //green light in first column, etc.
int green2 = 9;
int green3 = 8;
int red1 = 7;
int red3 = 5;
int yellow1 = 4;
int yellow2 = 3;
int yellow3 = 2;
int const switchPin = 6;  //switch is connected to pin 6
int arrayA[8] = {  //LEDs make the shape of the letter 'A'
  blue1, blue2, blue3,
  green3,
  red1, red3,
  yellow1, yellow2,
};
int arrayL[6] = {  //LEDs make the shape of the letter 'L'
  blue1,
  green1, green2,
  red1, red3,
  yellow1
};
int arrayY[6] = {  //LEDs make the shape of the letter 'Y'
  blue1,
  green1, green2, green3,
  yellow2, yellow3
};
int arrayBox [10] = {   //LEDs on perimeter of LED grid
  green1, blue2, yellow3,
  green3, blue3,
  red3, green2, yellow1,
  red1, blue1
};
int time = 100;

void setup() {
  //initializes all output pins
  pinMode(13, OUTPUT);
  pinMode(12, OUTPUT);
  pinMode(11, OUTPUT);
  pinMode(10, OUTPUT);
  pinMode(9, OUTPUT);
  pinMode(8, OUTPUT);
  pinMode(7, OUTPUT);
  pinMode(6, OUTPUT);
  pinMode(5, OUTPUT);
  pinMode(4, OUTPUT);
  pinMode(3, OUTPUT);
  pinMode(2, OUTPUT);
  //initialize input pin
  pinMode(switchPin, INPUT);
}

void loop() {
 
  int newPin = 0;
  int oldPin = 0;
  
  int bounce1 = digitalRead(switchPin); //these three lines send instructions to read pin 6
  delay(25);                            //this is dependent upon whether or not the switch has been flipped
  int bounce2 = digitalRead(switchPin);
  
  while ((bounce1 == bounce2) && (bounce1 == HIGH)) { //if both readings are high the following happens 
    
    
    for(int i=0; i<8; i++)            //for all 8 elements of arrayA
      digitalWrite(arrayA[i], HIGH);  //turns on all LEDs in arrayA
    
    delay(1000);                      //waits 1 second
   
    
    for(int i=0; i<8; i++) 
      digitalWrite(arrayA[i], LOW);   //turns off all LEDs in arrayA
  
    delay(250);                       //waits .25 seconds
  
    
    int i=0;
    for (int i=0; i<2; i++) {         //the steps in the brackets happen twice
      for(int i=0; i<6; i++)
        digitalWrite(arrayL[i], HIGH);  //turns on all LEDs in arrayL
  
      delay(1000);                      //waits 1 second
      
    
      for(int i=0; i<6; i++)
        digitalWrite(arrayL[i], LOW);   //turns off all LEDs in arrayL
      
      delay(250);                       //waits .25 seconds
      
    }
  
    for(int i=0; i<6; i++)
      digitalWrite(arrayY[i], HIGH);  //turns on all LEDs in arrayY
    
    delay(1000);                      //waits 1 second
    
    
    for(int i=0; i<6; i++)
    digitalWrite(arrayY[i], LOW);   //turns off all LEDs in arrayY

    delay(250);                       //waits .25 seconds
    
    for (int i=0; i<3; i++){
      for (int i=0; i<10; i++){
        digitalWrite(arrayBox[i], HIGH);
        delay(time);
        digitalWrite(arrayBox[i], LOW);
        delay(time);
      }
    }
    
    if (newPin == 0) {   //this tells the system what to do when the numbering restarts
      for (int i=0; i<10; i++) digitalWrite(arrayBox[i], LOW);  //all lights off
    }
    
    bounce1 = digitalRead(switchPin);  //checks to see if switch is flipped again
    delay(25);
    bounce2 = digitalRead(switchPin);
 }
 for (int i=0; i<10; i++) digitalWrite(arrayBox[i], LOW); //all lights off
 delay(25);
}

 

To reiterate the comments within the code, I begin by assigning all the output pins a name based upon the color and position of the light they correspond to. This made assigning pins to the various arrays much easier; I needed only to look at the lights to determine which were needed to make the respective letters. Next, I assigned arrays that would look like the desired letters when all the elements of the array were lit. Throughout the program, I used a notation similar to this: for (int i=0; i<x; i++) {. This means that everything in the brackets will occur for several values of i. When i=0, the first element of the array is used. x should be taken as the upper bound of the array, or the number of elements it has. i++ means that the value i will increase in increments of 1 from i=0 to i<x. On several occasions, a statement like the ones aforementioned precedes a statement of the same type. When this happens, the first for statement acts like a repeat command. Whatever x is equal to in the first statement is indicative of how many times that particular portion of the code will repeat itself in one loop of the overall function. The statement beginning with while is a conditional statement. It says that the LEDs will only light up when the input to pin 6 is high, or the switch has been flipped.

Improvements/Extensions

It would seem that this type of project has been much improved upon already. After constructing and running this system, I noticed that this must be very similar to the way in which LCD screens, digital clocks, etc. work. Certain combinations of blinking LEDs are used to create the numbers, letters, and even complete pictures that we see on older TVs.

Even though this technology has been much explored and improved upon, there are still expansions that can be made to this project directly. One of those improvements would be to make a larger grid, such that all letters and maybe even entire words can be spelled out with lights. A practical use for this would be perhaps and open/closed sign. Flip the switch one way and the LEDs light up to spell “open;” flip it the other way and it says “closed.” Another, more fun improvement could be to add a light-dependent resistor to the circuit so that the lights would only operate when it is dark.

Closing Statements

In conclusion, I think that technologies like this one have been and will continue to be very common in our everyday lives. I think this project was both hard for me, as a first-timer, and very much fun. Right now I’m thinking that I might try to make a sign for the basement of the house I will be living in next year. I’ll be sure to post if that becomes a reality. Thanks for reading!

Initial Plan for Exploring Course Topics

Exploring  Topics of Physical Computing

There are so many things that can be done using physical computing nowadays, and technologies are ever increasing.  To a newcomer in the world of physical computing, it seems like I can make just about anything. It’s a little overwhelming.

When deciding which topics I would be interested in exploring I tried to keep several things in mind:

  1. Have fun: Believe it or not, learning can be fun. I really pushed myself and will encourage you to pursue topics that you think you will have fun working with. If you think using an ultrasonic range finder would be cool, then go for it! Find something to make with it. Be creative. You will find experiences like these that are enjoyable to be so much more valuable in the long run. If you enjoy what you are doing, you are much more likely to do it again in the future.
  2. Future use: I am currently pursuing an undergraduate degree in biology, with the intention of going into biotechnology or a related field. This being the case, nearly anything I choose to and am able, to learn in this course will be very beneficial to me. Most career fields closely use computers this day in age and the amount of technological use in any given field is continually increasing. I would suggest choosing topics that you may find use for.
  3. Challenge yourself. It is very important to challenge myself. I did not try to make a device that simply met the criteria for project 1. I tried to push myself and think outside the box. There’s no pride in taking the easy way out. If you are not challenging yourself, you are not learning. Pick something that will be hard. You will make mistakes, but you will learn from them. And you will feel so much more accomplished when the project that you thought about giving up on works like it should.

Topics I Have Explored So Far

I decided to explore some additional course topics in addition to the topics required for course 1. Those include conditionals, functions, loops, arrays, interrupts, and light-dependent resistors. Although, I did not actually put all of these topics to use in my first project, I researched them and became better acquainted with them.

Topics I Plan to Explore

I could not make a complete list of fifteen points’ worth of topics for myself, but that’s okay. I did, however, decide that I will be exploring the following: soldering, using an oscilloscope, arrays, interrupts, microphone, stepper motor, and robotics. I was able to add most of these to my list because I intend to use them in my final project (more details to come). However, I am more than eager to tinker with all of the sensors and outputs. I am enrolled in this course to learn whatever I can, and learn I shall.