Bảng gian lận Arduino #1
Trong một bài viết trước , chúng ta đã thảo luận về Arduino- nền tảng phần cứng và phần sụn nguồn mở phổ biến được sử dụng để xây dựng các thiết bị điện tử DIY. Trong bài viết này, chúng ta sẽ xem qua một mánh gian lận mà tôi đã tạo khi tôi vẫn đang học Arduino, nhưng tôi thừa nhận vẫn tiếp tục sử dụng nó!
Dưới đây là bảng cheat Arduino chi tiết bao gồm một số chức năng Arduino được sử dụng phổ biến nhất:
độ trễ (ms):
Chức năng này tạm dừng chương trình trong một số mili giây được chỉ định. chức năng trì hoãn rất hữu ích trong các trường hợp như nhấp nháy đèn LED khi cần có khoảng cách giữa trạng thái bật và tắt của đèn led để mắt chúng ta có thể nhìn thấy, nếu không sử dụng độ trễ, đèn LED sẽ nhấp nháy quá nhanh và hiệu ứng nhấp nháy sẽ khó nhìn.
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