Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /********* Pleasedontcode.com **********
- Pleasedontcode thanks you for automatic code generation! Enjoy your code!
- - Terms and Conditions:
- You have a non-exclusive, revocable, worldwide, royalty-free license
- for personal and commercial use. Attribution is optional; modifications
- are allowed, but you're responsible for code maintenance. We're not
- liable for any loss or damage. For full terms,
- please visit pleasedontcode.com/termsandconditions.
- - Project: Temperature Display
- - Source Code compiled for: Arduino Uno
- - Source Code created on: 2023-12-09 14:43:01
- ********* Pleasedontcode.com **********/
- /****** SYSTEM REQUIREMENTS *****/
- /****** SYSTEM REQUIREMENT 1 *****/
- /* At the transmitter arduino side nrf24l01 module */
- /* with DS18B20 waterproof transmitter should send */
- /* data to the Receiver side with lcd display */
- /* Receiver should receive and display it on LCD */
- /****** END SYSTEM REQUIREMENTS *****/
- /****** DEFINITION OF LIBRARIES *****/
- #include <Arduino.h>
- #include <Wire.h>
- #include <DS18B20.h>
- #include <LiquidCrystal_I2C.h>
- /****** FUNCTION PROTOTYPES *****/
- void setup();
- void loop();
- void printTemperature();
- /***** DEFINITION OF DIGITAL INPUT PINS *****/
- const uint8_t DS18B20_DQ_PIN = 2;
- /***** DEFINITION OF I2C PINS *****/
- const uint8_t LCD_I2C_PIN_SDA = A4;
- const uint8_t LCD_I2C_PIN_SCL = A5;
- const uint8_t LCD_I2C_SLAVE_ADDRESS = 0x27;
- /****** DEFINITION OF LIBRARY CLASS INSTANCES*****/
- DS18B20 ds(DS18B20_DQ_PIN);
- LiquidCrystal_I2C lcd(LCD_I2C_SLAVE_ADDRESS, 16, 2);
- void setup()
- {
- // Initialize the digital input pin for DS18B20
- pinMode(DS18B20_DQ_PIN, INPUT);
- // Initialize the I2C communication
- Wire.begin();
- // Initialize the LCD display
- lcd.begin(16, 2);
- lcd.backlight();
- // Print initial message on LCD
- lcd.print("Receiver - NRF24L01");
- lcd.setCursor(0, 1);
- lcd.print("Waiting for data...");
- }
- void loop()
- {
- // Read temperature from DS18B20
- float temperature = ds.getTempC();
- // Display temperature on LCD
- lcd.clear();
- lcd.setCursor(0, 0);
- lcd.print("Temperature: ");
- lcd.print(temperature);
- lcd.print(" C");
- delay(2000);
- }
- void printTemperature()
- {
- // Read temperature from DS18B20
- float temperature = ds.getTempC();
- // Print temperature via serial
- Serial.print("Temperature: ");
- Serial.print(temperature);
- Serial.println(" C");
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement