顯示具有 99160114朱席寬 標籤的文章。 顯示所有文章
顯示具有 99160114朱席寬 標籤的文章。 顯示所有文章

2013年1月20日 星期日

Week15,hw12

本週進度:
我們大致都討論出來,靈感是來自於其中的作品
把它運用到麵包版上,感覺又有另一種感覺
主要是運用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);
}

Week13,HW11

影片:


心得:
我們成功做出五個按鈕,個代表五個音階,簡直就是簡易型的小鋼琴,
一開始有些瓶頸,後來詢問修改後,成功的做出來了,
很有趣也很好玩,感覺又學到了一些東西!
曲子是小蜜蜂~

WEEK 19,Final




程式碼:
processing:


import processing.serial.*;
Serial myPort;

int i,d1=0,d2=0,d3=0,d4=0;
int score=0, lastTime=60;
int[] value = new int[50000];
color[] c=new color[4];
int a,count=0;
int tmp=0;
int startt;
int val;
void setup(){
  size(500,600);
  myPort = new Serial(this, "COM4", 9600);
 
  c[0]=color(255,0,0);
  c[1]=color(0,255,0);
  c[2]=color(0,0,255);
  c[3]=color(255,255,255);
  for(i=0;i<10000;i++)
  {
    a=int(random(0,3.99));
    /*
    if(i%25==0)
      fill(255,0,0);
      else  if(i%30==0)
          fill(0,255,0);
          else  if(i%40==0)
              fill(0,0,255);
              else
              fill(255,255,255);
    */
    count%=50000;
    value[count++]=a;
  }
}
void draw(){
  background(255,200,100);
  if(myPort.available()>0){
    val = myPort.read();//
第三個重點:如果讀到數字就拿出來用
    //println("123");
  }
textSize(30);
fill(100,0,50);
text("Time:"+lastTime, 50,80);
text("Score:"+score, 0,220);
 if(lastTime==0){
      stop();
      textFont(createFont("3", 60));
      background(100,100,100);
      fill(255,255,255);
      text("Game Over ",120,250);
      text("Your score:"+score,0,350);
 }
lastTime=30-millis()/1000;

    i=200;
    for(int k=startt;k<startt+20;k++){
    fill(c[value[k]]);
    rect(i,100,80,80);
    i+=20;
    }
 




  fill(255,200,100);
  rect(0,100,200,80);

  if(d1==1){
    fill(128,128,128);
  }else{
    fill(255,0,0);
  }
  rect(60,400,80,80);
 
  if(d2==1){
    fill(128,128,128);
  }else{
    fill(0,255,0);
  }
  rect(360,400,80,80);
  if(d3==1){
    fill(128,128,128);
  }else{
    fill(0,0,255);
  }
  rect(260,400,80,80);
  if(d4==1){
    fill(128,128,128);
  }else{
    fill(255,255,255);
  }
  rect(160,400,80,80);
 
  if(val=='A'){
    d1=1;
    if(value[startt]==0){
      startt++;
      score+=10;
    }
  }
  else if(val=='S'){
 
    d2=1;if(value[startt]==1){
      startt++;
      score+=10;
    }
  }
  else if(val=='D'){
    d3=1;if(value[startt]==2)
    {  startt++;
    score+=10;
    }
  }else if(val=='F'){
    d4=1;if(value[startt]==3)   
     { startt++;
     score+=10;
     }
  }
  else if(val=='H'){
   d1=0;
  d2=0;
 d3=0;
d4=0;
  }
}
void keyPressed(){
  if(key=='4'){
    d1=1;
    if(value[startt]==0){
      startt++;
      score+=10;
    }
  }else if(key=='5'){
 
    d2=1;if(value[startt]==1){
      startt++;
      score+=10;
    }
  }else if(key=='r'){
    d3=1;if(value[startt]==2)
    {  startt++;
    score+=10;
    }
  }else if(key=='t'){
    d4=1;if(value[startt]==3)   
     { startt++;
     score+=10;
     }
  }
}
void keyReleased(){
  if(key=='4'){
    d1=0;
  }else if(key=='5'){
    d2=0;
  }else if(key=='r'){
    d3=0;
  }else if(key=='t'){
    d4=0;
  }
}


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);
}


心得:
在眾多的課程當中我覺得這是最需要創意且最有難度的一堂課,要會打程式要會麵包板還需要很多靈感來完成作品,而這堂課除了要感謝老師也要感謝助教、學長還有同學的幫忙,讓我們這組能順利的打完程式碼。雖然這堂課困難重重,但我又比別人多會了一樣的東西。

組員分工:
程式碼:朱席寬
電路板:林品妤
找題材:朱席寬
期末上台報告:林品妤

2012年11月27日 星期二

WEEK12,HW10




int sensorPin = A0;    // select the input pin for the potentiometer
int ledPin = 13;      // select the pin for the LED
int sensorValue = 0;  // variable to store the value coming from the sensor
void setup() {
  // declare the ledPin as an OUTPUT:
  pinMode(13, OUTPUT);
  pinMode(11, OUTPUT);
  pinMode(9, OUTPUT); 
  pinMode(7, OUTPUT);
  pinMode(5, OUTPUT);
  pinMode(3, OUTPUT);
  pinMode(1, OUTPUT); 
}
void loop() {
  // read the value from the sensor:
  sensorValue = analogRead(sensorPin);   
  // turn the ledPin on
  digitalWrite(13, HIGH); 
   digitalWrite(11, LOW); 
    digitalWrite(9, LOW); 
     digitalWrite(7, LOW); 
      digitalWrite(5, LOW); 
       digitalWrite(3, LOW); 
        digitalWrite(1, LOW); 
  // stop the program for <sensorValue> milliseconds:
  delay(sensorValue);         
  // turn the ledPin off:       
  digitalWrite(13, LOW);  
   digitalWrite(11, HIGH); 
    digitalWrite(9, LOW); 
     digitalWrite(7, LOW); 
      digitalWrite(5, LOW); 
       digitalWrite(3, LOW); 
        digitalWrite(1, LOW); 
             
  // stop the program for for <sensorValue> milliseconds:
  delay(sensorValue);   
  digitalWrite(13, LOW);  
   digitalWrite(11, LOW); 
    digitalWrite(9, HIGH); 
     digitalWrite(7, LOW); 
      digitalWrite(5, LOW); 
       digitalWrite(3, LOW); 
        digitalWrite(1, LOW); 
             
  // stop the program for for <sensorValue> milliseconds:
  delay(sensorValue);  
  digitalWrite(13, LOW);  
   digitalWrite(11, LOW); 
    digitalWrite(9, LOW); 
     digitalWrite(7, HIGH); 
      digitalWrite(5, LOW); 
       digitalWrite(3, LOW); 
        digitalWrite(1, LOW); 
             
  // stop the program for for <sensorValue> milliseconds:
  delay(sensorValue);  
  digitalWrite(13, LOW);  
   digitalWrite(11, LOW); 
    digitalWrite(9, LOW); 
     digitalWrite(7, LOW); 
      digitalWrite(5, HIGH); 
       digitalWrite(3, LOW); 
        digitalWrite(1, LOW); 
             
  // stop the program for for <sensorValue> milliseconds:
  delay(sensorValue);  
  digitalWrite(13, LOW);  
   digitalWrite(11, LOW); 
    digitalWrite(9, LOW); 
     digitalWrite(7, LOW); 
      digitalWrite(5, LOW); 
       digitalWrite(3, HIGH); 
        digitalWrite(1, LOW); 
             
  // stop the program for for <sensorValue> milliseconds:
  delay(sensorValue);  
  digitalWrite(13, LOW);  
   digitalWrite(11, LOW); 
    digitalWrite(9, LOW); 
     digitalWrite(7, LOW); 
      digitalWrite(5, LOW); 
       digitalWrite(3, LOW); 
        digitalWrite(1, HIGH); 
             
  // stop the program for for <sensorValue> milliseconds:
  delay(sensorValue);    
   digitalWrite(13, LOW);  
   digitalWrite(11, LOW); 
    digitalWrite(9, LOW); 
     digitalWrite(7, LOW); 
      digitalWrite(5, LOW); 
       digitalWrite(3, HIGH); 
        digitalWrite(1, LOW); 
             
  // stop the program for for <sensorValue> milliseconds:
  delay(sensorValue);   
  digitalWrite(13, LOW);  
   digitalWrite(11, LOW); 
    digitalWrite(9, LOW); 
     digitalWrite(7, LOW); 
      digitalWrite(5, HIGH); 
       digitalWrite(3, LOW); 
        digitalWrite(1, LOW); 
             
  // stop the program for for <sensorValue> milliseconds:
  delay(sensorValue);  
  digitalWrite(13, LOW);  
   digitalWrite(11, LOW); 
    digitalWrite(9, LOW); 
     digitalWrite(7, HIGH); 
      digitalWrite(5, LOW); 
       digitalWrite(3, LOW); 
        digitalWrite(1, LOW); 
             
  // stop the program for for <sensorValue> milliseconds:
  delay(sensorValue);  
  digitalWrite(13, LOW);  
   digitalWrite(11, LOW); 
    digitalWrite(9, HIGH); 
     digitalWrite(7, LOW); 
      digitalWrite(5, LOW); 
       digitalWrite(3, LOW); 
        digitalWrite(1, LOW); 
             
  // stop the program for for <sensorValue> milliseconds:
  delay(sensorValue);  
  digitalWrite(13, LOW);  
   digitalWrite(11, HIGH); 
    digitalWrite(9, LOW); 
     digitalWrite(7, LOW); 
      digitalWrite(5, LOW); 
       digitalWrite(3, LOW); 
        digitalWrite(1, LOW); 
             
  // stop the program for for <sensorValue> milliseconds:
  delay(sensorValue);  
  digitalWrite(13, HIGH);  
   digitalWrite(11, LOW); 
    digitalWrite(9, LOW); 
     digitalWrite(7, LOW); 
      digitalWrite(5, LOW); 
       digitalWrite(3, LOW); 
        digitalWrite(1, LOW); 
             
  // stop the program for for <sensorValue> milliseconds:
  delay(sensorValue);    
}

2012年11月13日 星期二

Midtern


int i,d1=0,d2=0,d3=0,d4=0;
int score=0, lastTime=60;
int[] value = new int[50000];
color[] c=new color[4];
int a,count=0;
int tmp=0;
int startt;

void setup(){
  size(500,600);
  c[0]=color(255,0,0);
  c[1]=color(0,255,0);
  c[2]=color(0,0,255);
  c[3]=color(255,255,255);
  for(i=0;i<10000;i++)
  {
    a=int(random(0,3.99));
    /*
    if(i%25==0)
      fill(255,0,0);
      else  if(i%30==0)
          fill(0,255,0);
          else  if(i%40==0)
              fill(0,0,255);
              else
              fill(255,255,255);
    */
    count%=50000;
    value[count++]=a;
  }
}
void draw(){
  background(255,200,100);
textSize(30);
fill(100,0,50);
text("Time:"+lastTime, 50,80);
text("Score:"+score, 0,220);
 if(lastTime==0){
      stop();
      textFont(createFont("3", 60));
      background(100,100,100);
      fill(255,255,255);
      text("Game Over ",120,250);
      text("Your score:"+score,0,350);
 }
lastTime=30-millis()/1000;

    i=200;
    for(int k=startt;k<startt+20;k++){
    fill(c[value[k]]);
    rect(i,100,80,80);
    i+=20;
    }
 




  fill(255,200,100);
  rect(0,100,200,80);

  if(d1==1){
    fill(128,128,128);
  }else{
    fill(255,0,0);
  }
  rect(160,400,80,80);
  if(d2==1){
    fill(128,128,128);
  }else{
    fill(0,255,0);
  }
  rect(280,400,80,80);
  if(d3==1){
    fill(128,128,128);
  }else{
    fill(0,0,255);
  }
  rect(160,500,80,80);
  if(d4==1){
    fill(128,128,128);
  }else{
    fill(255,255,255);
  }
  rect(280,500,80,80);
}
void keyPressed(){
  if(key=='4'){
    d1=1;
    if(value[startt]==0){
      startt++;
      score+=10;
    }
  }else if(key=='5'){
 
    d2=1;if(value[startt]==1){
      startt++;
      score+=10;
    }
  }else if(key=='r'){
    d3=1;if(value[startt]==2)
    {  startt++;
    score+=10;
    }
  }else if(key=='t'){
    d4=1;if(value[startt]==3)
     { startt++;
     score+=10;
     }
  }
}
void keyReleased(){
  if(key=='4'){
    d1=0;
  }else if(key=='5'){
    d2=0;
  }else if(key=='r'){
    d3=0;
  }else if(key=='t'){
    d4=0;
  }
}

遊戲開始:





















60秒後遊戲結束:






















2012年10月23日 星期二

WEEK,HW07

視訊圖案

WEEK07,HW07

int d1=0,d2=0,d3=0,d4=0;
void setup(){
  size(500,800);
}
void draw(){
  if(d1==1){
    fill(128,128,128);
  }else{
    fill(255,0,0);
  }
  rect(160,400,80,80); 
  if(d2==1){
    fill(128,128,128);
  }else{
    fill(0,255,0);
  }
  rect(280,400,80,80); 
  if(d3==1){
    fill(128,128,128);
  }else{
    fill(0,0,255);
  }
  rect(160,500,80,80); 
  if(d4==1){
    fill(128,128,128);
  }else{
    fill(255,255,255);
  }
  rect(280,500,80,80); 
}
void keyPressed(){
  if(key=='4'){
    d1=1;
  }else if(key=='5'){
    d2=1;
  }else if(key=='1'){
    d3=1;
  }else if(key=='2'){
    d4=1;
  }   
}
void keyReleased(){
  if(key=='4'){
    d1=0;
  }else if(key=='5'){
    d2=0;
  }else if(key=='1'){
    d3=0;
  }else if(key=='2'){
    d4=0;
  }   
}



做出四個顏色方塊,按下對應數字"4"(紅),"5"(綠),"1"(藍),"2"(白)會變成灰色 。
















2012年10月16日 星期二

WEEK06,HW06

1.
我覺得詹中豪那組俄羅斯方塊很特別,利用腳踩踏的方式控制方塊的方向再利用手控制方塊左右移動感覺很動感。
2.
素材:顏色方塊*4,計時器,100個隨機顏色方塊以上我們打算直接用PROCESSING做出來,
背景音樂想選用比較刺激的配樂。
流程:剛進入遊戲畫面會有兩個選項 1.開始遊戲 2.背景音樂開關  按開始遊戲後就可以直接開始按相對應的方塊,上方有計時60秒的計時器,看大家在一分鐘能按對幾個顏色方塊

2012年10月9日 星期二

WEEK05,HW05

1.
void setup(){
  size(600,600);
}
float r=0.01;
void draw(){
  background (0,0,0);
  translate(300,300);
  ellipse(0,0,80,80);
  rotate(r);r+=0.02;
  for(int i=0;i<12;i++){
    rotate( PI/6);
      for(int x=225;x<255;x+=5){
        fill(random(x),random(x),0);
        ellipse(90,0,100,40);
      }
  }
}

























2.
void setup(){
  size(600,600);
}
float r=0.01;
void draw(){
  background (0,0,0);
  translate(mouseX,mouseY);
  ellipse(0,0,80,80);
  rotate(r);r+=0.02;
  for(int i=0;i<12;i++){
    rotate( PI/6);
      for(int x=225;x<255;x+=5){
        fill(random(x),random(x),0);
        ellipse(90,0,100,40);
      }
  }
}



3.

在時間內按下對應的顏色

2012年10月2日 星期二

Week04,HW04

void setup(){
  size(500,400);
  fill(255,0,0);
  rect(0,0,50,50);
  fill(0,255,0);
  rect(0,50,50,50);
  fill(255,255,0);
  rect(0,100,50,50);
  fill(255,255,255);
  rect(0,150,50,50);
  fill(0,0,0);
  rect(0,200,50,50);
  fill(255,255,255);
  rect(0,250,50,50);
  fill(255,255,255);
  rect(0,300,50,50);
  fill(255,255,255);
  rect(450,0,50,50);
  fill(255,255,255);
  rect(450,50,50,50);
}
int w=5;
void draw(){
  if(mousePressed && mouseX<50 && mouseY<50) stroke(255,0,0);
  else if(mousePressed && mouseX<50 && mouseY<100) stroke(0,255,0);
  else if(mousePressed && mouseX<50 && mouseY<150) stroke(255,255,0);
  else if(mousePressed && mouseX<50 && mouseY<200) stroke(255,255,255);
  else if(mousePressed && mouseX<50 && mouseY<250) stroke(0,0,0);
  else if(mousePressed && mouseX<50 && mouseY<300) save("bbb.png");
  else if(mousePressed && mouseX<50 && mouseY<350){
  PImage file=loadImage("bbb.png");
  image(file,0,0,500,400);
   }
  else if(mousePressed && mouseX>450 && mouseY<50){
    strokeWeight(++w);
  }
  else if(mousePressed && mouseX>450 && mouseY<1000){
    strokeWeight(--w);
    if(w<2)w=2;
  }
  else if(mousePressed)  line(mouseX, mouseY, pmouseX, pmouseY);
}


 

2012年9月25日 星期二

WEEK03,HW03


1.
void setup(){
size(600,600);
}

void draw(){

fill(255,255,100);
rect(100,100,100,100);

fill(255,100,255);
ellipse(mouseX,mouseY,100,100);

}
























2.

void setup(){
size(600,600);
frameRate(15);
}
int x=100,y=100;
void draw(){
background(0,0,0);

fill(255,255,100);
ellipse(mouseX,mouseY,100,100);

fill(255,100,255);
ellipse(x,y,20,20);

x=(x+mouseX)/2;
y=(y+mouseY)/2;
}
























3.
心得:
每個禮拜都有簡單的程式驚奇的功能,很有趣





2012年9月18日 星期二

WEEK01,HW01


1.                                      
processing  影片
     














2.

size(200,190);
PImage kitty;
kitty = loadImage("http://www.e-informacije.com/wp-content/uploads/2009/06/hello-kitty-3-150x150.jpg");
image(kitty,30,20);


3.
原圖
























size(400,600);
fill(255,200,0,100);
rect(130,100,150,100);
rect(165,200,80,120);
fill(0,0,0,255);
ellipse(155,210,20,20);
fill(0,0,0,255);
ellipse(255,210,20,20);
fill(255,200,0,100);
rect(145,220,20,80);
fill(255,200,0,100);
rect(245,220,20,80);
fill(255,200,0,100);
rect(165,320,80,20);
rect(165,340,35,50);
rect(210,340,35,50);

















完成圖:


WEEK02,HW02

1.
size(600,600);
for(int i=0;i<20;i++){
fill(random(255),random(255),random(255));
rect(random(500),random(500),random(500),random(500));
}


























2.
size(600,600);
for(int i=0;i<40;i++){
  for(int k=0;k<30;k++){
fill(i*255/50*random(200),k*random(255),100);
rect(i*10,k*10,10,10);
  }
}






















3.

size(400,300);
for(int i=0;i<4;i++){
  for(int k=0;k<3;k++){
fill(i*255/4,k*255/3,180);
ellipse(i*100+50,k*100+50,100,100);
fill(i*255/40,k*255/30,50);
ellipse(i*100+50,k*100+50,10,100);
fill(i*255/4,k*255/3,250);
ellipse(i*100+50,k*100+50,10,10);
  }
}





















課堂心得:
利用random隨機產生自己設定範圍內的方形
使用for迴圈讓小方格產生隨機或者漸進式的顏色變化
ellipse是圓形的指令