(LED 소스)
void setup(){
pinMode(13,OUTPUT);
}
void loop(){
digitalWrite(13,HUGH);
delay(100);
digitalWrite(13,LOW);
delay(100);
}
(LED 4개)
void setup(){
pinMode(13,OUTPUT);
pinMode(12,OUTPUT);
pinMode(11,OUTPUT);
pinMode(10,OUTPUT);
}
void loop(){
digitalWrite(13,HUGH);
digitalWrite(12,HUGH);
digitalWrite(11,HUGH);
digitalWrite(10,HUGH);
delay(100);
digitalWrite(13,LOW);
digitalWrite(12,LOW);
digitalWrite(11,LOW);
digitalWrite(10,LOW);
delay(100);
}
(pushbuttons 소스)
int =13;
int =2;
int val =0;
}
void setup(){
pin Mode(13,OUTPUT)
pin Mode(2,INPUT);
}
void loop(){
val=digitalRead(inputpin);
if(val==HIGH){
digitalWrite(13,LOW);
}else{
digitalWrite(13,HIGH);
}
}
(servos소스)
#include<servo.h>
servo myservo;
int pos=0;
void setup(){
myservo.attach(9);
}
void loop(){
for(pos =0; pos <180; pos +=1){
myservo.write(pos);
delay(15);
}
for(pos =180; pos >=180; pos -=1){
myservo.write(pos);
delay(15);
}
}
(RGB LED소스)
int red=13;
int green=12;
int blue=11;
void setup(){
}
void loop(){
for (green=0;
green<=255;
green+=5){
red=255-green;
analogWrite(GREEN_LED_PIN,green);
analogWrite(RED_LED_PIN,red);
delay(DISPALY_TIME);
}
for(blue=0;
blue<=255;
blue+=5){
green=255-blue;
analogWrite(BLUE_LED_PIN,blue);
analogWrite(GREEN_SED_PIN,green);
delay(DISPALY_TIME);
}
for(red=0;
red<=255;
red+=5){
blue=255-red;
analogWrite(RED_LED_PIN,red);
analogWrite(BLUE_SED_PIN.blue);
delay(DISPALY_TIME);
}
}
(piezo Elements 소스)
int speakerpin=9;
int length=15;
char noter[] = "ccggaagffeeddc";
int beats[] ={1,1,1,1,1,1,2,1,1,1,1,1,1,2,4};
int tempo=300;
void playTone(int tone, inr duration){
for(long I=0;i<duration * 1000L;i+=tone *2){
digitalwrite(speakerpin,HIGH);
delayMicroseconds(tone);
digitalwrite(speakerpin,LOW);
delayMicroseconds(tone);
}
}
void playNote(char,note,int,duration){
char names[] = {'c','d','e','f','g','a','b','c'};
int tones[]={1915,1700,1519,1432,1275,1136,1014,956};
for(int I =0; i<8; i++){
if(names[i]==note){
playTone(tones[i],duration);
}
}
}
void setup(){
pinMode(13,OUTPUT);
}
void loop(){
for(int I =0; i<lengh i++){
if(notes[i]==' '){
dealy(beats[i] *tempo);
}else{
playNote(notes[i],beats[i]*tempo);
}
dealy(tem/2);}
}
댓글 없음:
댓글 쓰기