Skip to content

Instantly share code, notes, and snippets.

@neosarchizo
Last active September 29, 2021 02:09
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save neosarchizo/309b7f037e4763e0e527 to your computer and use it in GitHub Desktop.
Save neosarchizo/309b7f037e4763e0e527 to your computer and use it in GitHub Desktop.
[아두이노, 상상을 현실로 만드는 프로젝트 입문편] 코드 7 - 1
int r = 0, g = 0, b = 0;
void setup() {
pinMode(4, INPUT);
pinMode(3, INPUT);
pinMode(2, INPUT);
}
void loop() {
if (digitalRead(4) == HIGH) {
++r;
if (r > 255) {
r = 0;
}
}
if (digitalRead(3) == HIGH) {
++g;
if (g > 255) {
g = 0;
}
}
if (digitalRead(2) == HIGH) {
++b;
if (b > 255) {
b = 0;
}
}
analogWrite(11, r);
analogWrite(10, g);
analogWrite(9, b);
delay(10);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment