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

2010年11月20日土曜日

Arduino Daisy Chain 03


I finally fined a way of daisy chain Arduino.


Prepare two Arduino

Connect USB cable to one of Arduino

Put one side of a wire to 5V of the Arduino that USB is connected to.

The other side of the wire go to vin of the other Arduino.

Connect Tx to Rx of the other Arduino.

Connect Rx to TX of the other Arduino.



2010年8月8日日曜日

Arduino Daisy Chain 2


Program for Arduino Daisy Chain

This program is specifically designed to communicate with Isadora.

You can use this program as a switch in Isadora.



Program for a host Arduino

/*

this program is just send on and off signal to client Arduino every 2 second

*/

int signalPin=3;
void setup(){
pinMode(signalPin, OUTPUT);

digitalWrite(signalPin, LOW);
}
void loop(){
 
digitalWrite(signalPin, HIGH);
delay(2000);
digitalWrite(signalPin, LOW);
delay(2000);
}


Program for a Client

int ReadingPin = 0;
int val;
void setup(){
Serial.begin(9600);

}
void loop(){
val = analogRead(ReadingPin);

/*

with this "if" commend, Arduino does not send any data to Isadora when an analog pin receive nothing.

*/
  if (val>100){
  val=1;//you can change value to anything you want 
Serial.print(1,DEC);
Serial.print (val, DEC);
Serial.println();
delay(50);
}
}






Projector test











2010年8月6日金曜日

fixed a troble of a LEDs controller




LED controller is made by 4 8-bit shift resistors, 28 transistors and 28 resistors.





2010年8月2日月曜日

2010年7月19日月曜日

2010年7月4日日曜日

7 segment with Shift Resistors

I did a test of controlling 7 segment with Shift resistor 8-Bit - 74HC595.

I finally control two 7 segment with two Shift resistor 8-Bit - 74HC595.


Tutorial

Shift resistor 8-Bit - 74HC595 is very useful since Arduino have only 13 digital pins we may need more pins to make a more complex controller.

7 segment is one of a example that need a lot of pins to control.

So that I will explain Shift resistor 8-Bit - 74HC595 with two 7 segment.



Requirement

Shift Resistor 8-Bit - 74HC595

Two 7 segment

A lot of wires

14 220Ohm resistors

Breadboards(At least you need one large  Breadboard) I use one  Breadboard and two small  Breadboard.

Arduino

Arduino program

computer with USB

Calculator (you need to change decimal to binary)

Circuit

latchPin is 8.

clockPin is 12.

dataPin is 11.



When you send a value with ShiftOut, the value which transformed into
a binary data will conrespond to the red pin(Q0 ~ Q7).
Since this is a 8 bit shift resistor, the range of the value will be 0~255.
(2x2x2x2x2x2x2x2)
For example, if you send a value 96, it will transformed to 011000000.
Since number 0 means off and number 1 means on, in this case Q6 and Q5
will be HIGH.






Program


//Original program is http://arduino.cc/en/Tutorial/ShftOut11


//**************************************************************//
// Name : shiftOutCode, Hello World
// Author : Carlyn Maw,Tom Igoe, David A. Mellis
// Date : 25 Oct, 2006
// Modified: 23 Mar 2010
// Version : 2.0
// Notes : Code for using a 74HC595 Shift Register //
// : to count from 0 to 255
//****************************************************************


//I modified slightly


//Pin connected to ST_CP of 74HC595
int latchPin = 8;
//Pin connected to SH_CP of 74HC595
int clockPin = 12;
////Pin connected to DS of 74HC595
int dataPin = 11;

void setup() {
//set pins to output because they are addressed in the main loop
pinMode(latchPin, OUTPUT);
pinMode(clockPin, OUTPUT);
pinMode(dataPin, OUTPUT);
}

void loop() {
//count up routine

//ground latchPin and hold low for as long as you are transmitting
digitalWrite(latchPin, LOW);

//You can change the value.

// If you use the same circuit

// TO DISPLAY   1 is 96, 2 is 220, 3 is 244, 4 is 104, 5 is 182, 6 is 62, 7 is 226, 8 is 254, 9 is 230, 0 is  250.
shiftOut(dataPin, clockPin, MSBFIRST, 254);
   

// second shift resister

//Same as the hear
shiftOut(dataPin, clockPin, MSBFIRST, 226);


//return the latch pin high to signal chip that it
//no longer needs to listen for information

digitalWrite(latchPin, HIGH);
delay(1000);

}






2010年7月3日土曜日

Practical Tutorial of How to make Aii (Arduino + Wii Nunchuk) and use it

This is a tutorial of How to make Aii(Arduino and Wii Nunchak).

This exercise enables you to connect Wii Nunchuk to Arduino.

You will also learn how to connect Aii to Isadora and how to send a OSC data over the Internet(Wi-Fi).

Wii Nunchuk is a great tool for us. It has 7 different input device(two button, two potentiometer like function and one XYZ accelerometer)

Having an Accelerometer is really great, because the cost  of accelerometer is from 19.95 to $39.95.(SparkFun.com) However, if you order Wii Nunchuk from Amazon.com, it costs only from $3.25 to $19.95. 

I connect Nintendo Will Nunchuk to Arduino and made Aii.

The program was based on the information of http://www.windmeadow.com/node/42

I added little more cords so that it works with Isadora.

To make a circuit, I referred http://todbot.com/blog/2007/10/25/boarduino-wii-nunchuck-servo/

For the information of OSC transmission with Isadora, I referred http://vjskulpture.wordpress.com/2010/01/14/basic-open-sound-control-osc-isadora-mac/

Requirement

Arduino

Arduino program

Isadora

Wii Nunchuk

Wires(you may need alligator clips and soldering iron)

Two computer that is connected to a same router.

Red LED



Circuit









Program

You can use a program from http://www.windmeadow.com/node/42

But you have to change the function of void print() in the program to following.

void
print ()
{
int joy_x_axis = outbuf[0];
int joy_y_axis = outbuf[1];
int accel_x_axis = outbuf[2] * 2 * 2;
int accel_y_axis = outbuf[3] * 2 * 2;
int accel_z_axis = outbuf[4] * 2 * 2;

int z_button = 0;
int c_button = 0;

// byte outbuf[5] contains bits for z and c buttons
// it also contains the least significant bits for the accelerometer data
// so we have to check each bit of byte outbuf[5]
if ((outbuf[5] >> 0) & 1)
{
z_button = 1;
}
if ((outbuf[5] >> 1) & 1)
{
c_button = 1;
}

if ((outbuf[5] >> 2) & 1)
{
accel_x_axis += 2;
}
if ((outbuf[5] >> 3) & 1)
{
accel_x_axis += 1;
}

if ((outbuf[5] >> 4) & 1)
{
accel_y_axis += 2;
}
if ((outbuf[5] >> 5) & 1)
{
accel_y_axis += 1;
}

if ((outbuf[5] >> 6) & 1)
{
accel_z_axis += 2;
}
if ((outbuf[5] >> 7) & 1)
{
accel_z_axis += 1;
}

// This is a section that is actually modified.

Serial.print(1,DEC);
Serial.print (joy_x_axis, DEC);
Serial.println();

Serial.print(2,DEC);
Serial.print (joy_y_axis, DEC);
Serial.println();

Serial.print(3,DEC);
Serial.print (accel_x_axis, DEC);
Serial.println();

Serial.print(4,DEC);
Serial.print (accel_y_axis, DEC);
Serial.println();

Serial.print(5,DEC);
Serial.print (accel_z_axis, DEC);
Serial.println();

Serial.print(6,DEC);
Serial.print (z_button, DEC);
Serial.println();

Serial.print(7,DEC);
Serial.print (c_button, DEC);
Serial.println();

Serial.print ("\r\n");
}

// Encode data to format that most wiimote drivers except
// only needed if you use one of the regular wiimote drivers
char
nunchuk_decode_byte (char x)
{
x = (x ^ 0x17) + 0x17;
return x;
}


For more information check my tutorial of Isadora + Arduino

http://art-research2010summer.blogspot.com/2010/06/tutorial-01-isadora-and-arduino.html


Isadora

You do not do something special for Isadora but you have to make a lot of "Serial in Watcher".

Check below again to know how to do it.

http://art-research2010summer.blogspot.com/2010/06/tutorial-01-isadora-and-arduino.html

You need 7 "Serial in Watcher" to get all of the benefit of Wii Nunchuk

All of the "Serial in Watcher" need ideal number to identify each other.

Program for Isadora's Serial in Watcher(double click and open a window)

Serial in Watcher 1

"1"

StickA: integer = 4 digits

Serial in Watcher 2

"2"

StickB:integer = 4 digits

Serial in Watcher 3

"3"

Acc1: integer = 4 digits

Serial in Watcher 4

"4"

Acc2: integer = 4 digits

Serial in Watcher 5

"5"

Acc3: integer = 4 digits

Serial in Watcher 6

"6"

ButA:interger= 4 digits

Serial in Watcher 7

"7"

ButB: integer = 4 digits


Go to the OUTPUT and Setup Serial (choose Serial such as COM4 Speed 9600) and check Enable Serial 





You can play around with Aii to see how these value will change.


Make "OSC transmit"

Setup IP address of the computer that you want to control and connect the value of the "OSC transmit" to the "Serial in Watcher" which you like.


Setup your another computer

If you do not know how to check your IP address, see my blog post about Arduino Server (below address).

http://art-research2010summer.blogspot.com/2010/06/arduino-ethernet-shield.html

Run Isadora in your another computer(in my case it is a Laptop).

Make a OSC listener, that it!.

You will get a value and you can use this value for anything that you want to use.

I use "Calculator" to adjust a value and connect it to "Dot" size.





You DONE



2010年6月28日月曜日

2010年6月22日火曜日

Sensor 07 Gyro (LISY300AL)

Requirements

Wires

Arduino

Gyro (LISY300AL)

Computer with USB

This sensor is easy to program. Just  build a program that read a data from an analog pin.

The pins of sensor seems tricky but basically you connect ST and PD to ground.










Arduino Ethernet Shield with temp sensor

This blog post is badly organized because of the technical difficulty.(Blogger can not show HTML cords )

I highly recommend you to check this blog post with Opera browser.(Even Opera it is disorganized)

http://www.opera.com/

I did not check with other browser such as Safari, FireFox, Chrome and IE.

Do not copy and paste uploaded program to Arduino program. I do not know it is works or not.

Requirement

Temperature/Humidity sensor.

Four wires.

Two Ethernet cable

Router

Arduino

Arduino program

Arduino official Ethernet Shield with WIZnet W5100 chip

USB

computer with Ethernet and USB. 

Knowledge of basic HTML

Finished my former tutorial of Ethernet Shield



In this experiment you will build up webpage that will show a temperature and humidity of the critic room of the sculpture studio. The webpage will broadcast thorugh a Arduino web server.

This experiment based on 

http://wiring.org.co/learning/basics/humiditytemperaturesht15.html

I referred a  program and example of circuit in the webpage.


You will put together Arduino's web server program and temp/humid program.

The program for temperature and humidity sensor is the most difficult program I have ever see.

However, we will modify ready made program so that  it  will not be so much complex.


First we need to do is to open a sample program of the web server.

This program has several functions.


The one is get a data from analog pins.

The second is answer the request of web browser and send a data based on http rule.

The Third is information of webpage itself.


I will not touch anything to the second function so that it will be more easy.

If you look through the program you will see a loop of "for".

In the section you will also see a lot of 

client.print("");

This cord works as the same as "Serial.print".

In stead of send a data through serial connection, client.print send a data through Ethernet.

In side of the parenthesis of the "client.print("");" you will see "

<br />". This is another program called HTML.

Arduino sends a data of HTML to your browser with "client.print".

So if we change contents  of the program of HTML the webpage will show up differently.

 I changed a loop of "for" to the following


client.print("Today's NewPaltz Sculpture Studio");
client.print("<br />");
client.print("temperature");
client.print((long)temperature, DEC);
client.println("<br />");
client.print("humidity ");
client.print((long)humidity, DEC);
client.print("<br />");
client.print("sensor will reload every appx. 2 minute.");
client.print("<br />");
client.print("<image src="http://www.newpaltz.edu/sculpture/images/main_image.jpg">");
client.print("<br />");
client.print("This report send from Critic room by Arduino server and sensor BFA Shotaro.");
client.println("<br />");

the

<img src="" /> is a HTML commend that will show a image. I linked the commend to the picture of the New Paltz sculpture webpage. 

client.print("humidity ");
client.print((long)humidity, DEC);

These are commend that will show data from the sensor.

Do not wrongly erase a commend 

break;

If you do that your web  browser will load a webpage forever.

We already made the program for HTML.


We need to add a program of the sensor.

Basically you can copy the program that you got from the link which I introduced.

And paste them in a certain places.

However there is a one problem will occur.

The program of the sensor contains the commend

delay(300000);

which means that if you copy and paste directly your Arduino server work only every 5 minute.

Since 5 minute is too long, your web browser will be timed out.

Therefor, you need a lack to see the webpage which is none-sense .

However, if we delete it it must be not so good for arduino and server.

In order to avoid this issue we need to modify our program.

if(counter>=100000, ++counter)
{
sendCommandSHT(temperatureCommand, dataPin, clockPin);
waitForResultSHT(dataPin);
val = getData16SHT(dataPin, clockPin);
skipCrcSHT(dataPin, clockPin);
temperature = (float)val * 0.01 - 40;
sendCommandSHT(humidityCommand, dataPin, clockPin);
waitForResultSHT(dataPin);
val = getData16SHT(dataPin, clockPin);
skipCrcSHT(dataPin, clockPin);
humidity = -4.0 + 0.0405 * val + -0.0000028 * val * val;
counter=0;
}
you you change the program to this the Arduino check temperature only every 100 seconds and the rest of the time Arduino works as a server.

Now you are ready.

Setup MAC address and IP address based on former tutorial, upload and connect Ethernet cable.


You can see your webpage from your browser.


 

 






 

 









2010年6月21日月曜日

Arduino Ethernet shield

I finally figure out to use Ethernet Shield.

Even though Arduino provides a good example of web server, the beginner really does not understand it well.

Also the book "Making Things Talk" did not help me at all. Forget about it, it will not help you so much.


This is a tutorial of how to use Arduino's official Ethernet Shield as a web server. In oder to make a thing simple I do not add any sensor to analog pin of Arduino but you can play around it.  


Requirement

Your computer which has a Ethernet connection and USB. (I will explain about a case of Windows. If you are user of Linux or ... Mac find a same way by yourself. I am not familiar with  Linux and do not have Mac)

Internet connection

Arduino

Arduino program

Official Arduino Ethernet Shield which has a chip WIZnet W5100

two Ethernet cable. Do not use wireless except some situation. Especially if you want to do a same thing at school never use wireless otherwise you will wast 2 hours to realize your problem.

USB cable

Web Browser. (I checked with IE in this time, but I think I really does not matter)

A little knowledge of network(I will explain later).


Step one

First thing you need to do is to build Arduino Ethernet shield ready to use.

see the following picture.



you can add sensor to the analog pin if you want you will those value through the Internet.

+ Do not connect any thing to the digital pins number 10, 11, 12, and  13 . Even though they are looked vacant pins since they are already used by Ethernet Shield.

Second Step

Load a ready made program that is in samples.

File>Examples>Ethernet>WebServer.



The ready made program will be load in a new window.

However it is not ready to upload them.

If you see the program you will see a cords



byte mac[] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
byte ip[] = { 127, 0, 0, 1 };

Server server(80);

These are very fundamental information of network.

Since I am not a specialist of network, I can not tell exactly but mac and ip are addresses that indicate your computer. 

the number 80 is called a port number. Usually "http"(which you often seen in a address bar of the browser) uses port number 80.

Before upload we have to figure out and tell the address of the Arduino. (I think probably that is because Arduino Ethernet shield do not have a function of DHCP server.)

Step 3

Detect addresses.

Fortunately, we do not need to spend so much effort to figure out addresses.

In the book "Making Things Talk" mention about the software PuTTy(PuTTy is Only for Windows, Linux and Mac need other software) in order to find a address called MAC address.

MAC address is a physical address that is recorded in your microchip and it will not change.(We also need IP address that will change normally unless you have a fixed IP address or do a special setup.

Look at a back side of Arduino Ethernet Shield 

You will see unfamiliar numbers that is looked like XX-XX-XX-XX-XX-XX

Since it is a hexadecimal number system the numbers contain alphabet. 






These numbers(Actually number) are called MAC address.  

Next you need to find your IP address.

Connect your computer to the Internet with Ethernet Cable.

You need to do a "Hacker" like thing to find. 

======Windows only ========================

go to Start> accessory>command prompt.

You will see DOS  window(I do not know how many people know DOS but)

You have to use it CUI

Type following and hit Enter:

ipconfig /all

This is a very useful commend that worth to remember.

You will see following thing



(sorry my computer runs Japanese operating system)

You will probably see "IPv4 address" which is your IP address.

IP address is looked like thins:

127.0.0.1

Now you have all the information you need.

=============For Linux and Mac and Windows user, who do not like CUI,===========

Go a web page that will tell your IP address. There are so many web page that tells your IP address.

Do not use proxy server and also your Internet security application potentially cause problem.

Linux must have a command that tells your IP address, since it is a operating system mainly for server but I am not sure.

I think Mac also has similar thing but I do not know.

==================================================================


go back to the program and replace the number to your number.

byte mac[] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
byte ip[] = { 127, 0, 0, 1 };

Server server(80);

 You do not need to do any thing for port number unless your router has some special setup.

Step 4

You are ready to upload a program to the Arduino.

Upload the program.

Unplug the Ethernet cable that is connected to your computer(only the side of computer) and plug it to Arduino.



Bring another new cable and connect  your computer and the router.

Step 5

Run a browser.

I use IE since I used a school computer that was already connected to the network.

In the browser's address bar, type the IP address that you program.


http://127.0.0.1(use your own number.)


The number something like 127.0.0.1 is same as http://www.google.com they are looked different but they actually almost same. Since for humans  IP address is not easy to remember, a DNS server change it to words that human can easily remember.

(127.0.0.1 does not indicate Google webpage. 127.0.0.1 is a special IP address that is indicate your computer(localhost) so that if you run server system in your computer with Apache you will use it.)  


If you see a information of analog pin of Arduino.

If you choose other than 80 for port number you need to specify the port.


http://127.0.0.1:8080

I you have any trouble it must be caused by firewall of the router, programed wrong number or other many reasons.