Skip to content

Instantly share code, notes, and snippets.

View fxprime's full-sized avatar

ArduinoNa ขายอุปกรณ์ Arduino, เครื่องมือช่าง, raspberry pi, สอน ROS fxprime

View GitHub Profile
// Example code จาก www.arduinona.com
#include <Wire.h>
#include <LiquidCrystal_I2C.h>
// กำหนด Pin i2c สำหรับเชื่อมต่อกับหน้าจอ
LiquidCrystal_I2C lcd(0x27, 16, 2);
void setup()
{
// initialize ให้ LCD เริ่มสื่อสารกับบอร์ด
/*
ArduinoNa.com
อ่านค่า analog จาก pin A0-A2 และปริ้นค่าออกทาง Serial port
*/
int sensor_L , sensor_C , sensor_R ; //ตัวแปรไว้เก็บค่า sensor
String tmp ;
int ADC_stabilize = 5 ;
/*
www.arduinona.com
ตัวอย่างการต่อสาย AM2320 กับ Arduino Uno
โมดูล -> Arduino Uno
VCC -> 3.3-5V
GND -> GND
SCL -> A5
SDA -> A4
/*
www.arduinona.com
ตัวอย่างการสั่ง servo ให้หมุนตามค่าที่พิมพ์ลงใน Serial monitor
โดยต่อ Servo เข้ากับ arduino board ดังนี้
Servo -> Arduino (Uno)
แดง -> Vcc
ดำ -> Gnd
ขาว -> A0 ซึ่งตรงกับ pin number 14 ที่ใช้ในตัวอย่าง อ้างอิงจาก
https://i2.wp.com/marcusjenkins.com/wp-content/uploads/2014/06/ARDUINO_V2.png
/**
www.arduinoNa.com
ตัวอย่างcodeสำหรับเซนเซอร์ตรวจจับเปลวไฟ 5 หัว
**/
void setup() {
//เริ่มสื่อสารระหว่างคอมกับarduinoด้วยความเร็ว 115200 bps
Serial.begin(115200);
}
void loop() {
/**
* www.ArduinoNa.com
* ในตัวอย่างนี้ใช้ Library ของคุณ E. Kremer ซึ่งสามารถเพิ่มได้จาก
* Arduino IDE -> Tools -> Manage Libraries -> พิมพ์ว่า MAX6675
* เลือก MAX6675 with hardware SPI by Evgeny Kremer
*
* ต่อกับ arduino uno/pro mini
* sensor -> arduino uno/pro mini
* gnd -> gnd
* vcc -> vcc
/***************************************************************************************************/
/*
Example for 12-bit MAX6675 K-Thermocouple to Digital Converter with Cold Junction Compensation
written by : enjoyneering79
sourse code: https://github.com/enjoyneering/MAX6675
- MAX31855 maximum power supply voltage is 3.6v
- K-type thermocouples have an absolute accuracy of around ±2°C..±6°C.
- Measurement tempereture range -200°C..+700°C ±2°C or -270°C..+1372°C ±6°C
/**
* www.ArduinoNa.com
* ในตัวอย่างนี้ใช้ Library ของคุณ Avishay Orpaz ซึ่งสามารถเพิ่มได้จาก
* Arduino IDE -> Tools -> Manage Libraries -> พิมพ์ว่า TM1637
* เลือก TM1637 by Avishay Orpaz
**/
#include <TM1637Display.h>
#include <Arduino.h>
#include <TM1637Display.h>
// Module connection pins (Digital Pins)
#define CLK 3
#define DIO 2
// The amount of time (in milliseconds) between tests
#define TEST_DELAY 2000
/**
* www.ArduinoNa.com
* โหลด Library จาก Library manager บน arduino ide โดยเข้า arduino IDE
* คลิ๊ก Tool -> Manage libraries
* พิมพ์ MAX72XX เลือก MD_MAX72XX กด install
* ตัวอย่างการต่อ
* Arduino Nano - dot matrix
* pin 11 - DataIn
* pin 13 - CLK
* pin 10 - CS