Zeven Rodriguez

ITP PHYSCOMP

The Helper

ITP PHYSCOMP

Comments Closed


Share this post

The helper is an assistive technology for a person with muscular dystrophy who can not pinch. It is composed of an arm and a controller. The controller is composed of 2 round objects the control the arm sided to side and around itself. The controller has 2 buttons one to open and close the grabber and a preset button that will bring the arm to bring object to the user.

design2

The grabber mechanism motion is very similar to a fun childhood game hungry hungry hippos.

For the controller we used bowls because they would be easier to rotate with the palm of your hand.
For the controller we used bowls because they would be easier to rotate with the palm of your hand.
The controller was designed to be anbidextrous.

The controller was designed to be anbidextrous.

We installed buttons to allow for preset commands such as "Bring it to me" and "Grab item"

We installed buttons to allow for preset commands such as "Bring it to me" and "Grab item"

This is before the controller was wired in to the breadboard and arduino.

This is before the controller was wired in to the breadboard and arduino. We used big buttons to make it easier for the user who lack dexterity to push them.

The helper is controlled by two 360 potentiometer and two lighted big buttons.

The helper is controlled by two 360 potentiometer and two lighted big buttons.

Russ started with a cardboard mock up of how the grabber will operate.

Russ started with a cardboard mock up of how the grabber will operate.

Parts are in for the Grabber and Servo for the Arm.

Parts are in for the Grabber and Servo for the Arm.

The original design for the grabber the gears went on the outside, then mount for gear, then the axel. This did not let the axel spin 360 degrees.

The original design for the grabber the gears went on the outside, then mount for gear, then the axel. This did not let the axel spin 360 degrees.

This is the top design of 1st interation of the grabber.

We kept the main box clear any obstructions down to the rivets in order to have smooth movement for the Grabber.

This is the interim design that the grabber had. We mounted the axel on the inside which let the axel rotate 360 degrees.

This is the interim design that the grabber had. We mounted the axel on the inside which let the axel rotate 360 degrees.

This is the side view of the interim design for the grabber.

This is the side view of the interim design for the grabber.

We initially tested the arm to see how the servo would react to the weight of the servo.

This was the first install of the grabber. We made the mistake of mounting it on the rear of the grabber. This put all of the weight at the end of the grabber making it too heavy for the servo.

The required torque power for mounting to the rear of the Grabber was to great for our servo. We cut down the lifting force by mounting the arm closer to the center of the Grabber box.

In order for us to mount the arm in the center, we had to redesign the Grabber box  to include a roof.

In order for us to mount the arm in the center, we had to redesign the Grabber box to include a roof.

One stumbling block that we found was the Grabber was binding if drove it from only one side.   We had to run a drive shaft to the other side so that they wheels rotated equally.

One stumbling block that we found was the Grabber was binding if drove it from only one side. We had to run a drive shaft to the other side so that they wheels rotated equally.

Quick test to see if the servo can lift the Grabber from it's new mounting point.

Quick test to see if the servo can lift the Grabber from it's new mounting point.

Originally we mounted the arm directly to servo. This put to much stress on center screw on the servo and flexed to much.

Originally we mounted the arm directly to servo. This put to much stress on center screw on the servo and flexed to much.

The new servo turret takes the stress off the servo but allows the servo to rotate the grabber.

The new servo turret takes the stress off the servo but allows the servo to rotate the grabber.

This is the final version of the grabber.

This is the final version of the grabber. We are using a motor to drive the Grabber motion.

We are using springs to lift the Grabber above the items it intends to grab.

We are using springs to lift the Grabber above the items it intends to grab.

Russ testing everything out.

Russ making sure everything works.

Pcomp Final – The Helper from Zeven Rodriguez on Vimeo.

CODE

#include

int analogPin0 = 0; // blue up and down
int analogPin1 = 1; // green left right pot
int analogPin2 = 2; // blue pot to control hbridge speed

// pins for buttons
int redButton = 2; // red wire to pin 2
int greenButton = 5; // green wire to pin 5

// pins for lights
int redLight = 10; // yellow wire to pin 10
int greenLight = 11; // white wire to pin 11

// pins for motors
int servo1 = 6; // no color yet left right
int servo2 = 7; // no color yet up down
int motor1 = 9; // pulse pin for the hbridge

int red = 0;
int green = 0;

int analogSensorPin = 0; // select the input pin for the potentiometer
int analogSensorPin1 = 1; // select the input pin for the potentiometer

int formerValue = 0;
int nowValue = 0;
float difference = 0;
float deg = 83;

int formerValue1 = 0;
int nowValue1 = 0;
float difference1 = 0;
float deg1 = 0;

Servo updown;
Servo leftright;
void setup() {
Serial.begin(9600);
updown.attach(8);
leftright.attach(7);
pinMode(redButton, INPUT);
pinMode(greenButton,INPUT);
}

void loop()
{
// read the value from the sensor:

// this reads pot 1
nowValue = analogRead(analogSensorPin);
//Serial.print(“this is pot”);
//Serial.println(nowValue);
difference = nowValue – formerValue;

if(abs(difference) > 500)
{
if(difference > 0)
{
difference = formerValue + (1023 – nowValue);
}
else
{
difference = (1023 – formerValue) + nowValue;
}
}

deg += difference / 30;

if(deg < 0) { deg = 0; } else if(deg > 180)
{
deg = 180;
}

// Serial.println(deg);

formerValue = nowValue;

// this reads pot 2
nowValue1 = analogRead(analogSensorPin1);
//Serial.print(“this is pot1″);
//Serial.println(nowValue1);
difference1 = nowValue1 – formerValue1;

if(abs(difference1) > 500)
{
if(difference1 > 0)
{
difference1 = formerValue1 + (1023 – nowValue1);
}
else
{
difference1 = (1023 – formerValue1) + nowValue1;
}
}

deg1 += difference1 / 30;

if(deg1 < 0) { deg1 = 0; } else if(deg1 > 180)
{
deg1 = 180;
}

// Serial.println(deg1);

formerValue = nowValue;

updown.write(deg);
Serial.println(deg);
leftright.write(deg1);

red = digitalRead(redButton);
//Serial.print(“this is the red button”);
//Serial.println(red);
green = digitalRead(greenButton);
//Serial.print(“this is the red button”);
//Serial.println(red);
}

Read more

Pcomp Final Concept Drawing

ITP PHYSCOMP

Comments Closed


Share this post

The Helper is a assitive technology robot. The purpose of the robot is to be able to pick up and reach objects for individuals in wheel chairs. The project is composed of 2 parts one is the Helper robot that is able to reach and grab the objects. The other is the control unit. One of the main design concerns for the control unit is that a lot of people of handicap cannot pinch. For this reason the orb works with large objects that rotate like a pot to control the robot.

design

Read more

Physcomp Lab8 – Transistors and HBridge

ITP PHYSCOMP

Comments Closed


Share this post

This week we delt with tranistors and HBridge. The transistor help to control motors, lights, or objects that have a higher voltage that the Arduino cannot power. The Transistor has a Base, Collector, and Emitter. The base goes from a pin of the arduino. This acts like a switch for the object you are controlling. The collector, which is the middle pin, goes to ground. The Emitter, the last pin left to right, takes the ground of a motor in this case. The power to the motor comes from the power source that correlates to the voltage of the motor. In this case, we are taking power from the Vin pin. There is a diode that crosses from the Collector to the Emitter. The silver edge goes to the collector. It helps especially with motors because when they spin down they still are making energy.
P1000245-w400

This code is to program the arduino to speed up and slow done the motor.

 const int potPin = 0;           // Analog in 0 connected to the potentiometer
 const int transistorPin = 9;    // connected to the base of the transistor
 int potValue = 0;               // value returned from the potentiometer

 void setup() {
   // set  the transistor pin as output:
   pinMode(transistorPin, OUTPUT);
 }

 void loop() {
   // read the potentiometer, convert it to 0 - 255:
   potValue = analogRead(potPin) / 4;
   // use that to control the transistor:
   analogWrite(9, potValue);
 }

Physcomp Lab8 – Transistor from Zeven Rodriguez on Vimeo.

Now to the HBridge Lab. The HBridge is used to control multiple actions. In this case we are reversing the direction of a DC motor. This is how the HBridge wiring looks like.

This is my wiring.

P1000237-w400

Here is the code to get the HBridge to work. This code uses a pot to control the speed and a switch to reverse the direction. If you remove the analogWrite code, it will just work with the switch.

const int switchPin = 2; // switch input
const int motor1Pin = 3; // H-bridge leg 1 (pin 2, 1A)
const int motor2Pin = 4; // H-bridge leg 2 (pin 7, 2A)
const int enablePin = 9; // H-bridge enable pin
const int ledPin = 13; // LED
int pot= 0;
int potValue = 0;
void setup() {
Serial.begin(9600);
// set the switch as an input:
pinMode(switchPin, INPUT);

// set all the other pins you’re using as outputs:
pinMode(motor1Pin, OUTPUT);
pinMode(motor2Pin, OUTPUT);
pinMode(enablePin, OUTPUT);
pinMode(ledPin, OUTPUT);

// set enablePin high so that motor can turn on:
//digitalWrite(enablePin, HIGH);

// blink the LED 3 times. This should happen only once.
// if you see the LED blink three times, it means that the module
// reset itself,. probably because the motor caused a brownout
// or a short.
blink(ledPin, 3, 100);
}

void loop() {
potValue = analogRead(pot);
Serial.println(potValue);

// if the switch is high, motor will turn on one direction:
if (digitalRead(switchPin) == HIGH) {

analogWrite(enablePin, potValue/4);
digitalWrite(motor1Pin, LOW); // set leg 1 of the H-bridge low
digitalWrite(motor2Pin, HIGH); // set leg 2 of the H-bridge high
}
// if the switch is low, motor will turn in the other direction:
else {
analogWrite(enablePin, potValue/4);
digitalWrite(motor1Pin, HIGH); // set leg 1 of the H-bridge high
digitalWrite(motor2Pin, LOW); // set leg 2 of the H-bridge low
}
}

/*
blinks an LED
*/
void blink(int whatPin, int howManyTimes, int milliSecs) {
int i = 0;
for ( i = 0; i < howManyTimes; i++) {
digitalWrite(whatPin, HIGH);
delay(milliSecs/2);
digitalWrite(whatPin, LOW);
delay(milliSecs/2);
}
}

Phsycomp Lab8 – HBridge with Pot from Zeven Rodriguez on Vimeo.

Read more

PComp Midterm-MIDI Light Table: Making the table

ITP PHYSCOMP

Comments Closed


Share this post

17working

For our physical computing midterm Julio Terra, Michael Martinez-Campos, and Myself created a MIDI based light table. We used LEDs in a gradient pattern and a puck like object with photocells to achieve this. The photocells pick up the brightness from the LEDs. The Photocells are connected to the Arduino. Through Processing and using the OSC library we turn the photocell values into MIDI. The light has 2 sets of lights, green and red. Each of cell is composed of a red and green light. The cells provide 2 discrete values that affect the MIDI values that go to the music software. The MIDI information could then be used by many music software. In our case we chose Ableton. This article mostly focuses on the making of the light table.

Physcomp Midterm – MIDI Light Table from Zeven Rodriguez on Vimeo.

One day while looking around the shop, I found this cardboard grid. The cardboard grid needed stiffening. Hot glue and a simple wood frame were used. This piece we meant only as a sketch but it seemed to be of great use in the prototype.

1cardboardframe

We decided to use foil to help with the diffusion of light.

2wiredandfoiled

After soldering the 50 LEDs, we wired the rows of lights in parallel. This made it easy to make sure which lights were not working.

3juliofirstwiring

We decided to limit the puck object to get a better reading off the LEDs. Initially, we used a wood track to guide the movement of the puck.4woodtrackwithredlightsonly

The wooden block between the tracks contains bearings which help guide the wood easier along the tracks.

5woodtrackcloseup

We used a resistor ladder to control the brightness of the lights.

6resistorladderforlights

Due to the high friction and the lack of rigidity of wood, metal was used to fix this issue.

7usingmetal

This was the first time we started testing the brightness of the LEDs and the readings from the photocells.

8lightgradationtest

We decided to use 2 photocells per cell because after trying one per cell we were getting better readings.

10undertheobject

After the first test, we realized that we needed further diffusion of the light. After a chat with our professor, Tom Igoe he suggested some vellum for this purpose.11vellumgradtestThe biggest challenge for use was to get the maximum output from the LEDs as possible. We learned that pots could help use vary the resistance of the voltage to get a range of LEDs. This was better then the resistance ladder because it was easier to set. We originally used 10k pots but there was not enough control. We ended up using 1k pots. After using a 5v voltage regulator, we achieved around 2.3 volts on the brightest row of LEDs.

12aftertheladder

After testing, we found that our readings were difficult to map. To help achieve a better reading we decided to put in a push button to only pick up values when you pressed it. We also added a dome and a slit to put in a scroll-like wheel(which is actually a pot) to control volume.

13testing

Here are Julio and Mike doing some testing and calibration.

14theguystesting

This is the final pot ladder for the lights.

15finalptladder

This is was the lights looked like when they were tuned.

16itsworkingkinda

Our puck turned out to be a cool little mascot

17working

In the end, the thing we learned most about this project is the amount of testing it really takes for something like this to work. Because of the photocells prefer something with a higher contrast, the table did not work out perfectly. For more information about the programming aspects of this project visit Julio Terra’s blog

Read more

Lab 7 – Serial Communication 2 and Handshaking

ITP PHYSCOMP

Comments Closed


Share this post

For this lab we were doing more advanced serial communication with the arduino and processing. I used 2 pins of an accelerometer and a pot. The hardest part of this lab is the handshaking aspect. The reason it is tricky is because the different types, punctuation and handshaking. The handshaking makes sure that the information does not get backed up in the buffer.

This arduino code sends the information in this format 0,0,0. The punctuation method would just be the code with out this function establishContact(); and this if(Serial.available()>0) . With these 2 parts, we establish the handshake method between the arduino and processing. When the “hello” is sent from the arduino code, the processing code picks it up and sends back a character. This enables processing to get information when it needs it.

Arduino Code

int analogOne = 0; // analog input
int analogTwo = 1; // analog input
int analogThree = 2; // digital input

int sensorValue = 0; // reading from the sensor

void setup() {
// configure the serial connection:
Serial.begin(9600);
// configure the digital input:
// pinMode(digitalOne, INPUT);
establishContact();
}

void loop() {
if(Serial.available()>0){
// read the sensor:
sensorValue = analogRead(analogOne);
// print the results:
Serial.print(sensorValue, DEC);
Serial.print(“,”);

// read the sensor:
sensorValue = analogRead(analogTwo);
// print the results:
Serial.print(sensorValue, DEC);
Serial.print(“,”);

// read the sensor:
sensorValue = analogRead(analogThree);
// print the last sensor value with a println() so that
// each set of four readings prints on a line by itself:
Serial.println(sensorValue, DEC);
}
}
void establishContact() {
while (Serial.available() <= 0) {
Serial.println(“hello”); // send a starting message
delay(300);
}
}

Processing Code
import processing.serial.*; // import the Processing serial library
Serial myPort; // The serial port

float bgcolor; // Background color
float fgcolor; // Fill color
float xpos, ypos; // Starting position of the ball
boolean firstContact = false; // Whether we’ve heard from the microcontroller

void setup() {
size(640,480);
background(255);
smooth();
// List all the available serial ports
println(Serial.list());

// I know that the first port in the serial list on my mac
// is always my Arduino module, so I open Serial.list()[0].
// Change the 0 to the appropriate number of the serial port
// that your microcontroller is attached to.
myPort = new Serial(this, Serial.list()[0], 9600);

// read bytes into a buffer until you get a linefeed (ASCII 10):
myPort.bufferUntil(‘n’);

}

void draw() {

fill(random(255),fgcolor,random(255), random(255));
noStroke();
// Draw the shape
ellipse(xpos, ypos, 100, 100);
}

// serialEvent method is run automatically by the Processing applet
// whenever the buffer reaches the byte value set in the bufferUntil()
// method in the setup():

void serialEvent(Serial myPort) {
// read the serial buffer:
String myString = myPort.readStringUntil(‘n’);
// if you got any bytes other than the linefeed:
if (myString != null) {

myString = trim(myString);

if (firstContact == false) {
if (myString.equals(“hello”)) {
myPort.clear(); // clear the serial port buffer
firstContact = true; // you’ve had first contact from the microcontroller
myPort.write(‘A’); // ask for more
}
}

else{

// split the string at the commas
// and convert the sections into integers:
int sensors[] = int(split(myString, ‘,’));

// print out the values you got:
for (int sensorNum = 0; sensorNum < sensors.length; sensorNum++) {
print(“Sensor ” + sensorNum + “: ” + sensors[sensorNum] + “t”);
}
// add a linefeed after all the sensor values are printed:
println();
if (sensors.length > 1) {
xpos = map(sensors[0], 0,400,0,width/2);
ypos = map(sensors[1], 0,400,0,height/2);
fgcolor = sensors[2] / 4;
}

}
myPort.write(“A”);
}
}

Physcomp Lab7 – Serial Lab 2 from Zeven Rodriguez on Vimeo.

Read more

Observation: The Brita Filter

ITP PHYSCOMP

1 Comment


Share this post

Observation. Pick a piece of interactive technology in public, used by multiple people. Write down your assumptions as to how it’s used, and describe the context in which it’s being used. Watch people use it, preferably without them knowing they’re being observed. Take notes on how they use it, what they do differently, what appear to be the difficulties, what appear to be the easiest parts. Record what takes the longest, what takes the least amount of time, and how long the whole transaction takes. Consider how the readings from Norman and Crawford reflect on what you see.

filter

Reaction

The piece of technology I chose was a very simple low tech water purifier that had a short life span on the ITP floor. The technology is called the Brita filter. At first, the Brita filter seems to be designed nicely. Its has a very round shape and its white which makes it seem clean and streamline. This I think is the biggest flaw with the Brita filter. It took me a second to figure out how to switch between purified water and tap water. The knob was tough to grab if your hands get wet and the knob seemed to spin continuously. The nail on the coffin for the Brita filter was when I observed some people not realizing that they were washing dishes with the filtered water. I think this happened because people are not invested in the technology. People tend to take for granted that things happen automatically.

I think the biggest problems with the Brita filter could be fixed some what easily. First would be a more visual indicator that you are using purified water (even if they come out of different orifices). The second would be a larger lever as the switch. The Brita filter helps with using countless water bottles. If you do not make it able to become second nature then the technology fails. Sadly, the filter is now gone.

Read more

Physcomp Lab6 – Serial Communication

ITP PHYSCOMP

Comments Closed


Share this post

Using Serial Communication with Arduino and Processing was not too bad.

The arduino code is simple. We are using a Pot put in pin0 and doing a basic analogread. The import things about this whole lab is that you make sure you always close the serial monitor, because only one application could read the serial stream.

int analogPin = 0;
 int analogValue = 0;

 void setup()
 {
   // start serial port at 9600 bps:
   Serial.begin(9600);
 }

 void loop()
 {
   // read analog input, divide by 4 to make the range 0-255:
   analogValue = analogRead(analogPin);
   analogValue = analogValue / 4;
   Serial.print(analogValue, BYTE);
   // pause for 10 milliseconds:
   delay(10);
 }

Once you upload close the Arduino application. So you avoid any serial issues. Open processing. I simply altered some code and made a sort of paint brush. Here is the code.
import processing.serial.*;

Serial myPort; // The serial port
int graphXPos = 1; // the horizontal position of the graph:
float randNum = 0;
void setup () {
size(640, 480); // window size

// List all the available serial ports
println(Serial.list());
// I know that the fisrt port in the serial list on my mac
// is usually my Arduino module, so I open Serial.list()[0].
// Open whatever port is the one you’re using.
myPort = new Serial(this, Serial.list()[0], 9600);

// set inital background:
background(255);
smooth();
}
void draw () {
// nothing happens in draw. It all happens in SerialEvent()
}

void serialEvent (Serial myPort) {
// get the byte:
int inByte = myPort.read();
randNum = random(255);
// print it:
println(inByte);
// set the drawing color. Pick a pretty color:
fill(randNum, randNum);
noStroke();
// draw the ellipse:
ellipse(graphXPos, inByte*2, 100, 100);

// at the edge of the screen, go back to the beginning:
if (graphXPos >= width) {
graphXPos = 0;

}
else {
// increment the horizontal position for the next reading:
graphXPos++;
}
}

Physcomp Lab6 – Serial Communication from Zeven Rodriguez on Vimeo.

Read more

Stupid Pet Trick: The Nurse Station

ITP PHYSCOMP

Comments Closed


Share this post

The Nurse Station is a beer nursing meter. It goes placed on a bar counter and is used to measure if the person who places their beer on the coaster has left their beer too long on the counter.

Stupid Pet Trick: The Nurse Station from Zeven Rodriguez on Vimeo.

Stupid Pet Trick: Internals from Zeven Rodriguez on Vimeo.

Here is the code

#include <Servo.h>
Servo servoMotor;

int fsrPin = 0; // Analog input pin that the potentiometer is attached to
int fsrValue = 0; // value read from the pot
int fsrRef = 10; // value read from the pot
int redLed = 4;
int yellowLed = 3;
int greenLed = 2;
int servoPin = 8;
long time = 0;
long lastTime = 0;
boolean setTime=true;

void setup() {
// initialize serial communications at 9600 bps:
Serial.begin(9600);
// declare the led pin as an output:
pinMode(redLed, OUTPUT);
pinMode(greenLed, OUTPUT);
pinMode(yellowLed, OUTPUT);
//pinMode(speakerPin, OUTPUT);
pinMode(servoPin, OUTPUT); // Set servo pin as an output pin
// pulse = minPulse;
servoMotor.attach(servoPin);
//noiseMaker.begin(9);

}

void loop() {

fsrValue = analogRead(fsrPin); // read the pot value
Serial.println(fsrValue);
if(fsrValue < 60){
digitalWrite(redLed, LOW);
digitalWrite(yellowLed, LOW);
digitalWrite(greenLed, LOW);
// Serial.println(“this is when the fsr is not pressed”);
//Serial.println(time);
servoMotor.write(0);
setTime=true;
// Serial.println(lastTime);

}

if(fsrValue > 60 && setTime == true){
lastTime= millis();
//Serial.println(“START TIMER”);
setTime=false;
//Serial.println(lastTime);
}

if(fsrValue > 60) {
if(millis() – lastTime < 5000){
digitalWrite(greenLed, HIGH);
digitalWrite(redLed, LOW);
digitalWrite(yellowLed, LOW);
servoMotor.write(27);

}
if((millis() – lastTime >= 5000) && (millis() – lastTime <10000)){

digitalWrite(greenLed, LOW);
digitalWrite(redLed, LOW);
digitalWrite(yellowLed, HIGH);
servoMotor.write(50);
// Serial.println(“TEN SECOND LOOP”);
//Serial.println(lastTime);
}

if (millis() – lastTime >= 10000 ){
//Serial.println(“20 SECOND LOOP”);

digitalWrite(yellowLed, LOW);
digitalWrite(redLed, HIGH);
digitalWrite(greenLed, LOW);
servoMotor.write(75);
//Serial.println(lastTime);
}
delay(100);
}

//Serial.println(lastTime);
}

The next step is to re-implement the code not using the Servo.h library so I could add tone. Because tone and servo libraries use the internal timers of the arduino it makes the servo movement erratic. Also I could like to make a more mobile unit.

Read more

Lab 4 Servo and Tone

ITP PHYSCOMP

Comments Closed


Share this post

The breadboard is wired with 2 photocells in series go to pin 0. The photocells give an average range in the resistance. Depending which photocell you choose it pushes the resistance either towards the ends of the range. They make sure that all the voltage does not reach the arduino. The speaker goes to pin 8. It does not go to the Pulse Width Modulation because PWM changes the volume of the speaker.

Physcomp Lab4 – Photocell tone from Zeven Rodriguez on Vimeo.

This code is to check the range of the photocells

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

 void loop() {
   int sensorValue = analogRead(0);
   Serial.println(sensorValue, DEC);
 }

This code uses the 2 photocells to make a thermin
/*
   Theremin
  
  Plays tones based on a sensor reading
  uses Tone library by Brett Hagman
  http://code.google.com/p/arduino-tone/
  
  circuit:
  * photoresistor from +5V to analog in 0
  * photoresistor from analog pin 0 to ground
  * 8-ohm speaker on digital pin 8
  
  created 10 Sep 2009
  by Tom Igoe 
  */

 #include <Tone.h>
 Tone noiseMaker;    // instance of the tone library

 void setup() {
   // start the music:
   noiseMaker.begin(8);
 }

 void loop() {
   // get a sensor reading:
   int sensorReading = analogRead(0);
   // map the results from the sensor reading's range
   // to the desired pitch range:
   int pitch = map(sensorReading, 200, 900, 100, 1000);
   // change the pitch:
   noiseMaker.play(pitch);
 }

This video shows using 3 analog resistors to make a make-shift instrument

Phsycomp Lab4 - Three analog inputs from Zeven Rodriguez on Vimeo.
Here is the code

 /*
  
  circuit:
  * 3 force-sensing resistors from +5V to analog in 0 through 5
  * 3 10K resistors from analog in 0 through 5 to ground
  * 8-ohm speaker on digital pin 8
  
  */

 #include <Tone.h>
 Tone noiseMaker;    // instance of the tone library
 const int threshold = 10;    // minimum reading of the sensors that generates a note

 // notes to play, corresponding to the 3 sensors:
 int notes[] = {
   NOTE_A4, NOTE_B4,NOTE_C4 };

 void setup() {
   // start the music:
   noiseMaker.begin(8);
 }

 void loop() {
   for (int thisSensor = 0; thisSensor < 3; thisSensor++) {
     // get a sensor reading:
     int sensorReading = analogRead(thisSensor);
     // if the sensor is pressed hard enough:
     if (sensorReading > threshold) {
       // play the note corresponding to this sensor:
       noiseMaker.play(notes[thisSensor]);
     }
     else {
       // stop playing:
       noiseMaker.stop();
     }
   }
 }

Finally I made an instrument

Physcomp Lab4 - Musical Instrument from Zeven Rodriguez on Vimeo.
#include <Tone.h>
Tone noiseMaker; // instance of the tone library
int notes[] = {
NOTE_D4, NOTE_E4,NOTE_C4,NOTE_C3 };
int durations[] = {
100, 100, 100, 100, 100};
void setup() {
// start the music:
noiseMaker.begin(8);
Serial.begin(9600);
}
void loop() {
int pot = analogRead(5);
pot = pot/4;
Serial.println(pot);
//depending on were the pot is play series of tones at differnt pitches
if(pot > 204){
for (int thisNote = 0; thisNote < 5; thisNote ++) {
// change the pitch:
noiseMaker.play(notes[0]);
delay(durations[thisNote]);
// stop for the next note:
noiseMaker.stop();
}
}
else if((pot < 204) && (pot > 153)){
for (int thisNote = 0; thisNote < 5; thisNote ++) {
// change the pitch:
noiseMaker.play(notes[1]);
delay(durations[thisNote]);
// stop for the next note:
noiseMaker.stop();
}
// hold before repeating:
}
else if((pot < 153) && (pot > 102)){
for (int thisNote = 0; thisNote < 5; thisNote ++) {
// change the pitch:
noiseMaker.play(notes[2]);
delay(durations[thisNote]);
// stop for the next note:
noiseMaker.stop();
}
// hold before repeating:
}
else if((pot < 102) && (pot > 51)){
for (int thisNote = 0; thisNote < 5; thisNote ++) {
// change the pitch:
noiseMaker.play(notes[3]);
delay(durations[thisNote]);
// stop for the next note:
noiseMaker.stop();
}
// hold before repeating:
}
else if((pot < 51) && (pot >= 0)){
for (int thisNote = 0; thisNote < 5; thisNote ++) {
// change the pitch:
noiseMaker.play(notes[4]);
delay(durations[thisNote]);
// stop for the next note:
noiseMaker.stop();
}
// hold before repeating:
}
}

Now using the servo

The servo is connected directly to 5v rail on the breadboard. The servo goes to pin 2. The force sensor goes to analog in.

Physcomp Lab4 – Using Pulse code from Zeven Rodriguez on Vimeo.

This code does not use the arduino servo library

 /*
  Servo control from an analog input

 The minimum (minPulse) and maxiumum (maxPulse) values
 will be different depending on your specific servo motor.
 Ideally, it should be between 1 and 2 milliseconds, but in practice,
 0.5 - 2.5 milliseconds works well for me.
 Try different values to see what numbers are best for you.

 This program uses the millis() function to keep track of when the servo was
 last pulsed.  millis() produces an overflow error (i.e. generates a number
 that's too big to fit in a long variable) after about 5 days. if you're
 making a program that has to run for more than 5 days, you may need to
 account for this.

 by Tom Igoe
 additions by Carlyn Maw & Rob Faludi
 Created 28 Jan. 2006
 Updated 10 Jun. 2008
 */

 int servoPin = 2;     // Control pin for servo motor
 int minPulse = 500;   // Minimum servo position
 int maxPulse = 2500;  // Maximum servo position
 int pulse = 0;        // Amount to pulse the servo

 long lastPulse = 0;    // the time in milliseconds of the last pulse
 int refreshTime = 20; // the time needed in between pulses

 int analogValue = 0;  // the value returned from the analog sensor
 int analogPin = 0;    // the analog pin that the sensor's on

 void setup() {
  pinMode(servoPin, OUTPUT);  // Set servo pin as an output pin
  pulse = minPulse;           // Set the motor position value to the minimum
  Serial.begin(9600);
 }

 void loop() {
  analogValue = analogRead(analogPin);      // read the analog input
  pulse = map(analogValue,0,1023,minPulse,maxPulse);    // convert the analog value
                                                        // to a range between minPulse
                                                        // and maxPulse.

  // pulse the servo again if rhe refresh time (20 ms) have passed:
  if (millis() - lastPulse >= refreshTime) {
    digitalWrite(servoPin, HIGH);   // Turn the motor on
    delayMicroseconds(pulse);       // Length of the pulse sets the motor position
    digitalWrite(servoPin, LOW);    // Turn the motor off
    lastPulse = millis();           // save the time of the last pulse
  }
 }

This is servo part is using the Servo.h library
Physcomp Lab4 - Using Servo Library from Zeven Rodriguez on Vimeo.
 /*
 Servo control from an analog input using the Arduino Servo library

 This example code uses the Arduino Servo library which comes packaged with the Arduino software.

 In order to make this work, you must include the Servo.h library file, create an instance of the Servo object. 
 attach a pin to the Servo object, and then write an analog value to the Servo object to set its 
 position.

 The difference between using the Servo library and the older method of pulsing a digital pin is that the library
 handles a lot of the work for you. You no longer need to figure out the translation between pulse length and position. 
 You now can simply specify the angle you'd like your servo to be at and it will turn to that position.

 Updated 08 Sep 2009
 by Rory Nugent
 Created 20 Jan 2009
 by Tom Igoe
 */

 #include <Servo.h>      // include the servo library

 Servo servoMotor;       // creates an instance of the servo object to control a servo

 int analogPin = 0;      // the analog pin that the sensor is on
 int analogValue = 0;    // the value returned from the analog sensor

 int servoPin = 2;       // Control pin for servo motor, may only be pin 9 or 10

 void setup() {
   servoMotor.attach(servoPin);  // attaches the servo on pin 2 to the servo object
 }

 void loop()
 {
   analogValue = analogRead(analogPin);                 // read the analog input (value between 0 and 1023)
   analogValue = map(analogValue, 0, 1023, 0, 179);     // map the analog value (0 - 1023) to the angle of the servo (0 - 179)
   servoMotor.write(analogValue);                       // write the new mapped analog value to set the position of the servo
   delay(15);                                           // waits for the servo to get there 
 }

Read more

Lab 3 Working without Arduino

ITP PHYSCOMP

Comments Closed


Share this post

This lab was mostly to focus on building circuits with out the Arduino

I started by first looking at my power adapter. The adapter I was using was Positive on the outside and Negative on the inside.

measuringwallwart

The power adapter is connected through the breadboard to a 7805 5-volt voltage regulator which drops the 9v to 5v

measuringaftervoltageregulator

This is my basic LED circuit with a switch.

Physcomp Lab3-Basic circuit from Zeven Rodriguez on Vimeo.

I then connected another LED in series

Physcomp Lab3-Components in Series from Zeven Rodriguez on Vimeo.

Then measured the first LED in the circuit
series1

Then the second

series2

Finally, I added with a third LED. When I did that the intensity of the LEDs dropped. The last led dims because most of the voltage is sucked up by the first 2 leaving the last LED with a smaller current.

Physcomp Lab3- series Led plus 1 from Zeven Rodriguez on Vimeo.

In the parallel circuit I measured the amperage after the LEDs.

parallelmilliamps

The last part I measured the resistance on a pot.

Physcomp Lab3-Pot Variable Voltage Measuring from Zeven Rodriguez on Vimeo.

Read more