#include
#include 는 외부 라이브러리를 스케치 안에 포함할 때 쓰인다. 이것은 프로그래머가 표준 C 라이브러리(이미 만들어진 함수) 그리고 특히 아두이노를 위해 쓰여진 라이브러리 그룹에 대한 접근을 제공한다.
AVR C 라이브러리 (AVR은 아두이노가 기반인 Atmel 칩에 대한 참조)에 대한 주요 참조 페이지가 here 이다.
#include, #define 는 세미콜론 종결자가 없고, 추가하면 컴파일러가 암호 같은 에러 메시지를 낼 거다.
This example includes the Servo library so that its functions may be used to control a Servo motor.
#include <Servo.h>
Servo myservo;
void setup() {
myservo.attach(9);
}
void loop() {
for (int pos = 0; pos <= 180; pos += 1) {
myservo.write(pos);
delay(15);
}
for (int pos = 180; pos >= 0; pos -= 1) {
myservo.write(pos);
delay(15);
}
}
This example includes the pitches.h file, which is placed in the same directory with the sketch (the sketch's folder).
#include "pitches.h"
int melody[] = {
NOTE_C4, NOTE_G3, NOTE_G3, NOTE_A3, NOTE_G3, 0, NOTE_B3, NOTE_C4
};
int noteDurations[] = {
4, 8, 8, 4, 4, 4, 4, 4
};
void setup() {
for (int thisNote = 0; thisNote < 8; thisNote++) {
int noteDuration = 1000 / noteDurations[thisNote];
tone(8, melody[thisNote], noteDuration);
int pauseBetweenNotes = noteDuration * 1.30;
delay(pauseBetweenNotes);
noTone(8);
}
}
void loop() {
}
※ ARDUINO BUY RECOMMENDATION
Please note: These are affiliate links. If you buy the components through these links, We may get a commission at no extra cost to you. We appreciate it.
Follow Us
Share with your friends!