Recitation 9:Media controller- Andrew Xie

In this recitation, I chose to use a photosensitive resistor to control the brightness of the picture, but the effect was not obvious. The pictures are of Hobbits.

123

Code

PImage img;

void setup() {
size(600, 404);
PImage photo;
img = loadImage("hobbit.jpg");
tint(0,0,255,150);
point(mouseX,mouseY);

}

void draw() {
for (int i=0; i<100; i++) {
int size = int( random(1, 20) );
int x = int( random(img.width) );
int y = int( random(img.height) );
// get the pixel color
color c = img.get(x, y);
// draw a circle with the color
fill(c);
ellipse(x, y, size, size);
}
}

void mousePressed() {
point(mouseX,mouseY);
}

int photocellPin = 2; // 光敏电阻连接模拟端口【A2】

int ledPin = 13; // LED灯连接数字端口【D13】

int val = 0; // 存储光敏电阻值的变量

void setup() {

// 打开并设置串口

Serial.begin(9600);

// 设置数字端口ledPin用于输出

}

void loop() {

val = analogRead(photocellPin); // 读取光敏电阻的值

//在串口输出val的值 用于调试时使用

Serial.println(val);

if(val<=112){

digitalWrite(ledPin, HIGH);

}else{

digitalWrite(ledPin, LOW);

}

}

This article uses light and shadow to realize human interaction, which inspires me how to use multimedia in the project, such as using sound as a medium to trigger the interaction between the user and the machine.

Leave a Reply