Monday, October 29, 2012

Programming with Processing: Final Project Proposal

           For our Final Project, we have decided to create a physically interactive Risk game. Risk is a tactical multiplayer board game that separates the world into territories and players strive to gain power over the whole world by attacking other player’s territories.
           To make it physically interactive, we will implement processing with hardware and create a projection onto a table or board that will be the "game board". This board will be "touch sensitive" and will detect players moves throughout the game including attacks, dice rolls and loosing territories. For people new to this game, there will also be a "help" button to aid users in understanding and to help the game to be played fairly.
           Board games are an important part of learning and require players to be engaged to their position. The benefits of board games are impressive and Risk in particular: enhancing educational skills by teaching where things are located on a map, building self confidence when the hard work and strategy paid off, developing social and mental skills by communicating with other players and knowing their next move and encouraging problem solving and logic. The purpose of this project will be to engage more people into wanting to play this game by making it interactive allowing players to have more fun and feel in control.


Here are some examples of projectors with human interactivity:



This is how the actual board game looks. Our display will look similar to this:

Programming with Processing: Processing Exercise


            For this assignment, we created a screen drawing using a background image of a tree as well as a simple leaf shape in a simple yellow color. We first had an ellipse draw for the leaf but decided to make it more detailed with the leaf shape which is a png image.
            We used variables to parameterize the characteristics of our design such as the background color, size, image, mouse position and direction. This way, the choices can be changed at the top of the file instead of searching through the code to find replacements.
            We developed an algorithm for changing the direction the leaf is “floating”. If the down arrow is pressed, the y position increases and the x position increases making the leaf go towards the bottom right corner. If the other arrows are pressed, the leaf increases and decreases the x and y positions in the correct direction to change the leaf’s location across the page. When the mouse is clicked, the leaf is given the x and y position of the mouse. 





Problems:

While creating our animation, we had difficulty getting the leaf to our desired shape. One way to create a more leaf like image would be to use vertex() and connect multiple points together with noStroke().

Monday, October 15, 2012

Interactive Technology Observation: Coca-Cola Freestyle

             Coca-Cola Freestyle is an interactive touch screen soda fountain that has been added to numerous restaurants since its debut in 2009. It offers the customer more drink options (over 125)  than the previous 6-8 option beverage dispenser and takes up less room with its built in ice dispenser.
               It is used when people order a drink at fast-food restaurants. A customer gets their drink from a cashier and walks to the device. They first push their cup against the lever to dispense the ice. Then they sit the cup down and use the touch screen to choose the “base” drink and additional flavors. When they are satisfied with the drink and flavor, they push the "pour" button until the cup is full.
                When observing people using it, I noticed that some skip the ice part entirely. I also noticed that during peak hours, a long line forms because the machine can only serve one person at a time. Some people choose to just have the basic drink choices such as water, coke, and sprite. Others want all the customization of cherry-vanilla flavored Pibb Xtra or orange-vanilla Hi-C. Many times people had trouble with the soda overflowing the cup. I also saw that people wanted to try new combinations and took a lot of time choosing an option, tasting it, pouring it out, and starting over, bothering others waiting behind.
                The whole transaction takes about 30 seconds if the user knows what they want and about a minute if they are trying to decide. Getting the ice takes the least amount of time. To speed up the process, there could be a sign above the machine with all of the “base” drinks and then the additional flavors to choose from. This way people waiting in line can decide what they want before it is their turn, making the process faster.
                For Norman and Crawford, to interact well, both sides must listen, think, and speak well with each other.  Lacking in one of these areas will result in low interaction. The Coca-cola Freestyle has a high degree of interaction. The user tells the machine what it wants (touches the drink they want), the machine “listens” to what the user told it, “thinks” about the selection, and “speaks” by dispensing the drink. The user listens to the machine, thinks about what the machine will do, and “speaks” by putting their cup in the right place so the machine can give the soda.


Friday, October 12, 2012

Lab: Motors and Movement

Overview:

The purpose of this lab was to use a transistor to control a high-current DC motor from the Arduino using a transistor and to control the direction using an H-bridge and a Relay.

Transistor:

When circuits include high-current loads like a DC motor that require more than the Arduino can supply, we need a transistor to control it. A transistor has 3 prongs: the "base" connects to the Arduino's output, the "collector" is attached to the element that has the high current, and the "emitter" connects to ground.
     I started by connecting a potentiometer and transistor to the circuit. I then connected the motor to a power supply separate from the Arduino. I then connected a diode to protect my transistor from "back voltage" that occurs when the motor is turned off or changes direction. Finally, code was added to turn the motor on and off every second and then was changed to control speed with the potentiometer!

Direction:

To take the circuit a step further, we wanted to change its direction. To do this, we used an H-bridge which allows us to switch the polarity, changing the motor's direction. I added a switch to the circuit as well as a motor and H-bridge. The H-bridge can be confusing at first because of its many parts and because it looks so similar to the shift registers! I have included a diagram which made connecting it easier. Once the motor was connected to the h-bridge and to an external power source, I added code that turned the motor one way with current was high and the other direction when low. 



Relays are devices that can also control large loads. I implemented a relay to also change the direction of the motor, but with a more satisfying "click" when the change is made! To begin, I made a circuit that alternated between turning on 2 LEDs. I then reassembled the wires by reversing the flow of current and attached the motor:


Problems:

When working with the relays, there was a problem with the prongs not reaching far enough to touch the metal in the breadboard. This was frustrating because although the wiring was correct, the desired outcome was not achieved until time was wasted trying to find the problem. 

Links:

Tuesday, October 9, 2012

Lab: Shift Registers

Overview:

The purpose of this lab was to use see the usefulness of shift registers and how the work.

Shifting Out:

In previous labs, we have never used more than 8-10 pins at once. If we ever ran into a circuit that needed additional pins what would we do? Shift registers allow the Arduino to extend to many more pins than the ones on it's board. With one shift register you can control 8 outputs at once while only taking up a few pins on the microcontroller. If you need more pins, shift registers can connect to each other allowing more extensions.

Instead of using "asynchronous serial communication", the shift register works by "synchronous serial communication", pulsing a pin up and down which communicates a byte of data bit by bit while the clock pin delineated between them. When the byte is completely transmitted to the shift register, the high or low messages carried by each bit get allocated into the output of each LED. Shift registers can be confusing without the knowledge of each pin-out so I have included a drawing.

In the first circuit, just one shift register is used to light up 8 LEDs. Once connections were made to ground and power, the Serial Data Input, Shift Register Clock Pin, and Storage Register Clock Pin were connected. The LEDs were then added with resistors and connected to 8 pins around the register (Q0 - Q7). Finally the code was added to give a binary counting system to the LEDs:


In the second circuit, a second shift register was added without any additional wired to the Arduino. A "serial output" is used by an extra pin in one register to pass serial information from the Arduino out again without changing. This allows us to transmit 16 bits in a row using the second register. The first 8 bits flow through the first register to the second. The code was added to light all 16 LEDs one by one and other patterns:


Problems:

Although the shift registers clean up the wire collection on the Arduino, it asks for a lot of wires on the breadboards, as can be seen from the photos. With so many small, tight connections, it was difficult to make sure the connections were right the first try. Using the drawing of the shift register above made it easier to lay out where each where should connect to. 

Links:

Thursday, October 4, 2012

Project: Lazier Susan

Counter Culture:


The kitchen is a unique part of every house and is a central gathering point for everyone. Whether eating a meal, doing chores, sharing stories or doing homework, the kitchen provides an inviting haven to stay. With such an inviting space comes a great door of opportunity for some ingenious inventions.

I was assigned the task of designing and prototyping a novel kitchen object with any or all of the elements I have used in previous labs.

Observation:

I began by observing my own kitchen at school as well as at home. I noticed while eating dinner with my family and asking for someone to "pass me the ____" that there was a place for improvement. While Lazy Susan's exist already, I thought it would be nice to improve the existing model. Currently, a Lazy Susan spins when the user pushes the circle in a clockwise or counter clockwise direction. But what if I could make that even easier? And make people believe that they have special powers?


The Design in my Head:

And so I began to design my Lazier Susan. It would still be a circular disk moving both directions but taking out the pushing aspect. The device would be controlled by hovering your hand over a sensor to make it go in the direction you pleased!

What's so Great About It?

Upon these thoughts I realized that this device could be used for more than just the kitchen table. If your kitchen comes with a large island, the Lazier Susan would serve as a nice piece to avoid walking to the other side. And why stop at the kitchen? This device would work very well in places like the robotics lab where many people are hovered around a counter and pieces are scattered everywhere. No more wasting time to walk to your needs, just have someone place it on the Lazier Susan and then hover over the desired direction pad and let it come to you!

The Dirty Work:

We started by getting just the breadboard and code to do what we wanted before adding the actual pieces. Using our previous knowledge of servo motors and photo resistors, we developed code to make the motor go one way when covering one photo resistor and vice versa.

Next, we took a piece of plywood and cut out a large circle. We then attached it to the servo using glue and screws and attached that to a wooden base for stability.  



Because the diameter of the circle was so large, we wanted to give it more support for weight so we decided to construct platforms with wheels so when it spun the wheels would help it turn.


We then disconnected the photo resistors from the breadboard and placed them on the platform. We made them visually more appealing by creating foamcore platforms, one on either side, so users could understand how it works.

Demo:


Problems:

At first, our design included buttons and a musical tone that played as it spun. However, the delays on the song conflicted with the delays we wanted to give the circle so we decided to take it out and improve the interaction with users by making the buttons photo resistors instead. 

The plywood we used unfortunately was not completely flat and therefore we ran into problems as it was spinning. Instead of a steady spin, the device did lots of wobbling. To fix this problem, we included the wheels to support the weight and lessen the wobbling. 

In order to keep the circle still until the photo resistor is covered, we did a "calibration" that finds the average light from the resistor when first started and then when it is given less light than the average it tells it to spin. 

Tuesday, October 2, 2012

Lab: Analog Output

Overview:

The purpose of this lab was to familiarize myself with performing analog output with motor, servos, and piezo elements.


Pulse-Width Modulation:

Pulse-Width Modulation is a technique I used in order to get analog results (a range of results i.e. 0-255) with digital means (on or off). In order to make the digital output reflect an analog output, I can change the amount of time the light is in an off and on state. For example, If the light switches on for 1.5 milliseconds and off for .5 milliseconds then back to on repeatedly, the light would shine about 75% of its brightness. If the light is on for less and off for more of the time, the light will be more dim. 

I connected a motor to the breadboard controlled by a potentiometer from the analog input side of the Arduino. When I turned the potentiometer one direction the motor would increase speed, and when I turned it the other way the speed would decrease. I also used Serial.print in my code in order to see the speed increase/decrease on the monitor.


A Single Servos:

While the motor from the last circuit helped demonstrate analog control, the motor is weak and can be stopped easily. Servos can also be used to control but because they include a small gearbox inside they give a more powerful movement and can also make it easier to control. The servo has 3 wires: signal, power, and ground.

I connected the Arduino to the white wire (signal) of the servo, the red wire (power) to the voltage, and the black wire (ground) to the ground. The code was a continuous loop making the servo "sweep" from side to side from 0 degrees to 180 degrees.


Music:

A piezo element allows for an output of sound. It works by creating a "click" for every pulse of current it is given. To make a song, I have to give it current at the right frequency. If you want the note A, the frequency will have to be 440 times a second. The frequency is so fast that the output of sound will run together and give you notes!

I connected my Arduino to my piezo element and gave it code that sends the correct frequencies to the piezo to create a the right tone.


Problems:

I ran into a problem while adding the potentiometer to my PWM circuit. The wiring was not correct so I checked myself by looking back at a previous lab to connect my circuit correctly. If you run into a problem with an addition to your circuit, try getting to addition to work by itself (in my case the potentiometer and an led) and then connect it to your current circuit the correct way.


Links:

For more information on analog outputs: