Advertisement
pleasedontcode

MyFirstProject rev_01

Oct 18th, 2023
92
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: MyFirstProject
  13.     - Source Code compiled for: Arduino Uno
  14.     - Source Code created on: 2023-10-19 01:41:18
  15.     - Source Code generated by: MeetArbaz
  16.  
  17. ********* Pleasedontcode.com **********/
  18. /****** DEFINITION OF LIBRARIES *****/
  19. #include <Arduino.h>
  20. #include <Wire.h>
  21. #include <Adafruit_SSD1306.h>
  22.  
  23. /****** SYSTEM REQUIREMENT 1 *****/
  24. /* Make a form with two inputs: one for name and one for password, and add a submit button. */
  25.  
  26. /****** FUNCTION PROTOTYPES *****/
  27. void setup(void);
  28. void loop(void);
  29.  
  30. /***** DEFINITION OF I2C PINS *****/
  31. const uint8_t lcd_SSD1306OledDisplay_I2C_PIN_SDA_A4 = A4;
  32. const uint8_t lcd_SSD1306OledDisplay_I2C_PIN_SCL_A5 = A5;
  33. const uint8_t lcd_SSD1306OledDisplay_I2C_SLAVE_ADDRESS = 0x3C;
  34.  
  35. // Define the form inputs and submit button
  36. const int nameInputX = 40;
  37. const int nameInputY = 0;
  38. const int nameInputWidth = 80;
  39. const int nameInputHeight = 10;
  40. const int passwordInputX = 40;
  41. const int passwordInputY = 15;
  42. const int passwordInputWidth = 80;
  43. const int passwordInputHeight = 10;
  44. const int submitButtonX = 40;
  45. const int submitButtonY = 30;
  46. const int submitButtonWidth = 40;
  47. const int submitButtonHeight = 10;
  48.  
  49. // Variables to store the input values
  50. String nameInputValue = "";
  51. String passwordInputValue = "";
  52.  
  53. Adafruit_SSD1306 display(128, 64, &Wire, -1);
  54.  
  55. void setup(void)
  56. {
  57.   // Put your setup code here, to run once:
  58.   Wire.begin();
  59.   // Initialize the SSD1306 display with the I2C address
  60.   display.begin(SSD1306_SWITCHCAPVCC, lcd_SSD1306OledDisplay_I2C_SLAVE_ADDRESS);
  61.   display.display();
  62.   delay(2000);
  63.   display.clearDisplay();
  64. }
  65.  
  66. void loop(void)
  67. {
  68.   // Put your main code here, to run repeatedly:
  69.   // Display the form on the SSD1306 OLED display
  70.   display.setTextSize(1);
  71.   display.setTextColor(WHITE);
  72.  
  73.   // Draw the name input
  74.   display.setCursor(nameInputX, nameInputY);
  75.   display.println("Name:");
  76.   display.drawRect(nameInputX, nameInputY + 10, nameInputWidth, nameInputHeight, WHITE);
  77.   display.setCursor(nameInputX + 2, nameInputY + 12);
  78.   display.println(nameInputValue);
  79.  
  80.   // Draw the password input
  81.   display.setCursor(passwordInputX, passwordInputY);
  82.   display.println("Password:");
  83.   display.drawRect(passwordInputX, passwordInputY + 10, passwordInputWidth, passwordInputHeight, WHITE);
  84.   display.setCursor(passwordInputX + 2, passwordInputY + 12);
  85.   display.println(passwordInputValue);
  86.  
  87.   // Draw the submit button
  88.   display.drawRect(submitButtonX, submitButtonY, submitButtonWidth, submitButtonHeight, WHITE);
  89.   display.setCursor(submitButtonX + 2, submitButtonY + 2);
  90.   display.println("Submit");
  91.  
  92.   display.display();
  93.   delay(1000);
  94. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement