아두이노 첫날
LED 의 사용법을 익혔다.
LED 사용하기
#define LED 2
void setup() {
// put your setup code here, to run once:
pinMode(LED,OUTPUT);
}
void loop() {
// put your main code here, to run repeatedly:
digitalWrite(LED,HIGH);
delay(1000);
digitalWrite(LED,LOW);
delay(1000);}
RGB LED 사용하기
#define LED 2
#define RED 11
#define GREEN 10
#define BLUE 9
void setup() {
// put your setup code here, to run once:
pinMode(LED,OUTPUT);
pinMode(RED,OUTPUT);
pinMode(GREEN,OUTPUT);
pinMode(BLUE,OUTPUT);
}
void loop() {
// put your main code here, to run repeatedly:
for(int i=0;i<=255;i++)
{
analogWrite(RED,i);
analogWrite(GREEN,i);
analogWrite(BLUE,i);
delay(i/20);
}
for(int i=255;i>=0;i--)
{
analogWrite(RED,i);
analogWrite(GREEN,i);
analogWrite(BLUE,i);
delay(i/20);
}
}