Skip to content

Instantly share code, notes, and snippets.

View maxpromer's full-sized avatar

Max maxpromer

View GitHub Profile
/*
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;
void click_fn() {
Serial.println("Click !");
}
void setup() {
Serial.begin(9600);
attachInterrupt(0, click_fn, FALLING);
}
void setup() {
Serial.begin(9600);
}
void loop() {
int sensorValue = analogRead(A0);
Serial.println(sensorValue);
delay(1);
}
int i = 0;
void setup() {
ledcSetup(0, 5000, 13);
ledcAttachPin(LED_BUILTIN, 0);
}
void loop() {
ledcWrite(0, i);
delay(20);
int buzzer_pin = 23;
void setup() {
ledcWriteTone(0, 2000);
}
void loop() {
ledcAttachPin(buzzer_pin, 0);
delay(500);
ledcDetachPin(buzzer_pin);
void setup() {
Serial.setTimeout(100);
Serial.begin(115200);
}
void loop() {
if (Serial.available() > 0) {
String msg = Serial.readString();
Serial.print("Echo: ");
Serial.println(msg);
#define LED_PIN LED_BUILTIN
void setup() {
pinMode(LED_PIN, OUTPUT);
Serial.setTimeout(100);
Serial.begin(115200);
}
void loop() {
#include <Wire.h>
#define ADDR 0x27
void PCF_Write(byte data) {
Wire.beginTransmission(ADDR);
Wire.write(data);
Wire.endTransmission();
}
#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
void setup() {
Serial.begin(115200);
delay(1000);
Serial.println("ESP32 Touch Test");
}
void loop() {
Serial.println(touchRead(T0));
delay(1000);
}