我們大致都討論出來,靈感是來自於其中的作品
把它運用到麵包版上,感覺又有另一種感覺
主要是運用4個按鈕,代表不同顏色
一種反應遊戲~
希望我們可以成功!
心得:
原本覺得這是一個無法成功的遊戲
沒想到我們一步一步地接近了
詢問學長跟不斷改善
我們的作品快完成了
很開心上這堂課有這機會,這真的是不一樣的體驗和感受
希望大家會喜歡玩我們的作品
大致半成品:
arduino程式碼:
int buttonPin5 = 5;
int buttonPin2 = 2;
int buttonPin3 = 3;
int buttonPin4 = 4;
int buttonState5 = 0;
int buttonState2 = 0;
int buttonState3 = 0;
int buttonState4 = 0;
void setup() {,tgy
pinMode(buttonPin5, INPUT);
pinMode(buttonPin2, INPUT);
pinMode(buttonPin3, INPUT);
pinMode(buttonPin4, INPUT);
Serial.begin(9600);
}
void loop() {
buttonState5 = digitalRead(buttonPin5);
buttonState2 = digitalRead(buttonPin2);
buttonState3 = digitalRead(buttonPin3);
buttonState4 = digitalRead(buttonPin4);
if (buttonState5 == HIGH) {
//tone(8, 131, 300);
Serial.write('A');
}
else if (buttonState5 == LOW) {
//Serial.write('Z');
}
if (buttonState2== HIGH) {
//tone(8, 147 , 300);
Serial.print('S');
}
else if (buttonState2 == LOW) {
//Serial.write('X');
}
if (buttonState3 == HIGH) {
//tone(8, 165 , 300);
Serial.print('D');
}
else if (buttonState3 == LOW) {
//Serial.write('C');
}
if (buttonState4 == HIGH) {
//tone(8, 175 , 300);
Serial.print('F');
}
else if (buttonState4 == LOW) {
//Serial.write('V');
}
if(buttonState2 == LOW&&buttonState3 == LOW&&buttonState4 == LOW&&buttonState5 == LOW){
Serial.write('H');
}
delay(500);
}
int buttonPin2 = 2;
int buttonPin3 = 3;
int buttonPin4 = 4;
int buttonState5 = 0;
int buttonState2 = 0;
int buttonState3 = 0;
int buttonState4 = 0;
void setup() {,tgy
pinMode(buttonPin5, INPUT);
pinMode(buttonPin2, INPUT);
pinMode(buttonPin3, INPUT);
pinMode(buttonPin4, INPUT);
Serial.begin(9600);
}
void loop() {
buttonState5 = digitalRead(buttonPin5);
buttonState2 = digitalRead(buttonPin2);
buttonState3 = digitalRead(buttonPin3);
buttonState4 = digitalRead(buttonPin4);
if (buttonState5 == HIGH) {
//tone(8, 131, 300);
Serial.write('A');
}
else if (buttonState5 == LOW) {
//Serial.write('Z');
}
if (buttonState2== HIGH) {
//tone(8, 147 , 300);
Serial.print('S');
}
else if (buttonState2 == LOW) {
//Serial.write('X');
}
if (buttonState3 == HIGH) {
//tone(8, 165 , 300);
Serial.print('D');
}
else if (buttonState3 == LOW) {
//Serial.write('C');
}
if (buttonState4 == HIGH) {
//tone(8, 175 , 300);
Serial.print('F');
}
else if (buttonState4 == LOW) {
//Serial.write('V');
}
if(buttonState2 == LOW&&buttonState3 == LOW&&buttonState4 == LOW&&buttonState5 == LOW){
Serial.write('H');
}
delay(500);
}
沒有留言:
張貼留言