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 "driver/gpio.h" | |
#include "driver/twai.h" | |
void setup() { | |
Serial.begin(115200); | |
twai_general_config_t g_config = { // สร้างต้วแปร g_config ใช้กำหนดค่าเกี่ยวกับบัส CAN | |
.mode = TWAI_MODE_NORMAL, | |
.tx_io = GPIO_NUM_26, // กำหนดขา TX ต่อกับ 26 | |
.rx_io = GPIO_NUM_27, // กำหนดขา TX ต่อกับ 27 |
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
const uint8_t io[] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 15, 18, 19, 20, 21, 22, 23 }; | |
void setup() { | |
for (int i=0;i<sizeof(io);i++) { | |
pinMode(io[i], OUTPUT); | |
} | |
} | |
void loop() { | |
for (int i=0;i<sizeof(io);i++) { |
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() { | |
pinMode(3, OUTPUT); // กำหนดขาเชื่อมต่อรีเลย์ (GPIO3) เป็นดิจิทัลเอาต์พุต | |
} | |
void loop() { | |
digitalWrite(3, HIGH); // สั่งรีเลย์ทำงาน | |
delay(1000); // หน่วงเวลา 1 วินาที (1000 mS) | |
digitalWrite(3, LOW); // สั่งรีเลย์หยุดทำงาน | |
delay(1000); // หน่วงเวลา 1 วินาที (1000 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
//Parameters | |
const int gp2y0a21Pin = A0; | |
//Variables | |
int gp2y0a21Val = 0; | |
void setup() { | |
//Init Serial USB | |
Serial.begin(9600); | |
Serial.println(F("Initialize System")); |
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
Alert.begin(<Room token>); // เริ่มต้นใช้ Am Alert กำหนด ROOM token |
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 <WiFi.h> // นำเข้าไลบรารี่ WiFi | |
const char* ssid = "your-ssid"; // ชื่อ WiFi | |
const char* password = "your-password"; // รหัสผ่าน WiFi | |
void setup() { | |
Serial.begin(115200); // เริ่มต้นใช้ Serial ที่ความเร็ว 115200 | |
while(!Serial){delay(100);} | |
// We start by connecting to a WiFi network |
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 <AmAlert.h> // นำเข้าไลบารี่ AmAlert |
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 <WiFi.h> // นำเข้าไลบรารี่ WiFi | |
#include <AmAlert.h> // นำเข้าไลบารี่ AmAlert | |
const char* ssid = "WiFi Name"; // ชื่อ WiFi | |
const char* password = "WiFi Password"; // รหัสผ่าน WiFi | |
#define ROOM_TOKEN "ROOM Token" // ROOM Token | |
#define PIR_PIN (27) // กำหนดขาต่อเซ็นเซอร์ PIR | |
void setup() { |
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
Am_Alert_Massage_Option_t option; // สร้างตัวแปร option | |
option.image.url = "https://img2.pic.in.th/pic/IMG20230921232431.jpeg"; // ลิ้งรูป ไฟล์ JPEG ขนาดไม่เกิน 2048×2048px | |
if (Alert.send("User ID/Group ID", "รถโดยขโมย", &option)) { // ส่งข้อความ "รถโดนขโมย" ไปที่ Am Alert | |
Serial.println("Send notify successful"); | |
} else { | |
Serial.printf("Send notify fail. check your token (code: %d)\n", Alert.status_code); | |
} |
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 <WiFiManager.h> // นำเข้าไลบรารี่ WiFiManager | |
#include <AmAlert.h> // นำเข้าไลบารี่ AmAlert | |
#define ROOM_TOKEN "your ROOM token" // Room Token | |
WiFiManager wm; | |
void setup() { | |
Serial.begin(115200); // เริ่มต้นใช้ Serial ที่ความเร็ว 115200 | |
NewerOlder