Skip to content

Instantly share code, notes, and snippets.

// ติดตั้งไลบารีที่นี่ https://github.com/sparkfun/SparkFun_MPU-9250-DMP_Arduino_Library/tree/master
// VCC - 5V
// GND - GND
// SDA - A4
// SCL - A5
#include <Wire.h>
#include <SparkFunMPU9250-DMP.h>
MPU9250_DMP imu;
#include <Wire.h>
#define ADXL345_ADDRESS (0x53) // ADXL345 accelerometer address
#define ITG3205_ADDRESS (0x68) // ITG3205 gyroscope address
#define HMC5883L_ADDRESS (0x1E) // HMC5883L magnetometer address
void setup() {
Serial.begin(9600);
Wire.begin();
#include <Wire.h>
#include "Adafruit_CCS811.h"
#include "Adafruit_HDC1000.h"
Adafruit_CCS811 ccs;
Adafruit_HDC1000 hdc;
void setup() {
Serial.begin(9600);
Serial.println("CCS811 HDC1080 Example");
// กำหนดขาที่เชื่อมต่อกับ E3F-DS300C1
const int sensorPin = 2; // แก้ไขตามขาที่คุณใช้
void setup() {
// กำหนดขาเป็นขานำเข้า
pinMode(sensorPin, INPUT);
// เปิด Serial Monitor
Serial.begin(9600);
}
#include <Wire.h>
#include <Adafruit_ADXL345_U.h>
Adafruit_ADXL345_Unified accel = Adafruit_ADXL345_Unified();
void setup() {
Serial.begin(9600);
if(!accel.begin()) {
Serial.println("Could not find a valid ADXL345 sensor, check wiring!");
while(1);
const int sensorPin = 2; // ต่อเข้ากับขาของ Infrared Barrier Tracking Module
int sensorStatus = 0; // ตัวแปรเก็บสถานะของเซนเซอร์
void setup() {
pinMode(sensorPin, INPUT); // กำหนดขา sensorPin เป็น INPUT
Serial.begin(9600); // เริ่มการสื่อสารผ่าน Serial ที่ความเร็ว 9600 bps
}
void loop() {
sensorStatus = digitalRead(sensorPin); // อ่านค่าจากเซนเซอร์
#include <Wire.h>
#include <LiquidCrystal_I2C.h>
/*
การต่อขาจอ LCD กับ UNO
VCC - 5V
GND - GND
SDA - A4
SCL - A5
การต่อขา Ultrasonic กับ UNO
#include <Wire.h>
#include <LiquidCrystal_I2C.h>
/*
การต่อขาจอ LCD กับ UNO
VCC - 5V
GND - GND
SDA - A4
SCL - A5
การต่อขา Ultrasonic กับ UNO
#include <Servo.h>
/*
การต่อขา Ultrasonic - Uno
VCC - 5V
GND - GND
Trig - 9
Echo - 8
การต่อขา Servo - Uno
สีแดง - 5V
const int relayPin = 8; // ขาที่ relay ต่อกับ Arduino
const int switchPin = 13; // ขาที่สวิตช์ต่อกับ Arduino
bool isPressed = false; // ตัวแปรเพื่อตรวจสอบการกดของสวิตช์
void setup() {
pinMode(relayPin, OUTPUT); // กำหนด relayPin เป็น OUTPUT
pinMode(switchPin, INPUT_PULLUP); // กำหนด switchPin เป็น INPUT พร้อมใช้ค่า resistance ภายใน
digitalWrite(relayPin, LOW); // กำหนดให้ relay ปิดอยู่ในตอนเริ่มต้น
}