int R = 11; int G = 10; int B = 9;
// 프로그램 시작 - 초기화 작업 void setup() { pinMode(R, OUTPUT); pinMode(G, OUTPUT); pinMode(B, OUTPUT); }
void loop() { analogWrite(R, 0); analogWrite(G, 0); analogWrite(B, 0);
// RED for (int i = 0; i < 256; i++) { analogWrite(R, i); delay(10); } for (int i = 0; i < 256; i++) { analogWrite(R, 255-i); delay(10); }
// GREEN for (int i = 0; i < 256; i++) { analogWrite(G, i); delay(10); } for (int i = 0; i < 256; i++) { analogWrite(G, 255 - i); delay(10); }
// BLUE for (int i = 0; i < 256; i++) { analogWrite(B, i); delay(10); } for (int i = 0; i < 256; i++) { analogWrite(B, 255 - i); delay(10); }
// WHITE for (int i = 0; i < 256; i++) { analogWrite(R, i); analogWrite(G, i); analogWrite(B, i); delay(10); }
for (int i = 0; i < 256; i++) { analogWrite(R, 255 - i); analogWrite(G, 255 - i); analogWrite(B, 255 - i); delay(10); } }
|