Page 224 - 최강 아두이노 퍼스트 참고서
P. 224

/*
                 Arduino - RGB LED
                 */

                 int  redPin  =  11;  int
                 greenPin  =  10;  int
                 bluePin = 9;

                 void setup()
                 {
                     Serial.begin(9600);          pinMode(redPin,
                 OUTPUT);             pinMode(greenPin,
                 OUTPUT);     pinMode(bluePin, OUTPUT);
                 }

                 void loop()
                 {
                     Serial.println("red");  setColor(255,
                 0, 0);  // red     delay(1000);
                     Serial.println("green");          setColor(0,
                 255, 0);  // green     delay(1000);
                     Serial.println("blue");         setColor(0, 0,
                 255);  // blue     delay(1000);
                     Serial.println("yellow");         setColor(255, 255,
                 0);  // yellow     delay(1000);
                     Serial.println("purple");           setColor(80, 0,
                 80);  // purple     delay(1000);
                     Serial.println("aqua");           setColor(0, 255,
                 255);  // aqua     delay(1000);
                 }













                void setColor(int red, int green, int blue)
                {
                    analogWrite(redPin,  red);  analogWrite(greenPin,  green);






                                                   224
   219   220   221   222   223   224   225   226   227   228   229