總共有三種速度(三排),有A~Z共26個英文字母隨機編排,只要按到相對應的字母就可消除,消除一個得10分,若未及時消除則game over並結算分數。
影片網址:https://www.youtube.com/watch?v=VQcOnpL-kI4&feature=youtu.be
2015年1月25日 星期日
2015年1月24日 星期六
2015年1月22日 星期四
期末作品 -遙控車
期末作品: 遙控車
透過手機藍芽傳訊號給藍芽模組後,讓模型車體可以依手機打的指令分別: 前進,後退,轉彎。
操作說明:
在手機輸入指令:
f,100 前進 ,速度:100
f,100 前進 ,速度:100
b,200 後退,速度:200
a,20 轉20度
過程:
通電後,藍芽模組開始亮紅燈。(測試線路)
過程:
將HC-06 藍芽模組的 : VCC 分別用電線接到 -----> Arduino Uno版子: 5 V
將HC-06 藍芽模組的 : GND 分別用電線接到 -----> Arduino Uno版子: GND
將HC-06 藍芽模組的 : TXD 分別用電線接到 -----> Arduino Uno版子: Pin 10(RX)
將HC-06 藍芽模組的 : RXD 分別用電線接到 -----> Arduino Uno版子: Pin 11(TX)
接完藍芽模組的線路後,接著拔掉藍芽模組,並將L293D模組疊在上方,接著伺服馬達也接在在上面,並將USB線插入Arduino的插孔與電腦上。
執行編譯Arduino 程式後
將藍芽模組接在剛剛已經設好的線路上。
連通後藍芽模組開始閃紅燈。
開啟手機的藍芽,並與藍芽模組 配對。
點入App中
搜尋藍芽,並配對藍芽。
" a,50" 讓伺服馬達轉50度。
測試減速馬達是否正常運轉,測試結果為正常。
但與 L293D模組接好後,卻無法運轉,初步判斷可能是線路差反,確定線路的正負沒錯後,
詢問過他人的想法後,在猜想有可能是馬達的電壓 9 V 與 Arduino 版的供電數 有關。
參考資料:
| Arduino 從基礎到實踐 / Michael McRoberts著 ; 杨继志, 郭敬译 |
車子模型
2015年1月19日 星期一
HW19, Week19, 期末作品
期末作品-Row, row, row your boat
(version 2-2)
[Version 2-2]遊戲規則與解說:
●操控:
◎向右=>滑左槳
◎向左=>滑右槳
●開始畫面:
◎player玩家
◎help幫助=>score+100
◎avoid避開=>score-100
◎Row to right=>Practice
向右可以進入練習模式
◎Row to left=>Start
向左可以直接遊戲
●練習模式:
◎Row to right=>good!
◎Row to left=>good!
●遊戲畫面:
◎失敗
分數為0即失敗
失敗後
Row to right=>Start
◎勝利
救到3隻水獺即可勝利
救到1隻水獺以圖式告知還需救幾隻(右下方)
勝利後
Row to right=>Start
◎遊戲中有音樂
◎碰到avoid與help均有音效
◎失敗與勝利之後
Row to right=>Start
向右均可再次遊戲
已改進:
●有練習模式,讓玩家可以先熟知玩法
●開始畫面:
向右可以進入練習模式
向左可以直接遊戲
作品第二版本影片:
Practice 模式
硬體photo:

●所有材料:
粗吸管(船桿)
海綿(船槳)
紙箱(海平面30*30*3、船高20)
鐵絲
上色用具
(version 2-2)
[Version 2-2]遊戲規則與解說:
●操控:
◎向右=>滑左槳
◎向左=>滑右槳
●開始畫面:
◎player玩家
◎help幫助=>score+100
◎avoid避開=>score-100
◎Row to right=>Practice
向右可以進入練習模式
◎Row to left=>Start
向左可以直接遊戲
●練習模式:
◎Row to right=>good!
◎Row to left=>good!
●遊戲畫面:
◎失敗
分數為0即失敗
失敗後
Row to right=>Start
◎勝利
救到3隻水獺即可勝利
救到1隻水獺以圖式告知還需救幾隻(右下方)
勝利後
Row to right=>Start
◎遊戲中有音樂
◎碰到avoid與help均有音效
◎失敗與勝利之後
Row to right=>Start
向右均可再次遊戲
已改進:
●有練習模式,讓玩家可以先熟知玩法
●開始畫面:
向右可以進入練習模式
向左可以直接遊戲
作品第二版本影片:
Practice 模式
互動概論期末作品-Row, row, row your boat (version 2-2) Demo Practice 模式
失敗畫面
互動概論期末作品-Row, row, row your boat (version 2-2) Demo 失敗畫面
勝利畫面
互動概論期末作品-Row, row, row your boat (version 2-2) Demo 勝利畫面
硬體介紹
互動概論期末作品-Row, row, row your boat (version 2-2) 硬體介紹
上課 Demo 側錄
互動概論期末作品-Row, row, row your boat (version 2-2) 上課 Demo 側錄
作品第一版本影片:
2015.0118互動概論期末作品-Row, row, row your boat (version 2-1)
硬體photo:
●船槳上的鐵絲與海平面上的鐵絲觸碰,
Arduino 即可傳送訊息給 Processing

●船槳上的鐵絲部分
藏在船槳的海綿裡與吸管裡
●船內有 Board 的固定位置
Board 才不會滑動
粗吸管(船桿)
海綿(船槳)
紙箱(海平面30*30*3、船高20)
鐵絲
上色用具
期末作品-快打旋風
遊戲名字:快打旋風
此遊戲為一個簡單的打擊遊戲,玩家可以使用箱子上的紅色按鈕,遊戲中會出現不同種臉部表情的頭,點擊不同的表情會有不同的分數,相反的點到有骨頭的圖示就會結束遊戲(影片中有介紹各個圖片對應到的分數),主要是考驗玩家的手速和反應力。
Week 19
期末作品:快打旋風
一個功德箱的造型,製造"笑"果
這是我們箱子裡面的配線
這是利用判斷按鈕是否有回饋的藍色LED
我們額外去購買的大按鈕,外面再黏上一個珍珠板,讓它接受面積更大更好打擊。
遊戲畫面:
遊戲規則:
有五種不同的圖示,有些得一分有些得十分。
得20分
得10分
得一分
得一分
遊戲結束
遊戲結束
遊戲結束畫面和顯示得分
2015年1月18日 星期日
Week19
-------------------------------↓↓太鼓達人↓↓-------------------------------
(外觀)
(內部接線)
-------------------------------↓↓Demo影片↓↓-------------------------------
Final_影片及程式碼
影片:
Serial.begin(9600);
pinMode(2,INPUT_PULLUP);
pinMode(3,INPUT_PULLUP);
pinMode(4,INPUT_PULLUP);
pinMode(5,INPUT_PULLUP);
pinMode(13,OUTPUT);
}
int now2=0,now=0,now3=0,now4=0;
void loop(){
int pressButtonLeft = digitalRead(2);
int pressButtonRight = digitalRead(3);
int restart = digitalRead(5);
int shoot = digitalRead(4);
if(now==1 && pressButtonLeft==HIGH){//left
digitalWrite(13,LOW);
Serial.write('A');
now=0;
}
else if(now==0 && pressButtonLeft == LOW){
digitalWrite(13, HIGH);
Serial.write('a');
now=1;
}
delay(10);
if(now2==1 && pressButtonRight ==HIGH){//right
digitalWrite(13,LOW);
Serial.write('B');
now2=0;
}
if(now2==0 && pressButtonRight == LOW){
digitalWrite(13, HIGH);
Serial.write('b');
now2=1;
}
delay(10);
if(now3==1 && shoot ==HIGH){//shot
digitalWrite(13,LOW);
Serial.write('C');
now3=0;
}
if(now3==0 && shoot == LOW){
digitalWrite(13, HIGH);
Serial.write('c');
now3=1;
}
delay(10);
if(now4==1 && restart ==HIGH){//shot
digitalWrite(13,LOW);
Serial.write('D');
now4=0;
}
if(now4==0 && restart == LOW){
digitalWrite(13, HIGH);
Serial.write('d');
now4=1;
}
delay(10);
}
import processing.serial.*;
import ddf.minim.*;
AudioPlayer player1, player2, player3;
Minim minim;//audio context
Serial myPort;
PImage plane[]=new PImage[3], imgBG, canon, bullet;
int pX[]= {
0, 0, 0
}
, pY[]= {
0, 0, 0
}
, cX[]= {
375
}
, cY[]= {
500
}
, bX[]= {
387
}
, bY[]= {
520
};
float pVX[]= {
1, 1, 1
}
, pVY[]= {
1, 1, 1
}
, bVY=2, bLife[]= {
0
}
, pbX[]= {
0, 0, 0
}
, pbY[]= {
0, 0, 0
}
, pbv=1;
int shoot=0, gameover=-10, score=0;
void setup() {
size(800, 600);
myPort = new Serial(this, "COM3", 9600);
imgBG=loadImage("sky.png");
canon=loadImage("canon.png");
bullet=loadImage("bullet.png");
for (int i=0; i<3; i++) plane[i]=loadImage("plane"+int(random(3))+".png");
for (int i=0; i<3; i++) {//plane and planeBullet begin
pX[i]=int(random(30))*25;
pbX[i]=pX[i]+30;
pY[i]=int(random(7))*25+25;
pbY[i]=pY[i]+31;
}
minim = new Minim(this);
player1 = minim.loadFile("BGM.mp3", 2048);
player2 = minim.loadFile("bomb.mp3", 2048);
player3 = minim.loadFile("shoot.mp3", 2048);
player1.play();
}
void draw() {
background(255);
if (myPort.available()>0) {
int a=myPort.read();
if (a=='b') {
cX[0]+=50;
bX[0]+=50;
}
if (a=='a') {
cX[0]-=50;
bX[0]-=50;
}
if (a=='c')shoot++;
if (a=='d') {
gameover=-1;
score=0;
}
}
if (gameover>0) {//Gameover
fill(255, 0, 0);
rect(0, 0, 800, 600);
textSize(100);
fill(0);
text("GameOver!", 125, 200);
textSize(80);
text("Score = "+score, 125, 300 );
textSize(40);
text("click backspace to replay", 125, 400 );
} else {
image(imgBG, 0, 50);
image(bullet, bX[0], bY[0], 40, 40);
image(canon, cX[0], cY[0], 80, 100);
fill(0);
textSize(18);
text("use <- and -> to control canon location, click Ctrl to shoot.", 5, 20);
for (int i=0; i<3; i++) {//hit
if (abs(pX[i]-bX[0])<100 &&abs(pY[i]-bY[0])<15) {
score+=1;
pY[i]=-100;
pbY[i]=-100;
player2 = minim.loadFile("bomb.mp3", 2048);
player2.play();
}
}
text("Score = "+score, 5, 40);
for (int i=0; i<3; i++) {//canon hit
if (abs(pbX[i]-cX[0])<=20 &&pbY[i]>500 ) gameover++;
}
for (int i=0; i<3; i++) {//draw plane and planeBullet
fill(0);
ellipse(pbX[i], pbY[i], 10, 10);
image(plane[i], pX[i], pY[i], 100, 60);
}
for (int i=0; i<3; i++) {//plane speed and pBspeed
if (pX[i]>700) {
pX[i]=0;
pbX[i]=30;
plane[i]=loadImage("plane"+int(random(3))+".png");
pY[i]=int(random(7))*25+25;
pVX[i]=1;
} else if (pbY[i]>600) {
pbY[i]=pY[i]+31;
pbv=1;
} else {
pX[i]+=pVX[i];
pbX[i]+=pVX[i]-0.02;
pVX[i]+=0.05;
pbY[i]+=pbv;
pbv+=0.05;
}
}
if (shoot>0) {
//image(bullet,bX[0],bY[0],40,40);
for (int j=0; j<1; j++) {//canonBullet speed
if (bY[j]<30) {
bX[j]=cX[0]+20;
bY[j]=500;
bVY=2;
shoot=0;
} else {
bY[j]-=bVY;
bVY+=0.5;
}
}
}
}
}
void keyPressed() {
if (keyCode==RIGHT && cX[0]<725 && bY[0]<500) cX[0]+=50;
else if (keyCode==RIGHT && cX[0]<725 ) {
cX[0]+=50;
bX[0]+=50;
}
if (keyCode==LEFT && cX[0]>0&& bY[0]<500) cX[0]-=50;
else if (keyCode==LEFT && cX[0]>0) {
cX[0]-=50;
bX[0]-=50;
}
if (keyCode==CONTROL) {
shoot++;
player3 = minim.loadFile("shoot.mp3", 2048);
player3.play();
}
if (keyCode==32) {
gameover=0;
score=0;
for (int i=0; i<3; i++) {
pbY[i]=0;
pbX[i]=0;
pX[i]=0;
pY[i]=0;
}
}
}
*******************程式碼*******************
ARDUINO:
void setup(){Serial.begin(9600);
pinMode(2,INPUT_PULLUP);
pinMode(3,INPUT_PULLUP);
pinMode(4,INPUT_PULLUP);
pinMode(5,INPUT_PULLUP);
pinMode(13,OUTPUT);
}
int now2=0,now=0,now3=0,now4=0;
void loop(){
int pressButtonLeft = digitalRead(2);
int pressButtonRight = digitalRead(3);
int restart = digitalRead(5);
int shoot = digitalRead(4);
if(now==1 && pressButtonLeft==HIGH){//left
digitalWrite(13,LOW);
Serial.write('A');
now=0;
}
else if(now==0 && pressButtonLeft == LOW){
digitalWrite(13, HIGH);
Serial.write('a');
now=1;
}
delay(10);
if(now2==1 && pressButtonRight ==HIGH){//right
digitalWrite(13,LOW);
Serial.write('B');
now2=0;
}
if(now2==0 && pressButtonRight == LOW){
digitalWrite(13, HIGH);
Serial.write('b');
now2=1;
}
delay(10);
if(now3==1 && shoot ==HIGH){//shot
digitalWrite(13,LOW);
Serial.write('C');
now3=0;
}
if(now3==0 && shoot == LOW){
digitalWrite(13, HIGH);
Serial.write('c');
now3=1;
}
delay(10);
if(now4==1 && restart ==HIGH){//shot
digitalWrite(13,LOW);
Serial.write('D');
now4=0;
}
if(now4==0 && restart == LOW){
digitalWrite(13, HIGH);
Serial.write('d');
now4=1;
}
delay(10);
}
PROCESSING:
import processing.serial.*;
import ddf.minim.*;
AudioPlayer player1, player2, player3;
Minim minim;//audio context
Serial myPort;
PImage plane[]=new PImage[3], imgBG, canon, bullet;
int pX[]= {
0, 0, 0
}
, pY[]= {
0, 0, 0
}
, cX[]= {
375
}
, cY[]= {
500
}
, bX[]= {
387
}
, bY[]= {
520
};
float pVX[]= {
1, 1, 1
}
, pVY[]= {
1, 1, 1
}
, bVY=2, bLife[]= {
0
}
, pbX[]= {
0, 0, 0
}
, pbY[]= {
0, 0, 0
}
, pbv=1;
int shoot=0, gameover=-10, score=0;
void setup() {
size(800, 600);
myPort = new Serial(this, "COM3", 9600);
imgBG=loadImage("sky.png");
canon=loadImage("canon.png");
bullet=loadImage("bullet.png");
for (int i=0; i<3; i++) plane[i]=loadImage("plane"+int(random(3))+".png");
for (int i=0; i<3; i++) {//plane and planeBullet begin
pX[i]=int(random(30))*25;
pbX[i]=pX[i]+30;
pY[i]=int(random(7))*25+25;
pbY[i]=pY[i]+31;
}
minim = new Minim(this);
player1 = minim.loadFile("BGM.mp3", 2048);
player2 = minim.loadFile("bomb.mp3", 2048);
player3 = minim.loadFile("shoot.mp3", 2048);
player1.play();
}
void draw() {
background(255);
if (myPort.available()>0) {
int a=myPort.read();
if (a=='b') {
cX[0]+=50;
bX[0]+=50;
}
if (a=='a') {
cX[0]-=50;
bX[0]-=50;
}
if (a=='c')shoot++;
if (a=='d') {
gameover=-1;
score=0;
}
}
if (gameover>0) {//Gameover
fill(255, 0, 0);
rect(0, 0, 800, 600);
textSize(100);
fill(0);
text("GameOver!", 125, 200);
textSize(80);
text("Score = "+score, 125, 300 );
textSize(40);
text("click backspace to replay", 125, 400 );
} else {
image(imgBG, 0, 50);
image(bullet, bX[0], bY[0], 40, 40);
image(canon, cX[0], cY[0], 80, 100);
fill(0);
textSize(18);
text("use <- and -> to control canon location, click Ctrl to shoot.", 5, 20);
for (int i=0; i<3; i++) {//hit
if (abs(pX[i]-bX[0])<100 &&abs(pY[i]-bY[0])<15) {
score+=1;
pY[i]=-100;
pbY[i]=-100;
player2 = minim.loadFile("bomb.mp3", 2048);
player2.play();
}
}
text("Score = "+score, 5, 40);
for (int i=0; i<3; i++) {//canon hit
if (abs(pbX[i]-cX[0])<=20 &&pbY[i]>500 ) gameover++;
}
for (int i=0; i<3; i++) {//draw plane and planeBullet
fill(0);
ellipse(pbX[i], pbY[i], 10, 10);
image(plane[i], pX[i], pY[i], 100, 60);
}
for (int i=0; i<3; i++) {//plane speed and pBspeed
if (pX[i]>700) {
pX[i]=0;
pbX[i]=30;
plane[i]=loadImage("plane"+int(random(3))+".png");
pY[i]=int(random(7))*25+25;
pVX[i]=1;
} else if (pbY[i]>600) {
pbY[i]=pY[i]+31;
pbv=1;
} else {
pX[i]+=pVX[i];
pbX[i]+=pVX[i]-0.02;
pVX[i]+=0.05;
pbY[i]+=pbv;
pbv+=0.05;
}
}
if (shoot>0) {
//image(bullet,bX[0],bY[0],40,40);
for (int j=0; j<1; j++) {//canonBullet speed
if (bY[j]<30) {
bX[j]=cX[0]+20;
bY[j]=500;
bVY=2;
shoot=0;
} else {
bY[j]-=bVY;
bVY+=0.5;
}
}
}
}
}
void keyPressed() {
if (keyCode==RIGHT && cX[0]<725 && bY[0]<500) cX[0]+=50;
else if (keyCode==RIGHT && cX[0]<725 ) {
cX[0]+=50;
bX[0]+=50;
}
if (keyCode==LEFT && cX[0]>0&& bY[0]<500) cX[0]-=50;
else if (keyCode==LEFT && cX[0]>0) {
cX[0]-=50;
bX[0]-=50;
}
if (keyCode==CONTROL) {
shoot++;
player3 = minim.loadFile("shoot.mp3", 2048);
player3.play();
}
if (keyCode==32) {
gameover=0;
score=0;
for (int i=0; i<3; i++) {
pbY[i]=0;
pbX[i]=0;
pX[i]=0;
pY[i]=0;
}
}
}
Final(打殭屍加強版)-接蘋果遊戲
倒數 開始
左上角倒數計時30秒
紅蘋果,一顆1分
得30分後 有綠蘋果,一顆2分
畫面中由左到右籃子 分別對應8個按鍵
畫面中由左到右籃子 分別對應8個按鍵
遊戲結束後 算總分
import ddf.minim.*;
Minim m;
AudioPlayer player;
int []bz=new int[1000];
PImage imgZombie;
PImage imgRZombie;
PImage imgShoot;
PImage imgBG;
import processing.serial.*;
Serial myPort; // Create object from Serial class
int val;
void setup() {
size(800, 600);
imgZombie=loadImage("apple01.png");
imgRZombie=loadImage("apple02.png");
imgShoot=loadImage("shoot.png");
imgBG=loadImage("sky.png");
for (int i=0;i<1000;i++) {
bz[i]=int(random(8));
}
m = new Minim(this);
player = m.loadFile("apple.mp3");
//player.play();
String [] all = Serial.list();
String portName = all[all.length-1];
player.play();
myPort = new Serial(this, portName, 9600);
}
int now=0;
int a;
int total=0;
int countDown=300;
int countDown2=1860;//1860
void draw() {
background(imgBG);
print("val=" + val);
if ( myPort.available() > 0) { // If data is available,
val = myPort.read(); // read it and store it in val
}
int a=0;
if (a==0) {
if (countDown>0) {
countDown--;
textSize(100);
text(countDown/30+"Seconds", 200, 300);
return;
}
a++;
}
if (a==1) {
if (countDown2>0) {
countDown2--;
textSize(50);
text(countDown2/60+"Second", 20, 40);
for (int i=now;i<now+5;i++) {
if (now<=30)image(imgZombie, bz[i]*100, 400-(i-now)*100);
if (now>30)image(imgRZombie, bz[i]*100, 400-(i-now)*100);
}
image(imgShoot, 0, 500);
image(imgShoot, 100, 500);
image(imgShoot, 200, 500);
image(imgShoot, 300, 500);
image(imgShoot, 400, 500);
image(imgShoot, 500, 500);
image(imgShoot, 600, 500);
image(imgShoot, 700, 500);
}
a++;
}
if (a==2) {
if (countDown2/60==0)text("Score:"+total, 300, 350);
}
if (val-48==bz[now])
{
if (total<50)a=1;
if (total==50)a=2;
if (countDown2/60==0)a=0;
now++;
total=total+a;
}
}
/*void keyPressed(int val) {
//if (val==bz[now])
//{
// if (total<50)a=1;
// if (total==50)a=2;
// if (countDown2/60==0)a=0;
// now++;
// total=total+a;
// }
}*/
Minim m;
AudioPlayer player;
int []bz=new int[1000];
PImage imgZombie;
PImage imgRZombie;
PImage imgShoot;
PImage imgBG;
import processing.serial.*;
Serial myPort; // Create object from Serial class
int val;
void setup() {
size(800, 600);
imgZombie=loadImage("apple01.png");
imgRZombie=loadImage("apple02.png");
imgShoot=loadImage("shoot.png");
imgBG=loadImage("sky.png");
for (int i=0;i<1000;i++) {
bz[i]=int(random(8));
}
m = new Minim(this);
player = m.loadFile("apple.mp3");
//player.play();
String [] all = Serial.list();
String portName = all[all.length-1];
player.play();
myPort = new Serial(this, portName, 9600);
}
int now=0;
int a;
int total=0;
int countDown=300;
int countDown2=1860;//1860
void draw() {
background(imgBG);
print("val=" + val);
if ( myPort.available() > 0) { // If data is available,
val = myPort.read(); // read it and store it in val
}
int a=0;
if (a==0) {
if (countDown>0) {
countDown--;
textSize(100);
text(countDown/30+"Seconds", 200, 300);
return;
}
a++;
}
if (a==1) {
if (countDown2>0) {
countDown2--;
textSize(50);
text(countDown2/60+"Second", 20, 40);
for (int i=now;i<now+5;i++) {
if (now<=30)image(imgZombie, bz[i]*100, 400-(i-now)*100);
if (now>30)image(imgRZombie, bz[i]*100, 400-(i-now)*100);
}
image(imgShoot, 0, 500);
image(imgShoot, 100, 500);
image(imgShoot, 200, 500);
image(imgShoot, 300, 500);
image(imgShoot, 400, 500);
image(imgShoot, 500, 500);
image(imgShoot, 600, 500);
image(imgShoot, 700, 500);
}
a++;
}
if (a==2) {
if (countDown2/60==0)text("Score:"+total, 300, 350);
}
if (val-48==bz[now])
{
if (total<50)a=1;
if (total==50)a=2;
if (countDown2/60==0)a=0;
now++;
total=total+a;
}
}
/*void keyPressed(int val) {
//if (val==bz[now])
//{
// if (total<50)a=1;
// if (total==50)a=2;
// if (countDown2/60==0)a=0;
// now++;
// total=total+a;
// }
}*/
訂閱:
文章 (Atom)











































