Arduino 치트 시트 #1

May 03 2023
Arduino 펌웨어 기본 치트 시트
이전 기사에서 우리는 이미 DIY 전자 장치를 만드는 데 사용되는 인기 있는 오픈 소스 하드웨어 및 펌웨어 플랫폼인 Arduino에 대해 논의했습니다. 이 기사에서 우리는 Arduino를 배우는 동안 만든 치트 시트를 살펴볼 것이지만 여전히 그것을 계속 사용하고 있음을 인정합니다! 다음은 가장 일반적으로 사용되는 Arduino 기능 중 일부를 다루는 자세한 Arduino 치트 시트입니다. 지연(ms): 이 기능은 지정된 밀리초 동안 프로그램을 일시 중지합니다.

이전 기사 에서 우리는 이미 DIY 전자 장치를 만드는 데 사용되는 인기 있는 오픈 소스 하드웨어 및 펌웨어 플랫폼인 Arduino에 대해 논의했습니다. 이 기사에서 우리는 Arduino를 배우는 동안 만든 치트 시트를 살펴볼 것이지만 여전히 그것을 계속 사용하고 있음을 인정합니다!

다음은 가장 일반적으로 사용되는 Arduino 기능 중 일부를 다루는 자세한 Arduino 치트 시트입니다.

delay(ms):
이 함수는 지정된 밀리초 동안 프로그램을 일시 중지합니다. 지연 기능은 눈으로 볼 수 있도록 LED의 켜짐 상태와 꺼짐 상태 사이에 간격이 있어야 하는 LED 깜박임과 같은 경우에 매우 유용합니다. 지연을 사용하지 않으면 LED가 너무 빨리 깜박이고 깜박임 효과가 어려울 수 있습니다. 보다.

delay(1000); // waits for 1 second or 1000 milliseconds

delayMicroseconds(1000); // waits for 1 delay milliseconds or 1000 microseconds

pinMode(13, OUTPUT); // sets the pin 13 as output mode
pinMode(4, INPUT); // set pin 4 to input mode
pinMode(5, INPUT_PULLUP); // set pin 5 to input pullup mode

digitalWrite(13, HIGH); // sets the pin 13 on

int val = 0; // variable to store the read value
pinMode(4, INPUT); // sets the digital pin 4 as input
val = digitalRead(4); // read pin 4 and store in integer variable val

analogWrite(5, 128); // sets the pin 5 to 50% duty cycle

int val = 0; // variable to store the read value
val = analogRead(A0); // read the analog value of pin A0 and store in integer variable val

Serial.begin(9600); // initialise serial communication at 9600 baudrate

int val = 123;
Serial.print(val); // prints the integer variable val to the serial port

int val = Serial.read(); // reads a value from the serial port and stores it in the integer variable val

String myString = ""; // initialise empty string
String myString = Serial.readString();  //read until timeout

      
                
Photo by Daniel Andrade on Unsplash