DS18B20
![]() กดเพื่อขยายขนาด |
|
IC DS18B20
ไอซี DS18B20
ไอซีวัดอุณหภูมิ
โค๊ดตัวอย่าง
-
#include <OneWire.h>
-
#include <DallasTemperature.h>
-
-
// Define the pin connected to the DS18B20 sensor
-
#define ONE_WIRE_BUS 2
-
-
// Setup a oneWire instance to communicate with any OneWire devices
-
OneWire oneWire(ONE_WIRE_BUS);
-
-
// Pass the oneWire reference to DallasTemperature library
-
DallasTemperature sensors(&oneWire);
-
-
void setup() {
-
// Start serial communication
-
Serial.begin(9600);
-
-
// Initialize the DS18B20 sensor
-
sensors.begin();
-
}
-
-
void loop() {
-
// Call sensors.requestTemperatures() to issue a global temperature
-
// request to all connected devices on the bus
-
sensors.requestTemperatures();
-
-
// Read the temperature from the DS18B20 sensor
-
float temperatureC = sensors.getTempCByIndex(0);
-
-
// Print the temperature to the serial monitor
-
Serial.print("Temperature: ");
-
Serial.print(temperatureC);
-
Serial.println("°C");
-
-
// Wait for a second before taking the next temperature reading
-
delay(1000);
-
}
-

Share
สินค้าที่เกี่ยวข้อง
![]() 74HC595 74HC595 5.00 บาท |
![]() LM7812 lm7812 ( LMH7812 ) LM7812-TO3 45.00 บาท |
![]() SN74HC132N SN74HC132N 14.00 บาท |
![]() PIC16F877A-I/P PIC16F877A-I/P 200.00 บาท |
![]() SN74HC541N SN74HC541N 15.00 บาท |
![]() 74HC540N IC 74HC540N 30.00 บาท |
![]() 74HC03D IC 74HC03D 9.00 บาท |
![]() DS1307 IC DS1307 10.00 บาท |
![]() LM393 IC LM393 10.00 บาท |
![]() CH340G USB to serial IC CH340G 20.00 บาท |
![]() A3144 HALL-EFFECT SWITCHES IC A3144 8.00 บาท |
![]() LM386 IC LM386 5.00 บาท |
![]() 7915 IC 7915 10.00 บาท |
![]() HD74LS32 IC HD74LS32 14.00 บาท |
เขียนความคิดเห็น
ชื่อ:
ความคิดเห็น: คำแนะนำ: HTML จะไม่ถูกแปลง!
ความนิยม: แย่ ดี
ป้อนรหัสในกล่องข้างล่างนี้:

ความคิดเห็น: คำแนะนำ: HTML จะไม่ถูกแปลง!
ความนิยม: แย่ ดี
ป้อนรหัสในกล่องข้างล่างนี้:
ไม่มีรูปภาพเพิ่มเติมสำหรับสินค้านี้