This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /* | |
| DigitalReadSerial | |
| Reads a digital input on pin 2, prints the result to the serial monitor | |
| This example code is in the public domain. | |
| */ | |
| // digital pin 2 has a pushbutton attached to it. Give it a name: | |
| int pushButton = 0; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| void click_fn() { | |
| Serial.println("Click !"); | |
| } | |
| void setup() { | |
| Serial.begin(9600); | |
| attachInterrupt(0, click_fn, FALLING); | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| void setup() { | |
| Serial.begin(9600); | |
| } | |
| void loop() { | |
| int sensorValue = analogRead(A0); | |
| Serial.println(sensorValue); | |
| delay(1); | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| int i = 0; | |
| void setup() { | |
| ledcSetup(0, 5000, 13); | |
| ledcAttachPin(LED_BUILTIN, 0); | |
| } | |
| void loop() { | |
| ledcWrite(0, i); | |
| delay(20); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| int buzzer_pin = 23; | |
| void setup() { | |
| ledcWriteTone(0, 2000); | |
| } | |
| void loop() { | |
| ledcAttachPin(buzzer_pin, 0); | |
| delay(500); | |
| ledcDetachPin(buzzer_pin); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| void setup() { | |
| Serial.setTimeout(100); | |
| Serial.begin(115200); | |
| } | |
| void loop() { | |
| if (Serial.available() > 0) { | |
| String msg = Serial.readString(); | |
| Serial.print("Echo: "); | |
| Serial.println(msg); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #define LED_PIN LED_BUILTIN | |
| void setup() { | |
| pinMode(LED_PIN, OUTPUT); | |
| Serial.setTimeout(100); | |
| Serial.begin(115200); | |
| } | |
| void loop() { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #include <Wire.h> | |
| #define ADDR 0x27 | |
| void PCF_Write(byte data) { | |
| Wire.beginTransmission(ADDR); | |
| Wire.write(data); | |
| Wire.endTransmission(); | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #include <Wire.h> // เรียกใช้ไลบารี่ Wire.h | |
| void setup() { // สร้างฟังก์ชั่น setup | |
| Wire.begin(); // เริ่มใช้งาน I2C | |
| Serial.begin(9600); // ใช้ UART0 ในการดีบัคและแสดงผลใน Serial Monitor | |
| Serial.println("\nI2C Scanner"); // แสดงผลคำว่า “I2C Scanner” โดยให้ขึ้นบรรทัดใหม่ก่อนและหลังแสดงผล | |
| } // จบคำสั่งในฟังก์ชั่น setup | |
| void loop() { // สร้างฟังก์ชั่น loop |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| void setup() { | |
| Serial.begin(115200); | |
| delay(1000); | |
| Serial.println("ESP32 Touch Test"); | |
| } | |
| void loop() { | |
| Serial.println(touchRead(T0)); | |
| delay(1000); | |
| } |