- /*
- Adafruit Arduino - Lesson 12. Light and Temperature
- */
- #include <LiquidCrystal.h>
- int tempPin = 0;
- int lightPin = 1;
- // BS E D4 D5 D6 D7
- LiquidCrystal lcd(7, 8, 9, 10, 11, 12);
- void setup()
- {
- lcd.begin(16, 2);
- }
- void loop()
- {
- // Display Temperature in C
- int tempReading = analogRead(tempPin);
- float tempVolts = tempReading * 5.0 / 1024.0;
- float tempC = (tempVolts - 0.5) * 100.0;
- float tempF = tempC * 9.0 / 5.0 + 32.0;
- // ----------------
- lcd.print("Temp F ");
- lcd.setCursor(6, 0);
- lcd.print(tempF);
- // Display Light on second row
- int lightReading = analogRead(lightPin);
- lcd.setCursor(0, 1);
- // ----------------
- lcd.print("Light ");
- lcd.setCursor(6, 1);
- lcd.print(lightReading);
- delay(500);
- }
วันอาทิตย์ที่ 15 กรกฎาคม พ.ศ. 2561
สมัครสมาชิก:
ส่งความคิดเห็น (Atom)
Internet of Things (IoT)
Internet of Things หรือ IoT Internet of Things (IoT) คือ การที่อุปกรณ์อิเล็กทรอนิกส์ต่างๆ สามารถเชื่อมโยงหรือส่งข้อมูลถึงกันได้ด้วยอิ...
-
Calculator with Pic 16f877 microcontroller is a comprehensive project. Comprehensive in the w...
-
Internet of Things หรือ IoT Internet of Things (IoT) คือ การที่อุปกรณ์อิเล็กทรอนิกส์ต่างๆ สามารถเชื่อมโยงหรือส่งข้อมูลถึงกันได้ด้วยอิ...
-
#include <LiquidCrystal_I2C.h> LiquidCrystal_I2C lcd(0x27,16,2); int PIRpin = 8; void setup() { lcd.begin(); pinMode(PIRpin,...

ไม่มีความคิดเห็น:
แสดงความคิดเห็น