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: **Count Display**
- - Source Code NOT compiled for: Arduino Uno
- - Source Code created on: 2025-06-17 14:14:58
- ********* Pleasedontcode.com **********/
- /****** SYSTEM REQUIREMENTS *****/
- /****** SYSTEM REQUIREMENT 1 *****/
- /* Écrire un programme pour un compteur modulo 24 */
- /* avec Var1 unité et var2 dizaine */
- /****** SYSTEM REQUIREMENT 2 *****/
- /* Créez un programme de comptage modulo 24 en */
- /* utilisant Var1 pour les unités et var2 pour les */
- /* dizaines et avec cathode commune */
- /****** END SYSTEM REQUIREMENTS *****/
- /* START CODE */
- /****** DEFINITION OF LIBRARIES *****/
- #include <Arduino.h>
- #include <Wire.h>
- /****** FUNCTION PROTOTYPES *****/
- void setup(void);
- void loop(void);
- // Define variables for units and tens
- int var1 = 0; // Units
- int var2 = 0; // Tens
- // Function to update the display (for demonstration purposes)
- void updateDisplay(int units, int tens) {
- // This function would contain code to update a 7-segment display
- // For example, using digitalWrite to light up segments
- }
- /****** SETUP FUNCTION *****/
- void setup(void)
- {
- // Initialize serial communication for debugging
- Serial.begin(9600);
- // Initialize display or other components as needed
- // For example: display.begin();
- }
- /****** LOOP FUNCTION *****/
- void loop(void)
- {
- // Increment the counter
- var1++;
- // Check if var1 exceeds 9 (units)
- if (var1 >= 10) {
- var1 = 0; // Reset units
- var2++; // Increment tens
- }
- // Check if var2 exceeds 2 (tens for modulo 24)
- if (var2 >= 3) {
- var2 = 0; // Reset tens
- }
- // Update the display with the current values
- updateDisplay(var1, var2);
- // Print the current count for debugging
- Serial.print("Count: ");
- Serial.print(var2);
- Serial.print(var1);
- Serial.println();
- // Delay for a while to make the counting visible
- delay(1000); // Adjust delay as necessary
- }
- /* END CODE */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement