Wednesday, May 27, 2009

Analog In Lab

I read about a study that was recently conducted that confirmed that women's sexuality is hard to figure out because it has an inherent dichotomy to it. Women want to feel pressure and a sense of overpowering from a man, as it demonstrates interest and sexual prowess. However, women also want to feel a sense of sensitivity because it demonstrates an ability to mate and bond.

So my love machine will attempt to measure the balance between force and sensitivity as way to get a more yin yang measure of sexuality to find a more accurate measure of their sexual prowess.

So, for the coding, I have decided to take Rory's advice and start with a code outline, so I don't get overwhelmed with the particulars. So here is my outline for my love machine:

1. Capture input from the flex sensor
2. Capture input from the pressure sensor
3. Map input from flex sensor within a range of 1-10
4. Map input from pressure sensor within a range of 1-10
5. Add pressure sensor range to flex sensor range
6. Add a value to each LED
6. Light up LEDs based on pressure sensor range + flex sensor range

Hmmm. Ok. This seems too easy. So, of course I have more work to do. But I will jump to the arduino to code now.

----

Well. It appears that my arduino needs some work. I cannot get code to upload. It appears that I needs to boot-something up to my arduino. And of course I need some special device to do so, which I don't have and don't have the time to get today.

--

OK. Got my arduino board to upload a sketch, after Rory was kind enough to set my board to ATMEGA 328 since that was my chip, even though my board was the Duemilanove. That seems to have been the issue.

Uploaded the blinking LED sketch and all was good

--
Decided to rewire my potentiometer since I had put red wire on the ground the 1st time around. This time it is in the right order.

Potentiometer lab went fine. Lights up the LED. THough the range of input from the pontentiometer seemed pretty flat. It was mostly all over 1000.

---

Here is the code for my love machine:
int input1 = analogRead(2); //declare a variable for the flex sensor input
int input2 = analogRead(3); //declare a variable for pressure sensor input
int yenscore; //declare variable to store the yenscore, which is mapping of flex input
int yangscore; //declare variable to store the yangscore, which is mapping of pressure input
int yinyanglove;

void setup()
{
Serial.begin(9600);
pinMode(2, OUTPUT); // declare the digital pin 2 as an output
pinMode(3, OUTPUT); // declare the digital pin 3 as an output
pinMode(4, OUTPUT); // declare the digital pin 3 as an output
pinMode(5, OUTPUT); // declare the digital pin 3 as an output
pinMode(6, OUTPUT); // declare the digital pin 3 as an output
pinMode(7, OUTPUT); // declare the digital pin 3 as an output
pinMode(8, OUTPUT); // declare the digital pin 3 as an output
pinMode(9, OUTPUT); // declare the digital pin 3 as an output
pinMode(10, OUTPUT); // declare the digital pin 3 as an output
pinMode(11, OUTPUT); // declare the digital pin 3 as an output

}

void loop()
{

//this code makes sure every pin that is linking to the LEDs are off
digitalWrite(2,LOW);
digitalWrite(3,LOW);
digitalWrite(4,LOW);
digitalWrite(5,LOW);
digitalWrite(6,LOW);
digitalWrite(7,LOW);
digitalWrite(8,LOW);
digitalWrite(9,LOW);
digitalWrite(10,LOW);
digitalWrite(11,LOW);



//take analog input from the flex sensor and
//convert to a score between 1 and 10

if( input1 >=1 && input1 < yenscore=" 1;">=103 && input1 < yenscore="2;">=204 && input1 < yenscore="3;">=305 && input1 < yenscore="4;">=408 && input1 < yenscore="5;">=511 && input1 < yenscore="6;">=614 && input1 < yenscore="7;">=717 && input1 < yenscore="8;">=820 && input1 < yenscore="9;">=923 && input1 < yenscore="10;" input1 ="0)" yenscore="0;">=1 && input1 < yangscore=" 10;">=103 && input1 < yangscore="9;">=204 && input1 < yangscore="8;">=305 && input1 < yangscore="7;">=408 && input1 < yangscore="6;">=511 && input1 < yangscore="5;">=614 && input1 < yangscore="4;">=717 && input1 < yangscore="3;">=820 && input1 < yangscore="2;">=923 && input1 < 1023)
{
yangscore=1;
}
else if(input2 =0)
{
yangscore=0;
}

yinyanglove= yenscore + yangscore;



//this code turns on and off a certain number of LEDs based on your yin+yang score
if (yinyanglove=1 || 2)
{
digitalWrite (2, HIGH);
delay(1000); // wait 1 second
digitalWrite(2,LOW);
delay(1000); // wait 1 second
digitalWrite (2, HIGH);
}
else if (yinyanglove=3 || 4)
{
digitalWrite(2,HIGH);
digitalWrite(3,HIGH);
delay(1000); // wait 1 second
digitalWrite(2,LOW);
digitalWrite(3,LOW);
delay(1000); // wait 1 second
digitalWrite(2,HIGH);
digitalWrite(3,HIGH);
}
else if (yinyanglove=5 || 6)
{
digitalWrite(2,HIGH);
digitalWrite(3,HIGH);
digitalWrite(4,HIGH);
delay(1000); // wait 1 second
digitalWrite(2,LOW);
digitalWrite(3,LOW);
digitalWrite(4,LOW);
delay(1000); // wait 1 second
digitalWrite(2,HIGH);
digitalWrite(3,HIGH);
digitalWrite(4,HIGH);
}
else if (yinyanglove=7 || 8)
{
digitalWrite(2,HIGH);
digitalWrite(3,HIGH);
digitalWrite(4,HIGH);
digitalWrite(5,HIGH);
delay(1000); // wait 1 second
digitalWrite(2,LOW);
digitalWrite(3,LOW);
digitalWrite(4,LOW);
digitalWrite(5,LOW);
delay(1000); // wait 1 second
digitalWrite(2,HIGH);
digitalWrite(3,HIGH);
digitalWrite(4,HIGH);
digitalWrite(5,HIGH);
}
else if (yinyanglove=9 || 10)
{
digitalWrite(2,HIGH);
digitalWrite(3,HIGH);
digitalWrite(4,HIGH);
digitalWrite(5,HIGH);
digitalWrite(6,HIGH);
delay(1000); // wait 1 second
digitalWrite(2,LOW);
digitalWrite(3,LOW);
digitalWrite(4,LOW);
digitalWrite(5,LOW);
digitalWrite(6,LOW);
delay(1000); // wait 1 second
digitalWrite(2,HIGH);
digitalWrite(3,HIGH);
digitalWrite(4,HIGH);
digitalWrite(5,HIGH);
digitalWrite(6,HIGH);
}
else if (yinyanglove=11 || 12)
{
digitalWrite(2,HIGH);
digitalWrite(3,HIGH);
digitalWrite(4,HIGH);
digitalWrite(5,HIGH);
digitalWrite(6,HIGH);
digitalWrite(7,HIGH);
delay(1000); // wait 1 second
digitalWrite(2,LOW);
digitalWrite(3,LOW);
digitalWrite(4,LOW);
digitalWrite(5,LOW);
digitalWrite(6,LOW);
digitalWrite(7,LOW);
delay(1000); // wait 1 second
digitalWrite(2,HIGH);
digitalWrite(3,HIGH);
digitalWrite(4,HIGH);
digitalWrite(5,HIGH);
digitalWrite(6,HIGH);
digitalWrite(7,HIGH);
}
else if (yinyanglove=13 || 14)
{
digitalWrite(2,HIGH);
digitalWrite(3,HIGH);
digitalWrite(4,HIGH);
digitalWrite(5,HIGH);
digitalWrite(6,HIGH);
digitalWrite(7,HIGH);
digitalWrite(8,HIGH);
delay(1000); // wait 1 second
digitalWrite(2,LOW);
digitalWrite(3,LOW);
digitalWrite(4,LOW);
digitalWrite(5,LOW);
digitalWrite(6,LOW);
digitalWrite(7,LOW);
digitalWrite(8,LOW);
delay(1000); // wait 1 second
digitalWrite(2,HIGH);
digitalWrite(3,HIGH);
digitalWrite(4,HIGH);
digitalWrite(5,HIGH);
digitalWrite(6,HIGH);
digitalWrite(7,HIGH);
digitalWrite(8,HIGH);
}
else if (yinyanglove=15 || 16)
{
digitalWrite(2,HIGH);
digitalWrite(3,HIGH);
digitalWrite(4,HIGH);
digitalWrite(5,HIGH);
digitalWrite(6,HIGH);
digitalWrite(7,HIGH);
digitalWrite(8,HIGH);
digitalWrite(9,HIGH);
delay(1000); // wait 1 second
digitalWrite(2,LOW);
digitalWrite(3,LOW);
digitalWrite(4,LOW);
digitalWrite(5,LOW);
digitalWrite(6,LOW);
digitalWrite(7,LOW);
digitalWrite(8,LOW);
digitalWrite(9,LOW);
delay(1000); // wait 1 second
digitalWrite(2,HIGH);
digitalWrite(3,HIGH);
digitalWrite(4,HIGH);
digitalWrite(5,HIGH);
digitalWrite(6,HIGH);
digitalWrite(7,HIGH);
digitalWrite(8,HIGH);
digitalWrite(9,HIGH);
}
else if (yinyanglove=17 || 18)
{
digitalWrite(2,HIGH);
digitalWrite(3,HIGH);
digitalWrite(4,HIGH);
digitalWrite(5,HIGH);
digitalWrite(6,HIGH);
digitalWrite(7,HIGH);
digitalWrite(8,HIGH);
digitalWrite(9,HIGH);
digitalWrite(10,HIGH);
delay(1000); // wait 1 second
digitalWrite(2,LOW);
digitalWrite(3,LOW);
digitalWrite(4,LOW);
digitalWrite(5,LOW);
digitalWrite(6,LOW);
digitalWrite(7,LOW);
digitalWrite(8,LOW);
digitalWrite(9,LOW);
digitalWrite(10,LOW);
delay(1000); // wait 1 second
digitalWrite(2,HIGH);
digitalWrite(3,HIGH);
digitalWrite(4,HIGH);
digitalWrite(5,HIGH);
digitalWrite(6,HIGH);
digitalWrite(7,HIGH);
digitalWrite(8,HIGH);
digitalWrite(9,HIGH);
digitalWrite(10,HIGH);
}
else if (yinyanglove=19 || 20)
{
digitalWrite(2,HIGH);
digitalWrite(3,HIGH);
digitalWrite(4,HIGH);
digitalWrite(5,HIGH);
digitalWrite(6,HIGH);
digitalWrite(7,HIGH);
digitalWrite(8,HIGH);
digitalWrite(9,HIGH);
digitalWrite(10,HIGH);
digitalWrite(11,HIGH);
delay(1000); // wait 1 second
digitalWrite(2,LOW);
digitalWrite(3,LOW);
digitalWrite(4,LOW);
digitalWrite(5,LOW);
digitalWrite(6,LOW);
digitalWrite(7,LOW);
digitalWrite(8,LOW);
digitalWrite(9,LOW);
digitalWrite(10,LOW);
digitalWrite(11,LOW);
delay(1000); // wait 1 second
digitalWrite(2,HIGH);
digitalWrite(3,HIGH);
digitalWrite(4,HIGH);
digitalWrite(5,HIGH);
digitalWrite(6,HIGH);
digitalWrite(7,HIGH);
digitalWrite(8,HIGH);
digitalWrite(9,HIGH);
digitalWrite(10,HIGH);
digitalWrite(11,HIGH);
delay(1000); // wait 1 second
}
delay(7000); // wait 7 second before restarting loop
}

--

Here is my love machine:




The ball is a boob feeling blob, with a flex sensor on one side and a pressure sensor on the other. So a person must at the same time do a very light touch one side and pressure on the other side to achieve a combined yin yang lov-o-meter score.

Tuesday, May 26, 2009

Electronics Lab

Ok, after some help from Rory I am feeling much better about this lab. I have no idea what I did wrong in my previous lab. But things are working now.

Measuring Voltage
I'm getting a reading of 17-ish volts for my direct power connection into the breadboard, and a reading of 5.02 v off of the regulator.

A Basic LED Circuit
My soder job sucks!! But, yay. It worked. The LED glow does not nearly match my internal glow at getting it to work. Maybe my resistor is too high.


LED in Series
Put this in wrong the first time. But worked like a charm after I made sure things were connected to the power line.




Components in Parallel
The parallel setup worked too. Though, really am not sure what I am measuring. Took out the power side of one LED but left the ground connected. I then placed the red line against the location the power of the LED would have gone and got no reading. There didn't seem to be any location that I placed the meter that I would get a read....





Generating Variable Voltage with Pontentiometer
Well, the good news is that I am getting better at sodering. Managed to achieve some pretty solid soder this time, unlike last time where my wire simply came unhinged after I detached it. However, the bad news is that I solidly soder-ed a red wire to my ground location. Looks like I now need an additional lesson to un-soder if there is such a thing.

Also, I could get my LED to light up with the Pontentiometer-but not if I was using a resistor (and it was the same resistor I used on the previous exercise so I know that it works).

Monday, May 25, 2009

Breadboard lab


Completed the lab to setup my breadboard with the 5v regulator and the power connector that was soldered in class.

I have pretty much followed the pic as is. I then hooked up the power connector and try to measure the voltage. I got no reading. So, I really have no idea whether I have set the breadboard up wrong, or whether my power connector is bad, or what? I think I will move onto the 2nd lab and hopefully there is something there that will give me some clue as to whether my setup works or not.