2010年7月19日月曜日
2010年7月14日水曜日
2010年7月13日火曜日
Program for my artwork Ver 0.1 (unckecked)
Program for Art Work
Version 0.1
Huge 7 segment controller with Shift registor.
Made by Shotaro N 2010
*/
//reguler variable
int c;
int rec1, rec2, rec3, rec4;
// error checker
int checkND=0;
//controller variables
int vTime=500;
int amount7S =4;
//Shift Registor
int latchPin = 8;
int clockPin = 12;
int dataPin = 11;
void setup()
{
Serial.begin(9600);
pinMode(latchPin, OUTPUT);
pinMode(clockPin, OUTPUT);
pinMode(dataPin, OUTPUT);
}
void loop(){
if(Serial.available()>0){
//reading validity of words
block1();
block2();
block3();
block4();
//to ignore words with EXtra
EXchecker();
//main checking process
if (checkND ==amount7S){
//main LED
digitalWrite(latchPin, LOW);
c = rec1;
process();
c = rec2;
process();
c = rec3;
process();
c = rec4;
process();
digitalWrite(latchPin, HIGH);
delay(vTime);
}
}//main if end
//protection reset
checkND = 0;
}
//EDN OF VOID LOOP
//first block
void block1(){
rec1=Serial.read();
c = rec1;
Cprocess();//check prosecc
}
//second block
void block2(){
rec2=Serial.read();
c = rec2;
Cprocess();
}
//third block
void block3(){
rec3=Serial.read();
c = rec3;
Cprocess();
}
//Fourth block
void block4(){
rec4=Serial.read();
c = rec4;
Cprocess();
}
// checker
void Cprocess(){
if(c=='8'){
checkND = checkND + 1;
}
else if(c=='0'){
checkND = checkND + 1;
}
else if(c=='1'){
checkND = checkND + 1;
}
else if(c=='2'){
checkND = checkND + 1;
}
else if(c=='3'){
checkND = checkND + 1;
}
else if(c=='4'){
checkND = checkND + 1;
}
else if(c=='5'){
checkND = checkND + 1;
}
else if(c=='6'){
checkND = checkND + 1;
}
else if(c=='7'){
checkND = checkND + 1;
}
else if(c=='9'){
checkND = checkND + 1;
}
else{
}
}
//judgement & lighting
void process(){
if(c=='8'){
shiftOut(dataPin, clockPin, MSBFIRST, 254);
}
else if(c=='0'){
shiftOut(dataPin, clockPin, MSBFIRST, 250);
}
else if(c=='1'){
shiftOut(dataPin, clockPin, MSBFIRST, 96);
}
else if(c=='2'){
shiftOut(dataPin, clockPin, MSBFIRST, 220);
}
else if(c=='3'){
shiftOut(dataPin, clockPin, MSBFIRST, 244);
}
else if(c=='4'){
shiftOut(dataPin, clockPin, MSBFIRST, 104);
}
else if(c=='5'){
shiftOut(dataPin, clockPin, MSBFIRST, 182);
}
else if(c=='6'){
shiftOut(dataPin, clockPin, MSBFIRST, 62);
}
else if(c=='7'){
shiftOut(dataPin, clockPin, MSBFIRST, 226);
}
else if(c=='9'){
shiftOut(dataPin, clockPin, MSBFIRST, 230);
}
}
// EXchecker. protect system from invalid value
void EXchecker(){
if(Serial.available()>0){
int reader = Serial.read();
if(reader == -1){
}
else{
checkND = checkND +10;// protect from hack
}
}
}
2010年7月9日金曜日
2010年7月8日木曜日
Shorten program for 7 segment without Shift resister (unchecked program)
I made it for my practice of programing
int c;
int REC[]={0,0,0};
int checkND=0;
int newL[]={0,0,0};
int L=10;
int refleshT=1;
int vTime=500;
int amount7S =3;
void setup()
{
Serial.begin(9600);
for (int i=2; i<10; ++i){
pinMode(i,OUTPUT);
}
for (int i=10; i<13; ++i){
pinMode(i,INPUT);
}
for (int i=10; i<13; ++i){
digitalWrite(i,HIGH);
digitalWrite(i,LOW);
}
}
void loop()
{
if(Serial.available()>0){
BLOCK();
EXchecker();
if (checkND ==amount7S){
for(int FT=0; FT < vTime; ++FT){
for(int i=0; i<=3; i++){
L = newL[i]+10;
c = REC[i];
process();
}
}
}
nothing();
}
checkND = 0;
}
void zero(){
nothing();
digitalWrite(2,HIGH);
digitalWrite(4,HIGH);
digitalWrite(5,HIGH);
compress();
delay(refleshT);
}
void one(){
nothing();
digitalWrite(7,HIGH);
digitalWrite(8,HIGH);
delay(refleshT);
}
void two(){
nothing();
digitalWrite(3,HIGH);
digitalWrite(4,HIGH);
digitalWrite(5,HIGH);
digitalWrite(8,HIGH);
digitalWrite(9,HIGH);
delay(refleshT);
}
void three(){
nothing();
digitalWrite(3,HIGH);
digitalWrite(5,HIGH);
compress();
delay(refleshT);
}
void four(){
nothing();
digitalWrite(2,HIGH);
digitalWrite(3,HIGH);
digitalWrite(7,HIGH);
digitalWrite(8,HIGH);
delay(refleshT);
}
void five(){
nothing();
digitalWrite(2,HIGH);
digitalWrite(3,HIGH);
digitalWrite(5,HIGH);
digitalWrite(7,HIGH);
digitalWrite(9,HIGH);
delay(refleshT);
}
void six(){
nothing();
for(int i=2; i<=5; i++){
digitalWrite(i,HIGH);
}
digitalWrite(7,HIGH);
delay(refleshT);
}
void seven(){
nothing();
digitalWrite(2,HIGH);
compress();
delay(refleshT);
}
void eight(){
nothing();
for(int i=2; i<=5; i++){
digitalWrite(i,HIGH);
}
compress();
delay(refleshT);
}
void nine(){
nothing();
digitalWrite(2,HIGH);
digitalWrite(3,HIGH);
compress();
delay(refleshT);
}
void compress(){
digitalWrite(7,HIGH);
digitalWrite(8,HIGH);
digitalWrite(9,HIGH);
}
void nothing(){
reset();
for(int i=2; i<=9; i++){
digitalWrite(i,LOW);
}
delay(refleshT);
}
void reset(){
for (int e=10; e<13; ++e){
pinMode(e,INPUT);
}
}
void process(){
if(c=='8'){
pinMode(L,OUTPUT);
eight();
}
else if(c=='0'){
pinMode(L,OUTPUT);
zero();
}
else if(c=='1'){
pinMode(L,OUTPUT);
one();
}
else if(c=='2'){
pinMode(L,OUTPUT);
two();
}
else if(c=='3'){
pinMode(L,OUTPUT);
three();
}
else if(c=='4'){
pinMode(L,OUTPUT);
four();
}
else if(c=='5'){
pinMode(L,OUTPUT);
five();
}
else if(c=='6'){
pinMode(L,OUTPUT);
six();
}
else if(c=='7'){
pinMode(L,OUTPUT);
seven();
}
else if(c=='9'){
pinMode(L,OUTPUT);
nine();
}
else{
nothing();
return;
}
}
void BLOCK(){
for (int i=0; i<=2; i++){
REC[i]=Serial.read();
c = REC[i];
Cprocess();
newL[i]=i;
}
}
void EXchecker(){
if(Serial.available()>0){
int reader = Serial.read();
if(reader == -1){
}
else{
checkND = checkND +10;
}
}
}
void Cprocess(){
if(0<=c<=9){
checkND = checkND + 1;
}
else{
nothing();
return;
}
}
Prototype of a circuit for my work
2010年7月7日水曜日
Transistor switch
2010年7月5日月曜日
Arduino daisy-chain
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月2日金曜日
2010年7月1日木曜日
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 Video Editing