본문 바로가기
푸닥거리

아두이노 플랫폼을 활용한 코딩 기초(릴리패드)-4

by [김경민]™ ┌(  ̄∇ ̄)┘™ 2022. 4. 2.
728x90

arduino language framework

 

2, 3, 4, 5 디지털 출력 ( LED, 부저 )

- 0(끄다, LOW), 1(켜다, HIGH) 

 

// the loop function runs over and over again forever
void loop() {
  digitalWrite(LED_BUILTIN, HIGH);   // turn the LED on (HIGH is the voltage level)
  delay(100);                       // wait for a second
  digitalWrite(LED_BUILTIN, LOW);    // turn the LED off by making the voltage LOW
  delay(100);                       // wait for a second
}

 

https://www.arduino.cc/reference/en/

 

Arduino Reference - Arduino Reference

Language Reference Arduino programming language can be divided in three main parts: functions, values (variables and constants), and structure.

www.arduino.cc

 

 

- pinMode()

 

 

https://www.arduino.cc/reference/en/language/functions/digital-io/pinmode/

 

pinMode() - Arduino Reference

Example Code The code makes the digital pin 13 OUTPUT and Toggles it HIGH and LOW void setup() { pinMode(13, OUTPUT); // sets the digital pin 13 as output } void loop() { digitalWrite(13, HIGH); // sets the digital pin 13 on delay(1000); // waits for a sec

www.arduino.cc

 

 

- digitalRead()

 

- digital Write()

 

https://www.arduino.cc/reference/en/language/functions/digital-io/digitalwrite/

 

digitalWrite() - Arduino Reference

Example Code The code makes the digital pin 13 an OUTPUT and toggles it by alternating between HIGH and LOW at one second pace. void setup() { pinMode(13, OUTPUT); // sets the digital pin 13 as output } void loop() { digitalWrite(13, HIGH); // sets the dig

www.arduino.cc

 

// the setup function runs once when you press reset or power the board
void setup() {
  // initialize digital pin LED_BUILTIN as an output.
  pinMode(13, OUTPUT);
}

// the loop function runs over and over again forever
void loop() {
  digitalWrite(13, HIGH);   // turn the LED on (HIGH is the voltage level)
  delay(100);                       // wait for a second
  digitalWrite(13, LOW);    // turn the LED off by making the voltage LOW
  delay(100);                       // wait for a second
}

 

 

 

 

 

 

 

// the setup function runs once when you press reset or power the board
void setup() {
  // initialize digital pin LED_BUILTIN as an output.
  pinMode(2, OUTPUT);
}

// the loop function runs over and over again forever
void loop() {
  digitalWrite(2, HIGH);   // turn the LED on (HIGH is the voltage level)
  delay(100);                       // wait for a second
  digitalWrite(2, LOW);    // turn the LED off by making the voltage LOW
  delay(100);                       // wait for a second
}

 

 

 

 

전연 변수

 

void setup() // 초기설정 셋팅부분, 전원 인가 시 최조 1회만 실행

{

     코드 실행시, 최초 한번만 실행 : 지역변수 선언 가능, 주로 하드웨어적 셋팅
}

void loop() // 프로그램 주코드 입력부분, 무한 반복 실행

{

   무한 반복 : 지역변수 선언 가능, 작성된 코딩 알고리즘 수행
}

 

 

https://www.arduino.cc/reference/en/language/functions/time/delay/

 

delay() - Arduino Reference

Description Pauses the program for the amount of time (in milliseconds) specified as parameter. (There are 1000 milliseconds in a second.) Syntax Parameters ms: the number of milliseconds to pause. Allowed data types: unsigned long. Returns

www.arduino.cc

 

1000 = 1초

100 = 0.1초

 

delay(ms)

 

 

 

 

728x90

댓글