Advertisement
pleasedontcode

"Reverse Counting" rev_01

Dec 4th, 2024
60
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: "Reverse Counting"
  13.     - Source Code NOT compiled for: Arduino Uno
  14.     - Source Code created on: 2024-12-04 16:27:35
  15.  
  16. ********* Pleasedontcode.com **********/
  17.  
  18. /****** SYSTEM REQUIREMENTS *****/
  19. /****** SYSTEM REQUIREMENT 1 *****/
  20.     /* A 4-bit dual reverse counter is to be implemented */
  21.     /* with the aid of JK master slave flip-flops. The */
  22.     /* following versions of  the counter are to be */
  23.     /* examined: */
  24. /****** END SYSTEM REQUIREMENTS *****/
  25.  
  26. /* START CODE */
  27.  
  28. /****** DEFINITION OF LIBRARIES *****/
  29. #include "JKFlipFlop.h" // Include the JK flip-flop library
  30. #include "Counter.h"    // Include the counter library
  31.  
  32. /****** FUNCTION PROTOTYPES *****/
  33. void setup(void);
  34. void loop(void);
  35.  
  36. // Instantiate JK flip-flops and counter objects
  37. JKFlipFlop jk1, jk2, jk3, jk4; // Create four JK flip-flop instances
  38. Counter counter;               // Create a counter instance
  39.  
  40. void setup(void)
  41. {
  42.     // Initialize the flip-flops and counter
  43.     jk1.initialize();
  44.     jk2.initialize();
  45.     jk3.initialize();
  46.     jk4.initialize();
  47.     counter.initialize();
  48. }
  49.  
  50. void loop(void)
  51. {
  52.     // Implement the reverse counting logic
  53.     counter.startReverseCount(); // Start the reverse counting process
  54.  
  55.     // Update the JK flip-flops based on the counter value
  56.     jk1.update(counter.getBit(0));
  57.     jk2.update(counter.getBit(1));
  58.     jk3.update(counter.getBit(2));
  59.     jk4.update(counter.getBit(3));
  60.  
  61.     // Add a delay for stability
  62.     delay(1000); // Delay for 1 second
  63. }
  64.  
  65. /* END CODE */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement