แผ่นโกง Arduino #1

May 03 2023
แผ่นชีทพื้นฐานของเฟิร์มแวร์ Arduino
ในบทความก่อนหน้านี้เราได้พูดถึง Arduino ซึ่งเป็นแพลตฟอร์มฮาร์ดแวร์และเฟิร์มแวร์โอเพ่นซอร์สยอดนิยมที่ใช้สำหรับสร้างอุปกรณ์อิเล็กทรอนิกส์ DIY ในบทความนี้เราจะพูดถึงสูตรโกงที่ฉันสร้างขึ้นในขณะที่ฉันยังเรียนรู้ Arduino แต่ฉันยอมรับว่ายังคงใช้มันต่อไป ! นี่คือสูตรโกง Arduino โดยละเอียดซึ่งครอบคลุมฟังก์ชัน Arduino ที่ใช้บ่อยที่สุดบางส่วน: ความล่าช้า (ms): ฟังก์ชันนี้จะหยุดโปรแกรมชั่วคราวตามจำนวนมิลลิวินาทีที่ระบุ

ในบทความ ก่อนหน้านี้ เราได้พูดถึง Arduino ซึ่งเป็นแพลตฟอร์มฮาร์ดแวร์และเฟิร์มแวร์โอเพ่นซอร์สยอดนิยมที่ใช้สำหรับสร้างอุปกรณ์อิเล็กทรอนิกส์ DIY ในบทความนี้เราจะพูดถึงสูตรโกงที่ฉันสร้างขึ้นในขณะที่ฉันยังเรียนรู้ Arduino แต่ฉันยอมรับว่ายังคงใช้มันต่อไป !

นี่คือสูตรโกง Arduino โดยละเอียดซึ่งครอบคลุมฟังก์ชัน Arduino ที่ใช้บ่อยที่สุดบางส่วน:

ความล่าช้า (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