拔呀拔、插呀插、安捏插
joystick往上跟往下分別會發出不同聲音
或是用旋鈕左右旋轉也會有高低音
旋轉會亮燈!
亮得最少英文字母是A 亮最多是N
給泥程式碼辣!
———————————————————————————————————————
void setup() {
// put your setup code here, to run once:
for(int i=2;i<=13;i++){
pinMode(i,OUTPUT);
}
Serial.begin(9600);
}
void loop() {
// put your main code here, to run repeatedly:
int now = analogRead(A0);
int level = now/(512/13);
for(int i=2;i<=13;i++){
if(i<level) digitalWrite(i,HIGH);
else digitalWrite(i,LOW);
}
Serial.write('A'+level);
delay(100);
}
———————————————————————————————————————
亮ㄉ多 顏色填滿!
有兩個程式碼ㄜ﹗
Ardino
void setup() {
// put your setup code here, to run once:
for(int i=2;i<=13;i++){
pinMode(i,OUTPUT);
}
Serial.begin(9600);
}
void loop() {
// put your main code here, to run repeatedly:
int now = analogRead(A0);
int level = now/4;
for(int i=2;i<=13;i++){
if(i<level) digitalWrite(i,HIGH);
else digitalWrite(i,LOW);
}
Serial.write(level);
delay(20);
}
———————————————————————————————————————
Processingimport processing.serial.*;
Serial myPort;
void setup(){
size(700,100);
myPort = new Serial(this,"COM4",9600);
}
int level = 0;
void draw(){
background(255);
fill(0,50,200);
rect(0,0,level*3,100);
if(myPort.available()>0){
int now = myPort.read();
level = now;
}
}
———————————————————————————————————————



沒有留言:
張貼留言