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);

}






Great information about Shift register

http://www.arduino.cc/en/Tutorial/ShiftOut

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

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


This is a really great tutorial for beginner and and very useful. 

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



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年7月1日木曜日

PureData

Lots of information about Pure Data 


http://en.flossmanuals.net/PureData/

PuraData Practice

PureData Network access

My professor Emily upload an interesting link to a webpage that is introduce hot to connect Isadora over the network.

I tried it with PureData.




In order to do the thing with one computer. I connect Pure Data to the same Pure Data.

I chose localhost(127.0.0.1) and connect port 1300 with UDP connection instead of TCP.


The below link is a webpage, which I referred.

http://en.flossmanuals.net/PureData/Receive 




Display an image with PuraData(Open GL)

My computer's graphic card can handle OpenGL really well so that I tried to display an image with PureData.




PureData Webcam experiment





PureData movie experiment

PureData Video Editing