Advertisement
pleasedontcode

**Count Display** rev_01

Jun 17th, 2025
414
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: **Count Display**
  13.     - Source Code NOT compiled for: Arduino Uno
  14.     - Source Code created on: 2025-06-17 14:14:58
  15.  
  16. ********* Pleasedontcode.com **********/
  17.  
  18. /****** SYSTEM REQUIREMENTS *****/
  19. /****** SYSTEM REQUIREMENT 1 *****/
  20.     /* Écrire un programme pour un compteur modulo 24 */
  21.     /* avec Var1 unité et var2 dizaine */
  22. /****** SYSTEM REQUIREMENT 2 *****/
  23.     /* Créez un programme de comptage modulo 24 en */
  24.     /* utilisant Var1 pour les unités et var2 pour les */
  25.     /* dizaines et avec cathode commune */
  26. /****** END SYSTEM REQUIREMENTS *****/
  27.  
  28. /* START CODE */
  29.  
  30. /****** DEFINITION OF LIBRARIES *****/
  31. #include <Arduino.h>
  32. #include <Wire.h>
  33.  
  34. /****** FUNCTION PROTOTYPES *****/
  35. void setup(void);
  36. void loop(void);
  37.  
  38. // Define variables for units and tens
  39. int var1 = 0; // Units
  40. int var2 = 0; // Tens
  41.  
  42. // Function to update the display (for demonstration purposes)
  43. void updateDisplay(int units, int tens) {
  44.     // This function would contain code to update a 7-segment display
  45.     // For example, using digitalWrite to light up segments
  46. }
  47.  
  48. /****** SETUP FUNCTION *****/
  49. void setup(void)
  50. {
  51.     // Initialize serial communication for debugging
  52.     Serial.begin(9600);
  53.    
  54.     // Initialize display or other components as needed
  55.     // For example: display.begin();
  56. }
  57.  
  58. /****** LOOP FUNCTION *****/
  59. void loop(void)
  60. {
  61.     // Increment the counter
  62.     var1++;
  63.    
  64.     // Check if var1 exceeds 9 (units)
  65.     if (var1 >= 10) {
  66.         var1 = 0; // Reset units
  67.         var2++; // Increment tens
  68.     }
  69.    
  70.     // Check if var2 exceeds 2 (tens for modulo 24)
  71.     if (var2 >= 3) {
  72.         var2 = 0; // Reset tens
  73.     }
  74.    
  75.     // Update the display with the current values
  76.     updateDisplay(var1, var2);
  77.    
  78.     // Print the current count for debugging
  79.     Serial.print("Count: ");
  80.     Serial.print(var2);
  81.     Serial.print(var1);
  82.     Serial.println();
  83.    
  84.     // Delay for a while to make the counting visible
  85.     delay(1000); // Adjust delay as necessary
  86. }
  87.  
  88. /* END CODE */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement