Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <Servo.h>
- #include <LiquidCrystal.h>
- #include <OneWire.h>
- #include <DallasTemperature.h>
- // Data wire is plugged into port 2 on the Arduino
- #define ONE_WIRE_BUS 7
- // Setup a oneWire instance to communicate with any OneWire devices (not just Maxim/Dallas temperature ICs)
- OneWire oneWire(ONE_WIRE_BUS);
- // Pass our oneWire reference to Dallas Temperature.
- DallasTemperature sensors(&oneWire);
- LiquidCrystal lcd(12, 11, 5, 4, 3, 2); //sets the LCD pins
- int teplota = 0;
- Servo servo_9;
- void setup()
- {
- Serial.begin(9600);//begins serial interface
- lcd.begin(16, 2);
- lcd.setCursor(0, 0);
- lcd.print("Teplomer");
- sensors.begin();
- servo_9.attach(9, 500, 2500);
- pinMode(6, OUTPUT);
- }
- void loop()
- {
- sensors.requestTemperatures();
- teplota = sensors.getTempCByIndex(0);
- Serial.println(teplota);
- lcd.setCursor(0, 1);
- lcd.print(teplota);
- lcd.print(" C ");
- if (teplota > 80) {
- servo_9.write(1);
- } else {
- if (teplota <= 80) {
- servo_9.write(10);
- } else {
- servo_9.write(0);
- }
- if (teplota <= 78) {
- servo_9.write(20);
- }
- if (teplota <= 75) {
- servo_9.write(35);
- }
- if (teplota <= 73) {
- servo_9.write(45);
- }
- if (teplota <= 70) {
- servo_9.write(50);
- }
- if (teplota <= 65) {
- servo_9.write(80);
- }
- }
- if (teplota < 60) {
- analogWrite(6, 20);
- } else {
- analogWrite(6, 0);
- }
- delay(500);
- }
Add Comment
Please, Sign In to add comment