setup()

설명

setup() 함수는 스케치를 시작할 때 불린다. 그것을 이용하여 변수, 핀 모드를 초기화하고, 라이브러리 사용 시작 등을 한다. setup() 함수는 아두이노 보드 전원 켜기 또는 리셋 후 한번만 실행된다.

예제 코드

int buttonPin = 3; void setup() { // put your setup code here, to executed once: Serial.begin(9600); pinMode(buttonPin, INPUT); Serial.println("This is setup code"); } void loop() { // ... }

The output on Serial Monitor:

Newbiely | Arduino IDE 2.3.8
──
File
Edit
Sketch
Tools
Help
Arduino Uno
Newbiely.ino
···
8 Serial.println("Hello World!");
Output
Serial Monitor
Message (Enter to send message to 'Arduino Uno' on 'COM15')
New Line
9600 baud
This is setup code
Ln 11, Col 1
Arduino Uno on COM15
2

더보기

ARDUINO BUY RECOMMENDATION

Arduino UNO R3
Arduino Starter Kit
Disclosure: Some links in this section are Amazon affiliate links. If you make a purchase through these links, we may earn a commission at no extra cost to you.
Additionally, some links direct to products from our own brand, DIYables .

※ OUR MESSAGES