#include

설명

#include 는 외부 라이브러리를 스케치 안에 포함할 때 쓰인다. 이것은 프로그래머가 표준 C 라이브러리(이미 만들어진 함수) 그리고 특히 아두이노를 위해 쓰여진 라이브러리 그룹에 대한 접근을 제공한다.

AVR C 라이브러리 (AVR은 아두이노가 기반인 Atmel 칩에 대한 참조)에 대한 주요 참조 페이지가 here 이다.

#include, #define 는 세미콜론 종결자가 없고, 추가하면 컴파일러가 암호 같은 에러 메시지를 낼 거다.

예제 코드

예제 코드 1

This example includes the Servo library so that its functions may be used to control a Servo motor.

#include <Servo.h> Servo myservo; // create servo object to control a servo void setup() { myservo.attach(9); // attaches the servo on pin 9 to the servo object } void loop() { for (int pos = 0; pos <= 180; pos += 1) { // goes from 0 degrees to 180 degrees // in steps of 1 degree myservo.write(pos); // tell servo to go to position in variable 'pos' delay(15); // waits 15ms for the servo to reach the position } for (int pos = 180; pos >= 0; pos -= 1) { // goes from 180 degrees to 0 degrees myservo.write(pos); // tell servo to go to position in variable 'pos' delay(15); // waits 15ms for the servo to reach the position } }

예제 코드 2

This example includes the pitches.h file, which is placed in the same directory with the sketch (the sketch's folder).

/* * This example code is in the public domain * Tutorial page: https://arduinogetstarted.com/tutorials/arduino-piezo-buzzer */ #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

Arduino UNO R3
Arduino Starter Kit
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.

※ OUR MESSAGES

  • We are AVAILABLE for HIRE. See how to hire us to build your project
  • Any suggestion, correction, and translation? please email us at ArduinoGetStarted@gmail.com, We appreciate it
  • We mainly keep improving the references in English. See English version of this page for the latest update.