Wiring
void setup() {
Serial.begin(38400);
}
void loop() {
if (Serial.real() == 65) {
Serial.print((analogRead(0)/4));
Serial.print((analogRead(1)/4));
Serial.print((analogRead(2)/4));
Processing
import processing.serial.*;
Serial port;
float xpos;
void setup() {
size(256,256);
noStroke();
println(Serial.list());
port = new Serial(this, Serial.list()[2], 38400);
// port.clear();
}
void draw(){
background(0);
while (port.available() > 0) {
xpos = port.read();
}
rect(xpos,100,20,20);
}
int ax = 0; //set the pin number
int ay = 1;
int az = 2;
int x = 0; //the value of acceleration on x-axis
int y = 0;
int z = 0;
void setup() {
Serial.begin(38400);
}
void loop() {
x = analogRead(ax); //read the value of analog pin 0
y = analogRead(ay);
z = analogRead(az);
Serial.print(x/4);
Serial.print(y/4);
Serial.print(z/4); //write the scaled value to the serial port
}
된장... shielding... orz
'Hardware' 카테고리의 다른 글
[Noah Shibley] eagle PCB (0) | 2008.04.01 |
---|---|
smd toast oven (0) | 2008.03.24 |
soldering (0) | 2006.12.14 |
testing serial (0) | 2006.12.10 |
hardware term (0) | 2006.02.21 |