顯示具有 arduino 標籤的文章。 顯示所有文章
顯示具有 arduino 標籤的文章。 顯示所有文章

2009年5月5日 星期二

Tiles prototype

Smart Architecture is characterized with their adaptability to users' needs. The interaction between users and their living environments are redefined so that buildings are autonomously responsive to human activities. Floor, as the very construct where human-building interactions take place most frequently, is chosen to initialize our attempts to make buildings "smart". We applied the concept of Cellular Automata to develop the prototype of "Smart Tile", which can be connected to each other to form an information network so that activities takes place at somewhere on the floor can be recognized and disseminated to wherever the information is needed. Most importantly, a smart floor records the dynamic configuration of interior spaces that are filled with movable objects and people.


2009年4月22日 星期三

Smart Car API for smart tiles



int switchPin = 2; // switch input
int motor1go = 3; // H-bridge leg 1 (pin 2, 1A)
int motor1back = 4; // H-bridge leg 2 (pin 7, 2A)
int motor2go = 5; // H-bridge leg 1 (pin 2, 1A)
int motor2back = 6; // H-bridge leg 2 (pin 7, 2A)
int enablePin = 9; // H-bridge enable pin
int ledPin = 13; // LED

void setup() {
// set the switch as an input:
pinMode(switchPin, INPUT);

// set all the other pins you're using as outputs:
pinMode(motor1go, OUTPUT);
pinMode(motor1back, OUTPUT);
pinMode(motor2go, OUTPUT);
pinMode(motor2back, OUTPUT);
pinMode(enablePin, OUTPUT);
pinMode(ledPin, OUTPUT);

// set enablePin high so that motor can turn on:
digitalWrite(enablePin, HIGH);

// blink the LED 3 times. This should happen only once.
// if you see the LED blink three times, it means that the module
// reset itself,. probably because the motor caused a brownout
// or a short.
blink(ledPin, 3, 100);
}

void loop() {
// if the switch is high, motor will turn on one direction:
if (digitalRead(switchPin) == HIGH) {
digitalWrite(motor1go, LOW); // set leg 1 of the H-bridge low
digitalWrite(motor1back, HIGH); // set leg 2 of the H-bridge high

digitalWrite(motor2go, HIGH); // set leg 1 of the H-bridge low
digitalWrite(motor2back, LOW); // set leg 2 of the H-bridge high

}
// if the switch is low, motor will turn in the other direction:
else {
digitalWrite(motor1go, HIGH); // set leg 1 of the H-bridge high
digitalWrite(motor1back, LOW ); // set leg 2 of the H-bridge low

digitalWrite(motor2go, LOW); // set leg 1 of the H-bridge low
digitalWrite(motor2back, HIGH); // set leg 2 of the H-bridge high
}
}

/*
blinks an LED
*/
void blink(int whatPin, int howManyTimes, int milliSecs) {
int i = 0;
for ( i = 0; i < howManyTimes; i++) {
digitalWrite(whatPin, HIGH);
delay(milliSecs/2);
digitalWrite(whatPin, LOW);
delay(milliSecs/2);
}
}

References
ITP Physical Computing
Tamiya 70068 Wall-Hugging Mouse Kit
http://letsmakerobots.com/node/2278
http://akashxav.com/2009/04/18/arduino-l293d-dc-motor/

2009年1月29日 星期四

Arduino IR Remote

RECEIVER:
int ir_pin = 7; //Sensor pin 1 wired through a 220 ohm resistor
int led_pin = 9; //"Ready to Recieve" flag, not needed but nice
int debug = 0; //Serial connection must be started to debug
int start_bit = 2000; //Start bit threshold (Microseconds)
int bin_1 = 1000; //Binary 1 threshold (Microseconds)
int bin_0 = 400; //Binary 0 threshold (Microseconds)
int lll=0;

void setup() {
pinMode(led_pin, OUTPUT); //This shows when we're ready to recieve
pinMode(ir_pin, INPUT);
digitalWrite(led_pin, LOW); //not ready yet
Serial.begin(9600);
}

void loop() {
int key = getIRKey(); //Fetch the key
Serial.print("Key Recieved: ");
Serial.println(key);
if(key==1301&&lll==0)
{digitalWrite(10, HIGH); lll=1;}
else if(key==1301&&lll==1)
{digitalWrite(10, LOW); lll=0;}
delay(1000);

}


int getIRKey() {
int data[12];
digitalWrite(led_pin, HIGH); //Ok, i'm ready to recieve
while(pulseIn(ir_pin, LOW) < 2200) { //Wait for a start bit
}
data[0] = pulseIn(ir_pin, LOW); //Start measuring bits, I only want low pulses
data[1] = pulseIn(ir_pin, LOW);
data[2] = pulseIn(ir_pin, LOW);
data[3] = pulseIn(ir_pin, LOW);
data[4] = pulseIn(ir_pin, LOW);
data[5] = pulseIn(ir_pin, LOW);
data[6] = pulseIn(ir_pin, LOW);
data[7] = pulseIn(ir_pin, LOW);
data[8] = pulseIn(ir_pin, LOW);
data[9] = pulseIn(ir_pin, LOW);
data[10] = pulseIn(ir_pin, LOW);
data[11] = pulseIn(ir_pin, LOW);
digitalWrite(led_pin, LOW);

if(debug == 1) {
Serial.println("-----");
}
for(int i=0;i<11;i++) { //Parse them
if (debug == 1) {
Serial.println(data[i]);
}
if(data[i] > bin_1) { //is it a 1?
data[i] = 1;
} else {
if(data[i] > bin_0) { //is it a 0?
data[i] = 0;
} else {
data[i] = 2; //Flag the data as invalid; I don't know what it is!
}
}
}

for(int i=0;i<11;i++) { //Pre-check data for errors
if(data[i] > 1) {
return -1; //Return -1 on invalid data
}
}

int result = 0;
int seed = 1;
for(int i=0;i<11;i++) { //Convert bits to integer
if(data[i] == 1) {
result += seed;
}
seed = seed * 2;
}
return result; //Return key number
}

SENDER:
http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1209565937

2009年1月26日 星期一

Arduino bootloader 教學

只需要自備Arduino Diecimila基本板子
就可以大量購買所需的ATmega168 晶片,自己燒錄bootloader
製造arduino
感謝 Mr.Suz. 開發的avrdude-serjtag工具。

【前po】自製240元的arduino(不含usb connector)

參考網址:
http://robertcarlsen.net/blog/?p=221
http://www.geocities.jp/arduino_diecimila/bootloader/index_en.html