2015年1月18日 星期日
2014年12月15日 星期一
week14_01160686_葉梓灝
void setup() {
pinMode(13, OUTPUT);
}
void loop() {
int value =analogRead(A0);
digitalWrite(13,HIGH);
delay(value);
digitalWrite(13,LOW);
delay(value);
}
pinMode(13, OUTPUT);
}
void loop() {
int value =analogRead(A0);
digitalWrite(13,HIGH);
delay(value);
digitalWrite(13,LOW);
delay(value);
}
2014年12月8日 星期一
2014年12月1日 星期一
01160686_葉梓灝_week12
#include "pitches.h"
// notes in the melody:
int melody[] = {
NOTE_C4, NOTE_G3,NOTE_G3, NOTE_A3, NOTE_G3,0, NOTE_B3, NOTE_C4};
// note durations: 4 = quarter note, 8 = eighth note, etc.:
int noteDurations[] = {
4, 8, 8, 4,4,4,4,4 };
void setup() {
// iterate over the notes of the melody:
for (int thisNote = 0; thisNote < 8; thisNote++) {
// to calculate the note duration, take one second
// divided by the note type.
//e.g. quarter note = 1000 / 4, eighth note = 1000/8, etc.
int noteDuration = 1000/noteDurations[thisNote];
tone(8, melody[thisNote],noteDuration);
// to distinguish the notes, set a minimum time between them.
// the note's duration + 30% seems to work well:
int pauseBetweenNotes = noteDuration * 1.30;
delay(pauseBetweenNotes);
// stop the tone playing:
noTone(8);
}
}
void loop() {
// no need to repeat the melody.
}
01160686_葉梓灝_week12
/*
Button
Turns on and off a light emitting diode(LED) connected to digital
pin 13, when pressing a pushbutton attached to pin 2.
The circuit:
* LED attached from pin 13 to ground
* pushbutton attached to pin 2 from +5V
* 10K resistor attached to pin 2 from ground
* Note: on most Arduinos there is already an LED on the board
attached to pin 13.
created 2005
by DojoDave <http://www.0j0.org>
modified 30 Aug 2011
by Tom Igoe
This example code is in the public domain.
http://www.arduino.cc/en/Tutorial/Button
*/
// constants won't change. They're used here to
// set pin numbers:
const int buttonPin = 2; // the number of the pushbutton pin
const int ledPin = 13; // the number of the LED pin
// variables will change:
int buttonState = 0; // variable for reading the pushbutton status
void setup() {
// initialize the LED pin as an output:
pinMode(ledPin, OUTPUT);
// initialize the pushbutton pin as an input:
pinMode(buttonPin, INPUT);
}
void loop(){
// read the state of the pushbutton value:
buttonState = digitalRead(buttonPin);
// check if the pushbutton is pressed.
// if it is, the buttonState is HIGH:
if (buttonState == HIGH) {
// turn LED on:
digitalWrite(ledPin, HIGH);
}
else {
// turn LED off:
digitalWrite(ledPin, LOW);
}
}
2014年10月27日 星期一
2014年10月20日 星期一
2014年9月29日 星期一
01160686_葉梓灝,Hw03,week03
PImage img;
float eggX=750,eggY=550,eggVX,eggVY,flying=0;
import ddf.minim.analysis.*;
import ddf.minim.*;
Minim minim;
AudioPlayer jingle;
FFT fft;
void setup(){
size(400,600,P3D);
img=loadImage("201008031121163961.gif");
imageMode(CENTER);
minim = new Minim(this);
jingle = minim.loadFile("jingle.mp3", 1024);
jingle.loop();
fft = new FFT( jingle.bufferSize(), jingle.sampleRate() );
}
void draw(){
background(255,0,0);
stroke(255);
image(img,mouseX,mouseY,300,200);
if(flying>0){
fill(67,222,109);
ellipse(eggX,eggY,25,25);
eggX+= eggVX;
eggY+=eggVY;
flying--;
}
}
void mousePressed(){
eggX=750;eggY=550;
eggVX=(mouseX-eggX)/15;
eggVY=(mouseY-eggY)/15;
flying=30;
}
float eggX=750,eggY=550,eggVX,eggVY,flying=0;
import ddf.minim.analysis.*;
import ddf.minim.*;
Minim minim;
AudioPlayer jingle;
FFT fft;
void setup(){
size(400,600,P3D);
img=loadImage("201008031121163961.gif");
imageMode(CENTER);
minim = new Minim(this);
jingle = minim.loadFile("jingle.mp3", 1024);
jingle.loop();
fft = new FFT( jingle.bufferSize(), jingle.sampleRate() );
}
void draw(){
background(255,0,0);
stroke(255);
image(img,mouseX,mouseY,300,200);
if(flying>0){
fill(67,222,109);
ellipse(eggX,eggY,25,25);
eggX+= eggVX;
eggY+=eggVY;
flying--;
}
}
void mousePressed(){
eggX=750;eggY=550;
eggVX=(mouseX-eggX)/15;
eggVY=(mouseY-eggY)/15;
flying=30;
}
01160686_葉梓灝,Hw03,week03
PImage img;
float eggX=750,eggY=550,eggVX,eggVY,flying=0;
void setup(){
size(400,600);
img=loadImage("201008031121163961.gif");
imageMode(CENTER);
}
void draw(){
background(255,0,0);
image(img,mouseX,mouseY,300,200);
if(flying>0){
fill(67,222,109);
ellipse(eggX,eggY,25,25);
eggX+= eggVX;
eggY+=eggVY;
flying--;
}
}
void mousePressed(){
eggX=750;eggY=550;
eggVX=(mouseX-eggX)/15;
eggVY=(mouseY-eggY)/15;
flying=30;
}
float eggX=750,eggY=550,eggVX,eggVY,flying=0;
void setup(){
size(400,600);
img=loadImage("201008031121163961.gif");
imageMode(CENTER);
}
void draw(){
background(255,0,0);
image(img,mouseX,mouseY,300,200);
if(flying>0){
fill(67,222,109);
ellipse(eggX,eggY,25,25);
eggX+= eggVX;
eggY+=eggVY;
flying--;
}
}
void mousePressed(){
eggX=750;eggY=550;
eggVX=(mouseX-eggX)/15;
eggVY=(mouseY-eggY)/15;
flying=30;
}
01160686_葉梓灝,Hw03,Week03
PImage img;
void setup(){
size(400,600);
img=loadImage("0321-00296-001b2.jpg");
imageMode(CENTER);
}
void draw(){
background(255,0,0);
image(img,mouseX,mouseY,300,200);
}
void setup(){
size(400,600);
img=loadImage("0321-00296-001b2.jpg");
imageMode(CENTER);
}
void draw(){
background(255,0,0);
image(img,mouseX,mouseY,300,200);
}
2014年9月15日 星期一
訂閱:
文章 (Atom)









