Advertisement
pleasedontcode

Button Display rev_01

Dec 9th, 2023
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. /********* Pleasedontcode.com **********
  2.  
  3.     Pleasedontcode thanks you for automatic code generation! Enjoy your code!
  4.  
  5.     - Terms and Conditions:
  6.     You have a non-exclusive, revocable, worldwide, royalty-free license
  7.     for personal and commercial use. Attribution is optional; modifications
  8.     are allowed, but you're responsible for code maintenance. We're not
  9.     liable for any loss or damage. For full terms,
  10.     please visit pleasedontcode.com/termsandconditions.
  11.  
  12.     - Project: Button Display
  13.     - Source Code compiled for: Arduino Uno
  14.     - Source Code created on: 2023-12-09 14:24:34
  15.  
  16. ********* Pleasedontcode.com **********/
  17.  
  18. /****** SYSTEM REQUIREMENTS *****/
  19. /****** SYSTEM REQUIREMENT 1 *****/
  20.     /* At the transmitter arduino side nrf24l01 module */
  21.     /* with DS18B20 waterproof transmitter should send */
  22.     /* data to the Receiver side with lcd display */
  23.     /* Receiver should receive and display it on LCD */
  24. /****** END SYSTEM REQUIREMENTS *****/
  25.  
  26. /****** DEFINITION OF LIBRARIES *****/
  27. #include <Arduino.h>
  28. #include <EasyButton.h>
  29. #include <Wire.h>
  30. #include <LiquidCrystal_I2C.h>
  31.  
  32. /****** FUNCTION PROTOTYPES *****/
  33. void setup(void);
  34. void loop(void);
  35.  
  36. /***** DEFINITION OF DIGITAL INPUT PINS *****/
  37. const uint8_t NRF24_MODULE_PUSHBUTTON_PIN_D2 = 2;
  38. const uint8_t NRF24_MODULE_PUSHBUTTON_PIN_D3 = 3;
  39. const uint8_t NRF24_MODULE_PUSHBUTTON_PIN_D4 = 4;
  40.  
  41. /****** DEFINITION OF LIBRARIES CLASS INSTANCES*****/
  42. EasyButton buttonD2(NRF24_MODULE_PUSHBUTTON_PIN_D2);
  43. EasyButton buttonD3(NRF24_MODULE_PUSHBUTTON_PIN_D3);
  44. EasyButton buttonD4(NRF24_MODULE_PUSHBUTTON_PIN_D4);
  45.  
  46. LiquidCrystal_I2C lcd(0x27, 16, 2); // Initialize the LCD object with I2C address 0x27, 16 columns and 2 rows
  47.  
  48. void setup(void)
  49. {
  50.   // put your setup code here, to run once:
  51.   lcd.begin(16, 2); // Initialize the LCD
  52.   lcd.print("Receiver Setup"); // Display a message on the LCD
  53.  
  54.   pinMode(NRF24_MODULE_PUSHBUTTON_PIN_D2, INPUT_PULLUP);
  55.   pinMode(NRF24_MODULE_PUSHBUTTON_PIN_D3, INPUT_PULLUP);
  56.   pinMode(NRF24_MODULE_PUSHBUTTON_PIN_D4, INPUT_PULLUP);
  57. }
  58.  
  59. void loop(void)
  60. {
  61.   // put your main code here, to run repeatedly:
  62.  
  63.   // Button D2
  64.   buttonD2.read();
  65.  
  66.   if (buttonD2.wasPressed()) {
  67.     lcd.clear();
  68.     lcd.setCursor(0, 0);
  69.     lcd.print("Button D2 Pressed"); // Display a message on the LCD when button D2 is pressed
  70.   }
  71.  
  72.   // Button D3
  73.   buttonD3.read();
  74.  
  75.   if (buttonD3.wasPressed()) {
  76.     lcd.clear();
  77.     lcd.setCursor(0, 0);
  78.     lcd.print("Button D3 Pressed"); // Display a message on the LCD when button D3 is pressed
  79.   }
  80.  
  81.   // Button D4
  82.   buttonD4.read();
  83.  
  84.   if (buttonD4.wasPressed()) {
  85.     lcd.clear();
  86.     lcd.setCursor(0, 0);
  87.     lcd.print("Button D4 Pressed"); // Display a message on the LCD when button D4 is pressed
  88.   }
  89. }
  90.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement