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: "Display Voltage"
- - Source Code NOT compiled for: Arduino Nano
- - Source Code created on: 2025-01-11 11:11:26
- ********* Pleasedontcode.com **********/
- /****** SYSTEM REQUIREMENTS *****/
- /****** SYSTEM REQUIREMENT 1 *****/
- /* Misura tensione da 0V a 15Vcc con st7735 */
- /****** SYSTEM REQUIREMENT 2 *****/
- /* Measure voltage from 0V to 15V using the ST7789 */
- /* display for visual output. Ensure accurate */
- /* readings and display updates in real-time. Utilize */
- /* appropriate libraries for ST7789 integration and */
- /* voltage measurement. */
- /****** END SYSTEM REQUIREMENTS *****/
- /* START CODE */
- /****** DEFINITION OF LIBRARIES *****/
- #include <ST7789.h> // Include the ST7789 library for display
- #include <ADC.h> // Include the ADC library for voltage measurement
- /****** FUNCTION PROTOTYPES *****/
- void setup(void);
- void loop(void);
- // Create instances of the libraries
- ST7789 display = ST7789(); // Create an instance of the ST7789 display
- ADC adc = ADC(); // Create an instance of the ADC for voltage measurement
- void setup(void)
- {
- // Initialize the display
- display.init();
- display.setRotation(1); // Set the rotation of the display
- display.fillScreen(ST77XX_BLACK); // Clear the screen with black color
- // Initialize the ADC
- adc.begin(); // Start the ADC
- }
- void loop(void)
- {
- // Measure the voltage
- float voltage = adc.readVoltage(); // Read voltage from the ADC
- // Display the voltage on the ST7789 display
- display.setCursor(10, 10); // Set cursor position
- display.setTextColor(ST77XX_WHITE); // Set text color to white
- display.setTextSize(2); // Set text size
- display.print("Voltage: ");
- display.print(voltage); // Print the measured voltage
- display.print(" V");
- delay(1000); // Update every second
- }
- /* END CODE */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement