Advertisement
pleasedontcode

**Scoreboard Display** rev_01

Dec 2nd, 2024
25
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: **Scoreboard Display**
  13.     - Source Code NOT compiled for: Arduino Uno
  14.     - Source Code created on: 2024-12-02 11:36:29
  15.  
  16. ********* Pleasedontcode.com **********/
  17.  
  18. /****** SYSTEM REQUIREMENTS *****/
  19. /****** SYSTEM REQUIREMENT 1 *****/
  20.     /* i need a code that gathers information on a */
  21.     /* football match */
  22. /****** END SYSTEM REQUIREMENTS *****/
  23.  
  24. /* START CODE */
  25.  
  26. /****** DEFINITION OF LIBRARIES *****/
  27. #include <Wire.h>
  28. #include <SPI.h>
  29. #include <Servo.h>
  30. #include <LiquidCrystal.h>
  31.  
  32. /****** FUNCTION PROTOTYPES *****/
  33. void setup(void);
  34. void loop(void);
  35. void gatherMatchInfo(void);
  36.  
  37. /****** GLOBAL VARIABLES *****/
  38. String teamA = "Team A";
  39. String teamB = "Team B";
  40. int scoreA = 0;
  41. int scoreB = 0;
  42. unsigned long matchTime = 0; // in seconds
  43.  
  44. // LCD setup (assuming a 16x2 LCD)
  45. LiquidCrystal lcd(12, 11, 5, 4, 3, 2); // RS, E, D4, D5, D6, D7
  46.  
  47. void setup(void)
  48. {
  49.     // Initialize the LCD
  50.     lcd.begin(16, 2);
  51.     lcd.print("Match Info");
  52.     delay(2000);
  53.     lcd.clear();
  54.  
  55.     // Initialize Serial for debugging
  56.     Serial.begin(9600);
  57. }
  58.  
  59. void loop(void)
  60. {
  61.     // Gather match information
  62.     gatherMatchInfo();
  63.  
  64.     // Display the match information on the LCD
  65.     lcd.setCursor(0, 0);
  66.     lcd.print(teamA + ": " + String(scoreA));
  67.     lcd.setCursor(0, 1);
  68.     lcd.print(teamB + ": " + String(scoreB));
  69.  
  70.     // Simulate match time
  71.     matchTime++;
  72.     delay(1000); // Update every second
  73. }
  74.  
  75. // Function to gather match information
  76. void gatherMatchInfo(void)
  77. {
  78.     // Simulate score updates (for demonstration purposes)
  79.     if (matchTime % 10 == 0) { // Every 10 seconds
  80.         scoreA += random(0, 2); // Randomly score 0 or 1 for Team A
  81.         scoreB += random(0, 2); // Randomly score 0 or 1 for Team B
  82.         Serial.print("Score Update: ");
  83.         Serial.print(teamA);
  84.         Serial.print(" ");
  85.         Serial.print(scoreA);
  86.         Serial.print(" - ");
  87.         Serial.print(teamB);
  88.         Serial.println(scoreB);
  89.     }
  90. }
  91.  
  92. /* END CODE */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement