• 강의
  • 커뮤니티
  • 북마크
GCR

자료실

교육자료 | 안골포중 수업자료-13단원

최고관리자
2019.12.10 14:18 49 0

본문

코드 1

int LED_R = 11;
int LED_G = 10;
int LED_B = 9 ;

void setup() {
  pinMode(LED_R, OUTPUT);
  pinMode(LED_G, OUTPUT);
  pinMode(LED_B, OUTPUT);
}

void loop() {
  digitalWrite(LED_R, HIGH);
  delay(500);
  digitalWrite(LED_R, LOW);
  delay(500);
  digitalWrite(LED_G, HIGH);
  delay(500);
  digitalWrite(LED_G, LOW);
  delay(500);
  digitalWrite(LED_B, HIGH);
  delay(500);
  digitalWrite(LED_B, LOW);
  delay(500);
  digitalWrite(LED_R, HIGH);
  delay(500);
  digitalWrite(LED_B, HIGH);
  delay(500);
  digitalWrite(LED_G, HIGH);
  delay(500);
  digitalWrite(LED_R, LOW);
  delay(500);
  digitalWrite(LED_B, LOW);
  delay(500);
  digitalWrite(LED_G, LOW);
  delay(500);
}


코드2

#define RED 11
#define GREEN 10
#define BLUE 9

void setup() {
  randomSeed(analogRead(0));
}

void loop() {
  analogWrite(RED, random(256));
  analogWrite(GREEN, random(256));
  analogWrite(BLUE, random(256));
  delay(1000);
}

댓글목록 0

등록된 댓글이 없습니다.