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 loop() { | |
digitalWrite(LED_BUILTIN, HIGH); | |
delay(1000); | |
digitalWrite(LED_BUILTIN, LOW); | |
delay(1000); | |
} | |
unsigned long previousMillis = 0; | |
bool ledState = false; | |
const long interval = 1000; |
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 loop() { | |
delay(5000); // หยุด 5 วินาที | |
if (digitalRead(buttonPin) == HIGH) { | |
// ปุ่มอาจถูกกดและปล่อยไปแล้วระหว่าง delay() | |
Serial.println("Button pressed"); // อาจไม่ทำงาน | |
} | |
} |
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
// ตัวอย่างปัญหาของ delay() | |
void loop() { | |
digitalWrite(LED_BUILTIN, HIGH); | |
delay(1000); // หยุดทำงานทุกอย่าง 1 วินาที! | |
digitalWrite(LED_BUILTIN, LOW); | |
delay(1000); // หยุดอีก 1 วินาที | |
// ในขณะ delay() โปรแกรมไม่สามารถ: | |
// - อ่านเซนเซอร์ | |
// - ตรวจสอบปุ่มกด |
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
#ifndef __BATTERY_H__ | |
#define __BATTERY_H__ | |
#include <Arduino.h> | |
// ADC Configuration | |
#define BATTERY_PIN 34 // GPIO34 = ADC1_CH6 | |
#define VOLTAGE_DIVIDER_RATIO 2.0 // 47kΩ / (47kΩ + 47kΩ) = 0.5 (so 1/0.5 = 2.0) | |
#define ADC_SAMPLES 20 // Must be odd number for true median | |
#define VOLTAGE_OFFSET 0.2463 // Offset for calibration |
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
/* -------------------------------------------------------------------------- */ | |
/* ModuleMore RS-LDO-N01-1 (Modbus) Example code */ | |
/* -------------------------------------------------------------------------- */ | |
/* ------------------------------- วิธีการต่อ ------------------------------- */ | |
/** | |
| ESP32 | 12V Adapter | MAX485 | DO RS485 | | |
|-------|-------------|--------|----------| | |
| GND | GND | GND | Black | | |
| 3.3V | | VCC | | |
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 <Arduino.h> | |
/* Get all possible data from MPU6050 | |
* Accelerometer values are given as multiple of the gravity [1g = 9.81 m/s²] | |
* Gyro values are given in deg/s | |
* Angles are given in degrees | |
* Note that X and Y are tilt angles and not pitch/roll. | |
* | |
* License: MIT | |
*/ |
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 <Arduino.h> | |
#include <SoftwareSerial.h> | |
#include <TinyGPSPlus.h> | |
EspSoftwareSerial::UART gpsSerial; | |
TinyGPSPlus gps; | |
static void smartDelay(unsigned long ms); |
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 <Arduino.h> | |
#include <SoftwareSerial.h> | |
#include <TinyGPSPlus.h> | |
EspSoftwareSerial::UART gpsSerial; | |
TinyGPSPlus gps; | |
void displayInfo(); |
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 <Arduino.h> | |
#include <SoftwareSerial.h> | |
/* | |
lib_deps = | |
plerup/EspSoftwareSerial @ ^8.2.0 | |
tinyu-zhao/TinyGPSPlus-ESP32 @ ^0.0.2 | |
*/ | |
EspSoftwareSerial::UART gpsSerial; |
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 <Arduino.h> | |
#include <QMC5883LCompass.h> | |
/* | |
lib: mprograms/QMC5883LCompass @ ^1.2.3 | |
*/ |
NewerOlder