顯示具有 00160174江依紋 標籤的文章。 顯示所有文章
顯示具有 00160174江依紋 標籤的文章。 顯示所有文章

2014年1月12日 星期日

Week19_Final_彈珠台

##Demo影片



##製作到完成照片

一開始的拆箱、定尺寸、畫位置
























測試電路、設計開關(感應區)















電路和版面組合


展開的樣子
組裝好後的外觀






































玩的照片~
全亮燈的樣子
























## Arduino程式碼

import processing.serial.*;
PFont font;
Serial serial;
int pon=0;
void setup()
{
  size(600, 400);
  background(0,0,0);
  serial=new Serial(this, "COM3", 9600);
}

void draw()
{
  background(0,0,0);
   if (serial.available()>0)
  {
    int a=serial.read();
    print(a+" ");
         if(a==97)     {    pon+=0;    }//a
    else if(a==98)     {    pon+=20;   }//b
    else if(a==99)     {    pon+=0;    }//c
    else if(a==100)    {    pon+=25;   }//d
    else if(a==101)    {    pon+=0;    }//e
    else if(a==102)    {    pon+=50;   }//f
    else if(a==103)    {    pon+=0;    }//g
    else if(a==104)    {    pon+=20;   }//h
    //else if(a==105)    {    pon+=0;    }//i
    //else if(a==106)    {    pon+=10;   }//j
        
    textFont(createFont("calibri",40));
    textSize(100);
    text("Score:"+pon,50,210);
  
  }
}

## Processing 程式碼

import processing.serial.*;
PFont font;
Serial serial;
int pon=0;
void setup()
{
  size(600, 400);
  background(0,0,0);
  serial=new Serial(this, "COM3", 9600);
}

void draw()
{
  background(0,0,0);
   if (serial.available()>0)
  {
    int a=serial.read();
    print(a+" ");
         if(a==97)     {    pon+=0;    }//a
    else if(a==98)     {    pon+=20;   }//b
    else if(a==99)     {    pon+=0;    }//c
    else if(a==100)    {    pon+=25;   }//d
    else if(a==101)    {    pon+=0;    }//e
    else if(a==102)    {    pon+=50;   }//f
    else if(a==103)    {    pon+=0;    }//g
    else if(a==104)    {    pon+=20;   }//h
    //else if(a==105)    {    pon+=0;    }//i
    //else if(a==106)    {    pon+=10;   }//j
        
    textFont(createFont("calibri",40));
    textSize(100);
    text("Score:"+pon,50,210);
  
  }
}


2013年12月16日 星期一

week15

##Final mad

##程式碼
//int led13=0,led12=0,led11=0;
int msg=0;
int mmssg=2;

void setup()
{          
  Serial.begin(9600);
  pinMode(13, INPUT);
  pinMode(8, OUTPUT);
  //  pinMode(12, OUTPUT);
  //  pinMode(11, OUTPUT);
}

void loop() {

  //   digitalWrite(13, HIGH);

  msg=digitalRead(13);

  if(msg==LOW)
  {
    digitalWrite(8, HIGH);
    mmssg=11;
  }
  else {
    digitalWrite(8, LOW);
    mmssg=00;
 
  }
  Serial.print("  led8:");  
  Serial.print(mmssg+"  \n");



}

2013年12月8日 星期日

期末企劃

##期末企劃
*題目:自製彈珠台

*發想&類目標
(2)


















                                                    (4)
(3)

*我們想做的有分兩個部分,實體是實際操作遊戲的部分,計分則回傳到電腦畫面顯示。

  電腦畫面部分:計分板

  實體部分:
  圖一那種傳統彈珠台的樣式,但是底板在計分區會做像圖三那樣有上下兩層
  計分區的電路設計:在底層貼一條電線然後洞口那層也有一條,當彈珠掉進洞時會將上面的   電線下壓碰到底層的電線就會通電即可得分。

  嘗試...做像圖二及圖四會有一些圖釘、橡皮筋等增加趣味性,還有做碰撞加分的設置(考慮使用   蜂鳴器實做)


Week14

##Project 8 : Digital Hourglass



##程式碼
const int switchPin =8;
unsigned long previousTime =0;
int switchState =0;
int prevSwitchState=0;
int led =2;
long interval=600;
void setup(){
  for(int x=2;x<8;x++){
    pinMode(x,OUTPUT);
  }
  pinMode(switchPin,INPUT);
}
void loop(){
  unsigned long currentTime = millis();
  if(currentTime-previousTime>interval){
    previousTime=currentTime;
    digitalWrite(led,HIGH);
    led++;
    if(led==7){
    }
}
switchState=digitalRead(switchPin);
if(switchState !=prevSwitchState){
  for(int x=2;x<8;x++){
    digitalWrite(x,LOW);
  }
  led=2;
  previousTime=currentTime;
}
  prevSwitchState=switchState;
}


2013年12月2日 星期一

week13

##Project 6 : Light Theremin



##程式碼
int sensorValue; int sensorLow=1023; int sensorHigh=0; const int ledPin=13; void setup(){ pinMode(ledPin,OUTPUT); digitalWrite(ledPin,HIGH); while(millis()<5000){ sensorValue=analogRead(A0); if(sensorValue>sensorHigh){ sensorHigh=sensorValue; } if(sensorValue<sensorLow){ sensorLow=sensorValue; } } digitalWrite(ledPin,LOW); } void loop(){ sensorValue=analogRead(A0); int pitch=map(sensorValue,sensorLow,sensorHigh,50,4000); tone(8,pitch,20); delay(10); }


##Project 7 : Keyboard Instrument

Test1

Test2


##程式碼

int buttons[6]={2}; int notes[]={262,294,330,349}; void setup(){ Serial.begin(9600); } void loop(){ int keyVal=analogRead(A0); Serial.println(keyVal); if(keyVal==1023){ tone(8,notes[0]); } else if(keyVal>=990&&keyVal<=1010){ tone(8,notes[1]); } else if(keyVal>=505&&keyVal<=515){ tone(8,notes[2]); } else if(keyVal>=5&&keyVal<=10){ tone(8,notes[3]); } else{ noTone(8); } }

##Project 5 : Mood Cue

Test1


Test2


##程式碼
#include<Servo.h> Servo myServo; int const potPin=A0; int potVal; int angle; void setup() { myServo.attach(9); Serial.begin(9600); } void loop() { potVal=analogRead(potPin); Serial.print("potVal:"); Serial.print(potVal); angle=map(potVal,0,1023,0,179); Serial.print("angle:"); Serial.print(angle); Serial.print("\n"); myServo.write(angle); delay(15); }

2013年11月24日 星期日

Week12

## Project 3 : Love-o-Meter


















 DEMO


##程式碼
const int sensorPin = A0; const float baselineTemp = 24.0; void setup(){ Serial.begin(9600); for(int pinNumber = 2; pinNumber<5; pinNumber++){ pinMode(pinNumber,OUTPUT); digitalWrite(pinNumber, LOW); } } void loop(){ int sensorVal = analogRead(sensorPin); Serial.print("Sensor Value:"); Serial.print(sensorVal); float voltage = (sensorVal/1024.0)*5.0; Serial.print(", Volts:"); Serial.print(voltage); Serial.print(", degrees C:"); float temperature = (voltage - .5)*100; Serial.println(temperature); if(temperature < baselineTemp){ digitalWrite(2, LOW); digitalWrite(3, LOW); digitalWrite(4, LOW); } else if(temperature >= baselineTemp+2 && temperature < baselineTemp+4){ digitalWrite(2, HIGH); digitalWrite(3, HIGH); digitalWrite(4, LOW); } else if(temperature >= baselineTemp+6){ digitalWrite(2, HIGH); digitalWrite(3, HIGH); digitalWrite(4, HIGH); } delay(1); }

##Project 4 :Color Mixing Lamp
















DEMO


##程式碼
const int greenLEDPin=9; const int redLEDPin=11; const int blueLEDPin=10; const int redSensorPin=A0; const int greenSensorPin=A1; const int blueSensorPin=A2; int redValue=0; int greenValue=0; int blueValue=0; int redSensorValue=0; int greenSensorValue=0; int blueSensorValue=0; void setup(){ Serial.begin(9600); pinMode(greenLEDPin,OUTPUT); pinMode(redLEDPin,OUTPUT); pinMode(blueLEDPin,OUTPUT); } void loop(){ redSensorValue=analogRead(redSensorPin); delay(5); greenSensorValue=analogRead(greenSensorPin); delay(5); blueSensorValue=analogRead(blueSensorPin); Serial.print("Raw Sensor Value \t Red"); Serial.print(redSensorValue); Serial.print("\t Green"); Serial.print(greenSensorValue); Serial.print("\t Blue"); Serial.print(blueSensorValue); redValue=redSensorValue/4; greenValue=greenSensorValue/4; blueValue=blueSensorValue/4; Serial.print("Mapped Sensor Value \t Red"); Serial.print(redValue); Serial.print("\t Green"); Serial.print(greenValue); Serial.print("\t Blue"); Serial.print(blueValue); analogWrite(redLEDPin,redValue); analogWrite(greenLEDPin,greenValue); analogWrite(blueLEDPin,blueValue); }

2013年11月17日 星期日

Week11

##實作1-範例Blink
一個LED燈閃爍,有修改秒數

/*
  Blink
  Turns on an LED on for one second, then off for one second, repeatedly.

  This example code is in the public domain.
 */

// Pin 13 has an LED connected on most Arduino boards.
// give it a name:
int led = 13;

// the setup routine runs once when you press reset:
void setup() {              
  // initialize the digital pin as an output.
  pinMode(led, OUTPUT);  
}

// the loop routine runs over and over again forever:
void loop() {
  digitalWrite(led, HIGH);   // turn the LED on (HIGH is the voltage level)
  delay(1000);               // wait for a second
  digitalWrite(led, LOW);    // turn the LED off by making the voltage LOW
  delay(1000);               // wait for a second
}

====程式碼====

##實作2-Blink
三個LED燈閃爍

====程式碼====
/*
  Blink
  Turns on an LED on for one second, then off for one second, repeatedly.

  This example code is in the public domain.
 */

// Pin 13 has an LED connected on most Arduino boards.
// give it a name:
//

// the setup routine runs once when you press reset:
void setup() {              
  // initialize the digital pin as an output.
  pinMode(13, OUTPUT);  
    pinMode(12, OUTPUT);  
      pinMode(11, OUTPUT);  
}

// the loop routine runs over and over again forever:
void loop() {
  digitalWrite(13, HIGH);   // turn the LED on (HIGH is the voltage level)
  delay(100);               // wait for a second
  digitalWrite(13, LOW);    // turn the LED off by making the voltage LOW
  delay(100);           // wait for a second
  digitalWrite(12, HIGH);   // turn the LED on (HIGH is the voltage level)
  delay(100);               // wait for a second
  digitalWrite(12, LOW);    // turn the LED off by making the voltage LOW
  delay(100);
    digitalWrite(11, HIGH);   // turn the LED on (HIGH is the voltage level)
  delay(100);               // wait for a second
  digitalWrite(11, LOW);    // turn the LED off by making the voltage LOW
  delay(100);           // wait for a second
  digitalWrite(13, HIGH);   // turn the LED on (HIGH is the voltage level)
  delay(100);               // wait for a second
  digitalWrite(13, LOW);    // turn the LED off by making the voltage LOW
  delay(100);
  digitalWrite(12, HIGH);   // turn the LED on (HIGH is the voltage level)
  delay(100);               // wait for a second
  digitalWrite(12, LOW);    // turn the LED off by making the voltage LOW
  delay(100);           // wait for a second
  digitalWrite(11, HIGH);   // turn the LED on (HIGH is the voltage level)
  delay(100);               // wait for a second
  digitalWrite(11, LOW);    // turn the LED off by making the voltage LOW
  delay(100);
 
}

2013年11月11日 星期一

Week10_期中DEMO

##DEMO影片



##程式碼
PImage starS, winP, loseP, starT, ansOne, falloW, nexT, agaiN, ansTwo;

int Z,zZ;
int D1=0, D2=6;
int j=0, W;
int clickCount = 0;

int []Ponx= { 100, 400, 250, 100, 400}; 
int []Ponx2= { 125, 375, 75, 425, 250};
int []Pony= { 400, 400, 275, 150, 150}; 
int []Pony2= { 425, 425, 175, 175, 75};

int []PPx= { 125, 425, 275, 125, 425}; 
int []PPx2= { 250, 500, 200, 550, 375};
int []PPy= { 425, 425, 300, 175, 175}; 
int []PPy2= { 550, 550, 300, 300, 350};

int []x= { 6, 6, 6, 6, 6, 6, 6}; 
int []x2= { 6, 6, 6, 6, 6, 6};

int []ans1= { 0, 2, 4, 1, 2, 3, 0}; 
int []ans5= { 0, 4, 1, 2, 3, 0};
int []ans2= { 0, 2, 1, 4, 2, 3, 0}; 
int []ans6= { 0, 3, 2, 1, 4, 0};
int []ans3= { 0, 3, 2, 4, 1, 2, 0};
int []ans4= { 0, 3, 2, 1, 4, 2, 0};

void setup()

   size(900, 600);
   background(24, 20, 90);
   starS=loadImage("http://i.imgur.com/Oxs9TWM.png?1");
   winP=loadImage("http://i.imgur.com/Sx6NCzf.jpg");
   loseP=loadImage("http://i.imgur.com/0tJ86T7.jpg?1");
   ansOne=loadImage("http://i.imgur.com/HRVkRHp.png");
   starT=loadImage("http://i.imgur.com/NoZ4MqU.png?1");
   falloW=loadImage("http://i.imgur.com/oxcZTaE.png");
   nexT=loadImage("http://i.imgur.com/4hb4Cln.png");
   agaiN=loadImage("http://i.imgur.com/BdxdTvl.png");
   ansTwo=loadImage("http://i.imgur.com/tFNyu4o.png");
  sett1();
}

void sett1()
{
   image(starS, Ponx[0], Pony[0], 50, 50);
   image(starS, Ponx[1], Pony[1], 50, 50);
   image(starS, Ponx[2], Pony[2], 50, 50);
   image(starS, Ponx[3], Pony[3], 50, 50);
   image(starS, Ponx[4], Pony[4], 50, 50);
   image(starT, 55, 455, 150, 80);
   image(falloW, 600, 190, 200, 40);
   image(ansOne, 600, 250, 200, 200);
}

void sett2()
{
   image(starS, Ponx2[0], Pony2[0], 50, 50);
   image(starS, Ponx2[1], Pony2[1], 50, 50);
   image(starS, Ponx2[2], Pony2[2], 50, 50);
   image(starS, Ponx2[3], Pony2[3], 50, 50);
   image(starS, Ponx2[4], Pony2[4], 50, 50);
   image(starT, 55, 500, 150, 80);
   image(falloW, 600, 190, 200, 40);
   image(ansTwo, 600, 250, 200, 200);
}

void mouseClicked()
{
   if(mouseButton==LEFT)
   {
      if (Ponx[0]<=mouseX&&mouseX<=Ponx[0]+50&&Pony[0]<=mouseY&&mouseY<=Pony[0]+50) 
      {
          Z=0; 
      }
      else if (Ponx[1]<=mouseX&&mouseX<=Ponx[1]+50&&Pony[1]<=mouseY&&mouseY<=Pony[1]+50)
      { 
         Z=1; 
      }
      else if (Ponx[2]<=mouseX&&mouseX<=Ponx[2]+50&&Pony[2]<=mouseY&&mouseY<=Pony[2]+50)
      {
         Z=2; 
      }
     else if (Ponx[3]<=mouseX&&mouseX<=Ponx[3]+50&&Pony[3]<=mouseY&&mouseY<=Pony[3]+50)
      {
         Z=3;
      }
      else if (Ponx[4]<=mouseX&&mouseX<=Ponx[4]+50&&Pony[4]<=mouseY&&mouseY<=Pony[4]+50)
      {
         Z=4; 
      }

      x[clickCount]=Z;
      clickCount++;
      println("====");
      for (j=0;j < x.length; j++)
      { 
         println(x[j]);
      }

      if (clickCount > 6)
      { 
         check();
      }
   }

   else if(mouseButton==RIGHT)
   {
      if (450<=mouseX&&mouseX<=600&&150<=mouseY&&mouseY<=200) 
      { 
         background(24, 20, 90);
         sett2();
      }
      else if (450<=mouseX&&mouseX<=600&&450<=mouseY&&mouseY<=500)
      {
         background(24, 20, 90);
         sett1();
      }
   }

   if (D1!=6)
   {
      D2=Z; 
      draw();
      D1=D2; 
      D2=6;
   }
}

void draw()
{
   if (D1==0 && D2==1 || D1==1 && D2==0)
   line(PPx[0], PPy[0], PPx[1], PPy[1]);

   else if (D1==0 && D2==3 ||D1==3 && D2==0 ) 
   line(PPx[0], PPy[0], PPx[3], PPy[3]);

   else if (D1==2 && D2==0 ||D1==0 && D2==2 )
   line(PPx[0], PPy[0], PPx[2], PPy[2]);

   else if (D1==1 && D2==2 ||D1==2 && D2==1 )
   line(PPx[1], PPy[1], PPx[2], PPy[2]);

   else if (D1==1 && D2==4 ||D1==4 && D2==1 ) 
   line(PPx[1], PPy[1], PPx[4], PPy[4]);

   else if (D1==2 && D2==3 ||D1==3 && D2==2 ) 
   line(PPx[2], PPy[2], PPx[3], PPy[3]);

   else if (D1==2 && D2==4 ||D1==4 && D2==2 ) 
   line(PPx[2], PPy[2], PPx[4], PPy[4]);

   else if (D1==3 && D2==4 ||D1==4 && D2==3 ) 
   line(PPx[3], PPy[3], PPx[4], PPy[4]);
}

void check()
{
   for (int i=0;i<7;i++)//check ans1
   {
      if (x[i]==ans1[i])
      W=1;
      else 
      { 
         W=0; 
         i=7;
      }
   }
   if (W==0) //not ans1,check ans2
   { 
      for (int i=0;i<7;i++)//check ans2
      {
         if (x[i]==ans2[i])
         W=1;
         else
         { 
            W=0; 
            i=7;
         }
      }
      if (W==0) //not ans2,check ans3
      { 
         for (int i=0;i<7;i++)//check ans3
         {
            if (x[i]==ans3[i])
            W=1;
            else
            { 
               W=0; 
               i=7;
            }
         }
         if (W==0) //not ans3,check ans4
         { 
            for (int i=0;i<7;i++)//check ans4
            {
               if (x[i]==ans4[i])
               W=1;
               else 
               { 
                  W=0; 
                  i=7;
               }
            }
            if (W==0) //not ans4,All not end
            {
               lose();
            }
               else if (W==1) //ans4 OK
               {
                  win();
               }
            }
            else if (W==1) //ans3 OK
            {
               win();
            }
         }
         else if (W==1) //ans2 OK
         {
            win();
         }
      }
   else if (W==1) //ans1 OK
   {
      win();
   }
}

void win()
{
   image(winP, 100, 150, 350, 350);
   image(nexT, 450, 150, 150, 80);
}

void lose()
{
   image(loseP, 100, 150, 350, 350);
   image(agaiN, 450, 450, 150, 80);
}