我們的照片
2014年1月12日 星期日
2013年12月16日 星期一
2013年12月1日 星期日
第十三週上課內容
Project 05 (Mood Cue)
#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.println(angle); myServo.write(angle); delay(15); }
Project 06 (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 07 (keyboard Instrament)
#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.println(angle); myServo.write(angle); delay(15); }
Project 06 (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 07 (keyboard Instrament)
2013年11月24日 星期日
第十二週上課內容
const int sensorPin = A0;
const float baselineTemp = 23.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: ");
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, LOW);
digitalWrite(4, LOW);
}
else if(temperature >= baselineTemp+4 && temperature < baselineTemp+6){
digitalWrite(2, HIGH);
digitalWrite(3, HIGH);
digitalWrite(4, LOW);
}
else if(temperature >= baselineTemp +6){
digitalWrite(2, HIGH);
digitalWrite(3, HIGH);
digitalWrite(4, HIGH);
}
delay(100);
}
const int Brightness = 20; // set overall brightness, use lower value in darkroom to protect your eyes (0-255)
const int greenLEDPin = 9; // LED connected to digital pin 9
const int redLEDPin = 10; // LED connected to digital pin 10
const int blueLEDPin = 11; // LED connected to digital pin 11
const int redSensorPin = A0; // pin with the photoresistor with the red gel
const int greenSensorPin = A1; // pin with the photoresistor with the green gel
const int blueSensorPin = A2; // pin with the photoresistor with the blue gel
int redSensorValue = 0; // variable to hold the value from the red sensor
int greenSensorValue = 0; // variable to hold the value from the green sensor
int blueSensorValue = 0; // variable to hold the value from the blue sensor
int redSensorHigh = 0; //High and low value for mapping. Notice that 'High' value were set low at 0, so that during calibration, its value would be be pushed up. See project 6.
int greenSensorHigh = 0;
int blueSensorHigh = 0;
int redSensorLow = 1023; // the opposite is true for 'Low' value
int greenSensorLow = 1023;
int blueSensorLow = 1023;
void setup() {
// initialize serial communications at 9600 bps:
Serial.begin(9600);
// set the digital pins as outputs
pinMode(greenLEDPin,OUTPUT);
pinMode(redLEDPin,OUTPUT);
pinMode(blueLEDPin,OUTPUT);
//switching on your lamp before calibration, as it would affect calibration too, especially in dark environment
analogWrite(redLEDPin, Brightness);
analogWrite(greenLEDPin, Brightness);
analogWrite(blueLEDPin, Brightness);
//actual calibration which takes 10 seconds. During calibration, LED would shine at constant brightness. After that, it'll start to respond.
while (millis() < 10000) {
redSensorValue = analogRead(redSensorPin); //read pin
if (redSensorValue > redSensorHigh) { //push 'High' value up based on sensor value. At the end of calibration, 'High' value would take the highest 'SensorValue' during the 10 seconds.
redSensorHigh = redSensorValue;
}
if (redSensorValue < redSensorLow) { //opposite is true for 'Low' value
redSensorLow = redSensorValue;
}
delay(5);
greenSensorValue = analogRead(greenSensorPin);
if (greenSensorValue > greenSensorHigh) {
greenSensorHigh = greenSensorValue;
}
if (greenSensorValue < greenSensorLow) {
greenSensorLow = greenSensorValue;
}
delay(5);
blueSensorValue = analogRead(blueSensorPin);
if (blueSensorValue > blueSensorHigh) {
blueSensorHigh = blueSensorValue;
}
if (blueSensorValue < blueSensorLow) {
blueSensorLow = blueSensorValue;
}
delay(5);
}
}
void loop() {
// Read the sensors first:
// read the value from the red-filtered photoresistor:
redSensorValue = analogRead(redSensorPin);
// give the ADC a moment to settle
delay(5);
// read the value from the green-filtered photoresistor:
greenSensorValue = analogRead(greenSensorPin);
// give the ADC a moment to settle
delay(5);
// read the value from the blue-filtered photoresistor:
blueSensorValue = analogRead(blueSensorPin);
// print out the values to the serial monitor
Serial.print("raw sensor Values \t red: ");
Serial.print(redSensorValue);
Serial.print("\t green: ");
Serial.print(greenSensorValue);
Serial.print("\t Blue: ");
Serial.println(blueSensorValue);
int redValue = map(redSensorValue,redSensorLow,redSensorHigh,0,Brightness);
redValue = constrain(redValue,0,255);
int greenValue = map(greenSensorValue,greenSensorLow,greenSensorHigh,0,Brightness);
greenValue = constrain(greenValue,0,255);
int blueValue = map(blueSensorValue,blueSensorLow,blueSensorHigh,0,Brightness);
blueValue = constrain(blueValue,0,255);
// print out the mapped values
Serial.print("Mapped sensor Values \t red: ");
Serial.print(redValue);
Serial.print("\t green: ");
Serial.print(greenValue);
Serial.print("\t Blue: ");
Serial.println(blueValue);
analogWrite(redLEDPin, redValue);
analogWrite(greenLEDPin, greenValue);
analogWrite(blueLEDPin, blueValue);
}
2013年11月17日 星期日
第十一周上課內容
1. 練習第一個範例 File-Examples-Basic-Blink
2. 修改程式,變成展得比較特別的作法
void setup(){
pinMode(11, OUTPUT);
pinMode(13, OUTPUT); //13號孔的燈
pinMode(12, OUTPUT); //12號孔的燈
}
void loop(){
digitalWrite(13, HIGH);
delay(100);
digitalWrite(13, LOW);
delay(200);
digitalWrite(12, HIGH);
delay(200);
digitalWrite(12, LOW);
delay(200);
digitalWrite(11, HIGH);
delay(100);
digitalWrite(11, LOW);
delay(200);
}
2. 修改程式,變成展得比較特別的作法
void setup(){
pinMode(11, OUTPUT);
pinMode(13, OUTPUT); //13號孔的燈
pinMode(12, OUTPUT); //12號孔的燈
}
void loop(){
digitalWrite(13, HIGH);
delay(100);
digitalWrite(13, LOW);
delay(200);
digitalWrite(12, HIGH);
delay(200);
digitalWrite(12, LOW);
delay(200);
digitalWrite(11, HIGH);
delay(100);
digitalWrite(11, LOW);
delay(200);
}
2013年11月10日 星期日
2013年10月21日 星期一
第七週上課內容
兩個人交一份沒關係, 標注你的學號姓名
1. 請列出你今天三個小時,要完成的事
繼續完成"小朋友下樓梯",把小朋友放上去在螢幕上移動,
使樓梯亂數碼往上移動。
2. 你在期中作品要做到什麼程度
最後加上背景音樂使遊戲完美化。
3. Why? 你為什麼要做它
小時候的童年回憶能自己動手完成做出來感覺很棒。
1. 請列出你今天三個小時,要完成的事
繼續完成"小朋友下樓梯",把小朋友放上去在螢幕上移動,
使樓梯亂數碼往上移動。
2. 你在期中作品要做到什麼程度
最後加上背景音樂使遊戲完美化。
3. Why? 你為什麼要做它
小時候的童年回憶能自己動手完成做出來感覺很棒。
2013年10月13日 星期日
2013年10月6日 星期日
第五週上課內容
今天目標: (1) 會轉動的漂亮的花花, (2) 思考決定期中作品
(2) 思考決定期中作品
海綿寶寶戳泡泡
跟著水流不停的將沿路上的泡泡搓破,小心遇上了落下來的岩石要躲開!
控制方法:用鼠標控制方向。躲開旁邊的牆壁。
控制方法:用鼠標控制方向。躲開旁邊的牆壁。
(3)請用中文多寫一些心得及想要做的事 (老師可以讀)
我覺得老師講解時間以及關廣播給我們自由發揮的時間恰恰好。不會講太快!
2013年9月29日 星期日
2013年9月22日 星期日
第三週上課內容
1. 今天目標: 畫出一個五子棋
1.1. 使用 Tool- Color Selector, 挑出你要的顏色, 可用 R,G,B 來描述,也可用 #0B33FF 之類的數字來用
1.2. 要畫外框,可以用 rect()來畫, 要修改填充的顏色可以用fill(), 要讓畫的內部不要填充, 可以查看 Help-Reference 後,在 fill()樓上樓下相關的地方找到你要的功能 (ex. noFill() )
1.3. 使用 stroke() 來調畫線stroke的顏色, 在 Help-Reference 裡面可以找 stroke 相關的功能,像是比較粗的 stroke 可以用 strokeWeight() 來設定權重粗細
1.4. 想要畫裡面的細黑線,可以用 line() 來畫,配上不同的 strokeWeight() 粗細
1.1. 使用 Tool- Color Selector, 挑出你要的顏色, 可用 R,G,B 來描述,也可用 #0B33FF 之類的數字來用
1.2. 要畫外框,可以用 rect()來畫, 要修改填充的顏色可以用fill(), 要讓畫的內部不要填充, 可以查看 Help-Reference 後,在 fill()樓上樓下相關的地方找到你要的功能 (ex. noFill() )
1.3. 使用 stroke() 來調畫線stroke的顏色, 在 Help-Reference 裡面可以找 stroke 相關的功能,像是比較粗的 stroke 可以用 strokeWeight() 來設定權重粗細
1.4. 想要畫裡面的細黑線,可以用 line() 來畫,配上不同的 strokeWeight() 粗細
2013年9月8日 星期日
第一週上課內容
0. 課程準備
0.1. 加入 課程FB社團0.2. Google文件 填寫修課資料 (學號姓名,email,電話)
0.3. 加入 Blog, 設定
size(600,600);
background(255, 0, 0);
rect(100,100, 200,200);
PImage imgBird=loadImage("http://www.cmlab.csie.ntu.edu.tw/~jsyeh/processing/angryBirdsBrick/bird.png");
PImage imgPig =loadImage("http://www.cmlab.csie.ntu.edu.tw/~jsyeh/processing/angryBirdsBrick/pig.gif");
image(imgBird, 0,0);
image(imgPig, 200,200, 100,100);
PImage imgBird, imgPig;
void setup() {
size(600, 600);
imgBird=loadImage("http://www.cmlab.csie.ntu.edu.tw/~jsyeh/processing/angryBirdsBrick/bird.png");
imgPig =loadImage("http://www.cmlab.csie.ntu.edu.tw/~jsyeh/processing/angryBirdsBrick/pig.gif");
imageMode(CENTER);
}
void draw() {
background(255, 0, 0);
image(imgBird, mouseX, mouseY);
image(imgPig, 200, 200, 100, 100);
}
訂閱:
文章 (Atom)

























