搖桿控制音調
連接 COM6
void setup() {
pinMode(13,OUTPUT);
}
void loop() {
int now = analogRead(A0);
tone(8,now);
}
搖桿控制音調 + 燈光
void setup() {
// put your setup code here, to run once:
for(int i=2;i<=13;i++){
pinMode(i,OUTPUT);
}
}
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);
}
tone(8,now);
}
旋鈕控制顏色

沒有留言:
張貼留言