2010年11月30日火曜日

For Patrick, check this sample program for your purpose

//sample progrma with shiftresiostors and photosensors
// this program is very basic. you can use one photosensor and upto two shiftresistor so that you can control upto 16 LED with only 3 digital pins of Arduino

//connect photosensor to analog pin 0
int analogData0;


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

//regure variables
int RadomVal0;


void setup(){
//Start Serial for debuging purposes
Serial.begin(9600);
//set pins to output because they are addressed in the main loop
pinMode(latchPin, OUTPUT);
}

void loop(){
//read data from analog pin 0
analogData0=analogRead(0);
//scale down the value form 0-1023 to 0-255 which works with shift resistor.
analogData0=analogData0/4;
//put a randomize value into variable RadomVal0 this value take form "0" to "the scaled value" so that the new value still reflect the photosensor's value
// this code is optional
RadomVal0 = random(0,analogData0);
// tell shiftresistor to start
digitalWrite(latchPin, 0);
// actual data
shiftOut(dataPin, clockPin,MSBFIRST, RadomVal0);
//if you have second shift resistor. elase // and activate the program
//shiftOut(dataPin, clockPin,MSBFIRST, RadomVal0);
//tell shiftresistor to edn
digitalWrite(latchPin, 1);

// duration of the led light
delay(1000);
}

/*

the following program is optional.
if you want to use the following program replace "void loop" to the following program

void loop(){
//read data from analog pin 0
analogData0=analogRead(0);
//scale down the value form 0-1023 to 0-255 which works with shift resistor.
analogData0=analogData0/4;
// tell shiftresistor to start
//this will enable to light up LED more interestingly
for (int j = 0; j < analogData0; j++) {
digitalWrite(latchPin, 0);
// actual data
shiftOut(dataPin, clockPin,MSBFIRST, RadomVal0);
//if you have second shift resistor. elase // and activate the program
//shiftOut(dataPin, clockPin,MSBFIRST, RadomVal0);
//tell shiftresistor to edn
digitalWrite(latchPin, 1);

// duration of the led light for each led pattern
delay(300);
}
}

*/

2010年11月24日水曜日

high volate control

http://itp.nyu.edu/physcomp/Tutorials/HighCurrentLoads

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.