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 Control**
- - Source Code NOT compiled for: Arduino Uno
- - Source Code created on: 2024-12-06 14:36:34
- ********* Pleasedontcode.com **********/
- /****** SYSTEM REQUIREMENTS *****/
- /****** SYSTEM REQUIREMENT 1 *****/
- /* make the 7-segment display show the numbers 0 to 9 */
- /* with the for loop */
- /****** END SYSTEM REQUIREMENTS *****/
- /* START CODE */
- /****** DEFINITION OF LIBRARIES *****/
- /****** FUNCTION PROTOTYPES *****/
- void setup(void);
- void loop(void);
- // USER CODE START
- int segA = 1;
- int segB = 2;
- int segC = 3;
- int segD = 4;
- int segE = 5;
- int segF = 6;
- int segG = 7;
- // Array to represent the segments for numbers 0 to 9
- const int segmentMapping[10][7] = {
- {1, 1, 1, 1, 1, 1, 0}, // 0
- {0, 1, 0, 0, 0, 0, 0}, // 1
- {1, 1, 0, 1, 1, 0, 1}, // 2
- {1, 1, 1, 1, 0, 0, 1}, // 3
- {0, 1, 1, 0, 0, 1, 1}, // 4
- {1, 0, 1, 1, 0, 1, 1}, // 5
- {1, 0, 1, 1, 1, 1, 1}, // 6
- {1, 1, 0, 0, 0, 0, 0}, // 7
- {1, 1, 1, 1, 1, 1, 1}, // 8
- {1, 1, 1, 1, 0, 1, 1} // 9
- };
- // USER CODE END
- void setup(void)
- {
- // put your setup code here, to run once:
- pinMode(segA, OUTPUT);
- pinMode(segB, OUTPUT);
- pinMode(segC, OUTPUT);
- pinMode(segD, OUTPUT);
- pinMode(segE, OUTPUT);
- pinMode(segF, OUTPUT);
- pinMode(segG, OUTPUT);
- }
- void loop(void)
- {
- // put your main code here, to run repeatedly:
- for (int i = 0; i < 10; i++) { // Loop from 0 to 9
- // Set the segments according to the current number
- digitalWrite(segA, segmentMapping[i][0]);
- digitalWrite(segB, segmentMapping[i][1]);
- digitalWrite(segC, segmentMapping[i][2]);
- digitalWrite(segD, segmentMapping[i][3]);
- digitalWrite(segE, segmentMapping[i][4]);
- digitalWrite(segF, segmentMapping[i][5]);
- digitalWrite(segG, segmentMapping[i][6]);
- delay(1000); // Wait for 1 second before showing the next number
- }
- }
- /* END CODE */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement