ラベル Experiment movies の投稿を表示しています。 すべての投稿を表示
ラベル Experiment movies の投稿を表示しています。 すべての投稿を表示

2010年7月3日土曜日

Aii (Arduino + Wii Nunchuk)

http://www.youtube.com/watch?v=kwhSrHl6ub4



I connect Nintendo Will Nunchuk to Arduino and made Aii.

I connect Aii to Isadora which is running on my desktop.

I connect Isadora that is running on Laptop to Isadora that is running  on my desktop with OSC transmit.

 

Thanks Joe to shake my Aii  !!









2010年6月15日火曜日

Make a simple work with Lily Pad Arduino


LilyPad Arduino is a wearable Arduino.

It uses conduct threads in stead of regular metal wires so that it enable to make a wearable art work or interactive wall cloth.

I did a following experiment with Lily pad; however, I do not recommend you to do a same thing with me since I did not planed perfectly and it was the first time trial. 

I made a gloves with LED. If I press or hold something with finger, the color of LED will be changed. 

Requirement

Lily pad Arduino

conduct thread

power supply for Lily pad Arduino

AAA battery  

10K resistor

Force sensor

LED that came with Lily Pad

Sewing Stuffs (needle, thread)

Cloth or material which you want to be sewed 





Warning: this experiment potentially causes unexpected danger to you and Arduino.

Be safe when you do a experiment with Lily Pad.

If you find anything that unexpected result, plug out power charger( USB or battery ).

I actually almost broke down the circuit of the LilyPad because of shorts of the circuit.

First thing that you need to do is to imagine the final form of the circuit.

It must be better to spend a time to figure out how you sew thread to the glove.

I am sure that you will encounter a lot of problems while you are sewing since I also encountered a lot of problems.

Basic idea of circuit









As you see some of the threads nearly touch each other, that really bad.

I should have planned more nicely.



Program


int ledPin=10; // declare variables
int ledPin2=10;
int pressure=0;
int val,val2;
void setup()
{
  pinMode(ledPin, OUTPUT); //setup pin
}
void loop()
{
  val = analogRead(pressure)/4;

//load data and convert it to suitable value for PWM
val2 = 255-val;

//load data and convert it to suitable value for PWM
analogWrite(ledPin, val);
delay(400);
analogWrite(ledPin, val2);
delay(400);
}







2010年6月12日土曜日

Sensor 05 Forece sensor

Building up force sensor

Requirements

Arduino

10K Ohm Resistor

Force sensor

Wires



Circuit







Program

The program for force sensor is simple

int pinX=0; //variables

int dataX;

void setup()
{
Serial.begin(9600); //setup serial speed
}
void loop()
{
dataX=analogRead(pinX); // read a value

Serial.println(dataX);//send a value to PC


delay(100);//regulate a time
}



 or you can use more shorter program



void setup()
{
Serial.begin(9600); //setup serial speed
}
void loop()
{

Serial.println(analogRead(0));//read and send a value to PC


delay(100);//regulate a time
}


whichever you want

Experiment Movie



2010年6月10日木曜日

LilyPad Arduino



Testing LilyPad Arduino

http://arduino.cc/en/Guide/ArduinoLilyPad






test based on a webpage

http://web.media.mit.edu/~leah/LilyPad/06_rgb.html

instead of using 9,10,11 and 5V pins I use 3,5,6 and 13 pins.

The pins 3,5,6,9,10, and 11 have a function of pwm.

From the test, I conform that the function of pwm is available.



LilyPad + LEDs + Buzzer

I added following cords.

int soundPin=2; 

int frequency;

pinMode(soundPin,OUTPUT);


frequency=random(800,3000);
tone(soundPin, frequency,5000);
delay(100);

I did a test of temp. sensor but I do not know whether temp. sensor works properly or not.


Stand alone lilypad

 




Accelerometer test

instruction

Connect X,Y, and Z of the accelerometer to the analog input 0, 1, and 2 respectively.

Also connect 5V and ground.

int pinX=0;
int pinY=1;
int pinZ=2;
int dataX,dataY,dataZ;

void setup()
{
Serial.begin(9600);
}
void loop()
{
dataX=analogRead(pinX);
dataY=analogRead(pinY);
dataZ=analogRead(pinZ);
Serial.print(dataX);
Serial.print("-");
Serial.print(dataY);
Serial.print("-");
Serial.println(dataZ);

delay(100);
}





2010年6月8日火曜日

Sensors 01 Piezo

Piezo vibration sensor

explanation of Piezo

http://arduino.cc/en/Tutorial/Knock

 Requirement

10k Ohm Resister(any valued resistor is fine but it is hard to get a signal if you use lower resistor and it is potential risk to break down analog input if you use too high resistor)

piezo

wires

Arduino




This exercise is very simple.

Circuit



I wrongly put a LED in a picture but it does not do anything.



Program

I made a very simple program to check

void setup()
{
  Serial.begin(9600);//setup serial speed
}
void loop()
{
  Serial.println(analogRead(0)); // gets data from analog pin 0 and send to computer
  delay(500); //not to send too much information
}


It actually the resistor is critical for this circuit.

I originally used 100k ohm resistor but the value of analog signal was so tiny.

Also the result is deeply depend on piezo itself. I tried three different piezo but they send back different amount of values.





Exercise and Tutorial 4

 http://www.lulu.com/items/volume_63/1108000/1108699/4/print/ARDUINO_NOTEBOOKv6.pdf

This tutorial is based on the PDF page 35 about servo, and I changed program to check my understanding of the tutorial.

The PDF tutorial has a good information but the program seems complex. I simplified a program and add a little function.

In the following tutorial I am going to explain the way to control servo motor in a different way that explained in a tutorial of the Arduino web page.

In way that is introduced in a Arduino web page is use servo library to control the servo motor. Therefore, only pin9 and pin10 is available for servo.

However, the pin 9 and 10 has a function of pwm and you might want to use them for other purposes.

This tutorial enable you to use any digital pin to control servo motor.

Requirements

Servo motor 

(you may need a pin that has three legs both side to connect servo to the board)

10K resistor

Switch

Wires

Arduino





Before we start we need to understand more about servo motor

From the PDF

 http://www.lulu.com/items/volume_63/1108000/1108699/4/print/ARDUINO_NOTEBOOKv6.pdf

"Hobby servos are a type of self-contained motor that can move in a 180º arc. All that is needed is a pulse sent every 20ms."


From the Arduino web page

http://arduino.cc/en/Tutorial/Knob

"Servo motors have three wires: power, ground, and signal. The power wire is typically red, and should be connected to the 5V pin on the Arduino board. The ground wire is typically black or brown and should be connected to a ground pin on the Arduino board. The signal pin is typically yellow or orange and should be connected to pin 9 on the Arduino board."

I found additional useful information from Wikipedia

http://en.wikipedia.org/wiki/Servo_motor

"A servo pulse of 1.5 ms width will set the servo to its "neutral" position, or 90°. For example a servo pulse of 1.25 ms could set the servo to 0° and a pulse of 1.75 ms could set the servo to 180°. The physical limits and timings of the servo hardware varies between brands and models, but a general servo's angular motion will travel somewhere in the range of 180° - 210° and the neutral position is almost always at 1.5 ms."


Now we got a enough information to program and build up circuit, so that let's try based on these information.

Circuit






Program

/*

This program is enable you to rotate a servo motor without using a Arduino library.

If you hit a  switch the motor will rotate opposite direction.

*/

int ledPin=3;//switch 
int pin=2;//for servo motor control 
int val;
int offCount = 1450;// you can change the rotation of the servo motor 
int onCount = 1550;//same as here 

void setup()
{
pinMode(pin, OUTPUT);//set up pins 
pinMode(ledPin, INPUT);
}
void loop()
{
val= digitalRead(ledPin); // get data from switch 
if (val==false)

//check whether switch is on or off you can use 0 instead of false 
{
digitalWrite(pin, HIGH); //send a pulse 
  delayMicroseconds(offCount);//it is important for servo motor 
digitalWrite(pin, LOW);
delay(20);// also important. If you omit it, the motor do not work properly. 
}
else
{

// when you switch on
digitalWrite(pin, HIGH);
  delayMicroseconds(onCount);
digitalWrite(pin, LOW);
delay(20);
}

}



If you put a value 1500 at offCount or onCount ot both the motor does not work but it does not mean broken but it is balanced.

I do not know how much angle does our servo motor can take, but we can put a value from 1250 to 1750 safely.




Extra

Ardui-Bot (Arduino on the Boe-Bot frame)





2010年6月7日月曜日

Exercise and Tutorial 3

http://www.lulu.com/items/volume_63/1108000/1108699/4/print/ARDUINO_NOTEBOOKv6.pdf

This exercise based on the PDF p32,p34 "pwm output" out put and I modified a program to check my understanding.

The term pwm output is Pulse-width modulation that allow to use digital output like as analog output.

The following circuit and program will adjust the brightness of the  LED by the darkness of the place with photo-sensor and pwm.

Requirements

220Ω resistor

more than 10kΩ resistor (depend on the darkness of a room. I use 21kΩ)

1kΩ resistor(not necessary to use 1kΩ)

LED

Photo-sensor

Wires

Arduino 

Program

/*

Basically, this program works like a bridge between analog input and pwm output.

Get a value from photosensor and do calculation to adjust a value for pwm with arithmetics. 

*/

int ledPin = 9; // PWM pin for the LED
int anaPin=0;
int val;


void setup(){
Serial.begin(9600);
Serial.println("start");
}
void loop()
{
 val = analogRead(anaPin)/4; 

/*

The program get a vale from analog input.

However, the value of analog input takes from 0 to approx. 1000

,but for the pwm we need a value from 0 to 255.

Therefore, the value is divided by 4.

*/
Serial.println(val); // just for checking a value 
val = 255 - val;

/*

Since we want to light the LED when a room became dark,

we need to do kind of flip the value. 

So that we need to subtract a value from 255.

*/
analogWrite(ledPin, val);// send a signal and value to the pin 
delay(100);
}



Hardware setup



Need to adjust the resistance of resisters case by case.

Work movie





2010年6月6日日曜日

Today's exercise(homework)2


http://www.lulu.com/items/volume_63/1108000/1108699/4/print/ARDUINO_NOTEBOOKv6.pdf

The below program is based on the things that I learned in the PDF document page 16 to 26.

Learned: complex condition cords with "if" and "while".

This original program tells the value from analog input, which is connected to the Potentiometer, with Green LED and Red LED and sound.

If the analog input got more electrical flow, Arduino lights Green LED. If the flow is middle, Arduino lights Red LED. If the flow is low or none, Arduino tells us through the speaker.

I use commends that learned through the PDF exercise, in order to check my understanding.

Requirements

Arduino basic kit(two LEDs, possibly red and green; speaker; potentiometer and wires)

Resistor (more than 2. The number depend on how much Ω  is it)


 

Program

/*

This is a middle part of the exercise of PDF p16-26
http://www.lulu.com/items/volume_63/1108000/1108699/4/print/ARDUINO_NOTEBOOKv6.pdf
This exercise contains mainly
if else
while
random(min,max)
This program is made to check my understanding of the contents of the PDF.
This program also requires my original circuit setup. I will post it on my blog.
*/

int digiPin=13;
int digiPin2=2;
int digiPin3=7;
int anaPin=0;
int val;
int duration;

void setup()
{
Serial.begin(9600); //setup serial seep
pinMode(digiPin, OUTPUT); //setup digital pins
pinMode(digiPin2,OUTPUT);
pinMode(digiPin3,OUTPUT);
}
void loop()
{
val=analogRead(anaPin); //get a value from analog pin 0
if (val > 500) //if analog pin 0 got more than 500, do followings
{
digitalWrite(digiPin, HIGH); //light up LED at digital pin 13
delay(val); //dulation is decided by the value of analog value
Serial.println("more than 500"); //send back from Arduino
digitalWrite(digiPin, LOW);
delay(1000);
}
else // if analog pin 0 got less than 500, do followings
{

while(val<=300)// if analog pin 0 got less than 300, do play a sound

{

tone(digiPin3, 494, 500); // command for sound

delay(500);  

val=analogRead(anaPin);  // This step is important. If you forget it, you can't go out of while loop

}

// if value is 300

Serial.println("midium and random duration");

digitalWrite(digiPin2,HIGH); //turn on LED connected to digital pin 2.
duration = random(1000,3000); // LED lights from 1 to 3 second
delay(duration);
digitalWrite(digiPin2,LOW);
duration = random(1000,3000);
delay(duration);
}

}



val=analogRead(anaPin); is  important in the while loop. I did not put this commend at first so that the program did not work what I wanted. It was a good study.



Hardware setup






My work movie.






Today's excersise(homework)

http://www.lulu.com/items/volume_63/1108000/1108699/4/print/ARDUINO_NOTEBOOKv6.pdf

The below program is based on the things that I learned in the PDF document page 1 to 15.

Discovery : "Array", which can store values, is very useful.

This program light the led that connected to the digital pin #13 for 0.01 second 5 times and send a message back to the computer.

Requirement

Arduino + LED (If you use digital pin 13 and have a proper LED)

or

Arduino + LED + resister and wires(same as picture below)



Program

/*
This is a program that to show thigs that I learned from
http://www.lulu.com/items/volume_63/1108000/1108699/4/print/ARDUINO_NOTEBOOKv6.pdf Page 1 to 15
I am going to include commend as much as possible.
*/
/*
This is a block comment. I can write any thing in this section.
*/
// This is also comment. line comment


//list of variables
int variable;//integer that declares variables. most commonly used. 16bit 32,767 to -32,768.
int abc, def, ghi; // variables can take this form
int pin=13; // and also it can take this form
int y = 1;
byte b; //8 bit 0-255
long l; //32 bit 2,147,483,647 to -2,147,483,648
float f; //32 bit 3.4028235E+38 to -3.4028235E+38
double dob; // other form of varable for floating decimal
char ch; // also other form of variable. char has a different function from int
int delayValA[ ]={10, 3000, 5000}; //arrays that can stor the values

void setup()
{ //defines the starting point of function
Serial.begin(9600); // setup connection speed 9600 is good for my arduino
// very important. if you do not get respond from Arduino it must be because of this command

//void setup is the first function of the program
pinMode(pin, OUTPUT); // sets the 0pin as out put

}//defines the ending point of function
void loop()
{
for (int i=1; i<=5;) // this variable works only in the for loop

{

i++; // increment. there is many increment and decrement such as -- ++ *=

Serial.println(i);

digitalWrite(pin,HIGH);//send high signal(1)to the pin

delay(delayValA[1]); // delay the commend
digitalWrite(pin,LOW);//send low signal(0)to the pin
delay(delayValA[2] + 1000); //arithmetic works like this
digitalWrite(pin,HIGH);//send high signal(1)to the pin
delay(delayValA[1]); // delay the commend
digitalWrite(pin,LOW);//send low signal(0)to the pin
delay(delayValA[2] + 1000); //arithmetic works like this
}
Serial. println("out of for loop "); //println is use for send a message from Arduino
delay(delayValA[3] + 2000);
}


Actually, the PDF does not explain "for" commend and it is not easily understandable.

This link is useful to learn about For commend.

http://arduino.cc/en/Reference/For


for ( variable initialize; test; additional information)

for ( int i =0; i<10;>


Hardware setup





Experiment movie






2010年6月4日金曜日

2010年6月2日水曜日

Pure Data sample music

Trial to play a sample music from tutorial.




2010年5月30日日曜日