Digital LED
- LED 는
GND
와 5V
2종류 이다. 구분할수 없다면 시도해보는 수밖에...
- LED 는 긴 쪽이
+
![](https://velog.velcdn.com/images%2Fmichael00987%2Fpost%2F375db9e9-7099-4189-b6c3-5fa214ae7576%2Fc8a4bc0a-26bc-44f1-bd2a-aa22e1d5c03a.jpg)
void setup() {
pinMode(8, OUTPUT);
}
void loop() {
digitalWrite(8, HIGH);
delay(200);
digitalWrite(8, LOW);
delay(200);
}
Analog LED
- LED 는
GND
와 5V
2종류 이다. 구분할수 없다면 시도해보는 수밖에... 아마도...
- LED 는 가장 긴게 전력
- 전력 옆으로 한개 있는 쪽이 RED, 2개 있는 쪽이 전력으로 부터 GREEN, BLUE 순이다.
![](https://velog.velcdn.com/images%2Fmichael00987%2Fpost%2Fc966a2da-7539-44ca-b623-a855424b174d%2Ffritzing.jpg)
const int RED = 9;
const int GREEN = 10;
const int BLUE = 11;
void setup() {
pinMode(RED, OUTPUT);
pinMode(GREEN, OUTPUT);
pinMode(BLUE, OUTPUT);
}
void loop() {
{
showSpectrum();
}
}
void showSpectrum() {
for (int x = 0 ; x < 768; x++) {
showRGB(x);
delay(10);
}
}
void showRGB(int color) {
int redIntensity;
int greenIntensity;
int blueIntensity;
if (color <= 255){
redIntensity = 255 - color;
greenIntensity = color;
buleIntensity = 0;
} else if (color <= 51){
redIntensity = 0;
greenIntensity = 255 - (color - 256);
buleIntensity = color - 256;
} else if (color <= 768){
redIntensity = color - 512;
greenIntensity = 0;
buleIntensity = 255 - (color - 512);
}
analogWrite(RED, redIntensity);
analogWrite(GREEN, greenIntensity);
analogWrite(BLUE, blueIntensity);
}