Bu projemizde amacımız iki adet LM35 sensöründen gelen sıcaklık verilerini 16X2 matix LCD üzerinde gösterimini yapacağız.
1 adet Arduino UNO
1 adet 16x2 LCD Display
2 adet LM35 sıcaklık sensörü
1 adet ayarlı direnç (LCD ekran ışığının ayarı için)
dirençler ve bağlantı kabloları
Bu proje daha önce yapıldığı için gerektiği kadar detaylı bilgi veremedim. Projenin yapım aşaması malesef yok. Sormak istediklerinizi yorumlara yazabilirsiniz.
Program
/*
LiquidCrystal Library - Hello World
Demonstrates the use a 16x2 LCD display. The LiquidCrystal
library works with all LCD displays that are compatible with the
Hitachi HD44780 driver. There are many of them out there, and you
can usually tell them by the 16-pin interface.
This sketch prints "Hello World!" to the LCD
and shows the time.
The circuit:
* LCD RS pin to digital pin 12
* LCD Enable pin to digital pin 11
* LCD D4 pin to digital pin 5
* LCD D5 pin to digital pin 4
* LCD D6 pin to digital pin 3
* LCD D7 pin to digital pin 2
* LCD R/W pin to ground
* LCD VSS pin to ground
* LCD VCC pin to 5V
* 10K resistor:
* ends to +5V and ground
* wiper to LCD VO pin (pin 3)
Library originally added 18 Apr 2008
by David A. Mellis
library modified 5 Jul 2009
by Limor Fried (http://www.ladyada.net)
example added 9 Jul 2009
by Tom Igoe
modified 22 Nov 2010
by Tom Igoe
This example code is in the public domain.
http://www.arduino.cc/en/Tutorial/LiquidCrystal
*/
// include the library code:
#include
#include
// initialize the library with the numbers of the interface pins
LiquidCrystal lcd(7, 8, 9, 10, 11, 12);
int sensorPin = A0; // select the input pin for the potentiometer
int sensorPin2 = A1; // select the input pin for the potentiometer
int sensorPinA5 = A5;
float sensorValue = 0; // variable to store the value coming from the sensor
float sensorValue2 = 0;
float sensorValue3 = 0; // variable to store the value coming from the sensor
int sensorPin3 = A2; // select the input pin for the potentiometer
int ledPin2 = 2; // select the pin for the LED
void setup() {
// set up the LCD's number of columns and rows:
lcd.begin(16, 2);
pinMode(sensorPin,INPUT);
pinMode(sensorPin2,INPUT);
// pinMode(sensorPin3,INPUT);
pinMode(ledPin2,OUTPUT);
digitalWrite(ledPin2, HIGH);
analogWrite(sensorPinA5, 255);
delay(1000);
}
void loop() {
// set the cursor to column 0, line 1
// (note: line 1 is the second row, since counting begins with 0):
sensorValue = analogRead(sensorPin);
sensorValue = (5.0 * sensorValue * 100.0) / 1024;
sensorValue = round(sensorValue*10)/10.0;
sensorValue2 = analogRead(sensorPin2);
sensorValue2 = (5.0 * sensorValue2 * 100.0) / 1024;
sensorValue2 = round(sensorValue2*10)/10.0;
//sensorValue3 = analogRead(sensorPin3);
// sensorValue3 = (9.0 * sensorValue3 * 100.0) / 1024;
// sensorValue3 = round(sensorValue3*10)/10.0;
// stop the program for for milliseconds:
if (sensorValue >= 25){
digitalWrite(ledPin2, LOW);
delay(1000);
}
if (sensorValue < 24){
digitalWrite(ledPin2, HIGH);
delay(1000);
}
lcd.setCursor(0,0);
lcd.print("1:");
lcd.setCursor(2,0);
lcd.print(sensorValue);
lcd.setCursor(0,1);
lcd.print("2:");
lcd.setCursor(2,1);
lcd.print(sensorValue2);
lcd.setCursor(9,0);
lcd.print("3:");
lcd.setCursor(11,0);
lcd.print(sensorValue3);
delay(500);
}
Hiç yorum yok:
Yorum Gönder