Advertisement
pleasedontcode

myProject rev_47

Nov 13th, 2023
84
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: myProject
  13.     - Source Code compiled for: Arduino Uno
  14.     - Source Code created on: 2023-11-13 23:06:35
  15.     - Source Code generated by: Francesco Alessandro
  16.  
  17. ********* Pleasedontcode.com **********/
  18. /****** DEFINITION OF LIBRARIES *****/
  19. #include <Arduino.h>
  20.  
  21. /****** SYSTEM REQUIREMENT 1 *****/
  22. const int numInputs = 6; // Number of inputs required
  23.  
  24. /****** SYSTEM REQUIREMENT 2 *****/
  25. int inputs[numInputs]; // Array to store the inputs
  26.  
  27. /****** FUNCTION PROTOTYPES *****/
  28. void setup(void);
  29. void loop(void);
  30. void readInputs(void);
  31.  
  32. /***** DEFINITION OF DIGITAL INPUT PINS *****/
  33. const uint8_t data_PushButton_PIN_D2 = 2;
  34.  
  35. void setup(void)
  36. {
  37.   // put your setup code here, to run once:
  38.   pinMode(data_PushButton_PIN_D2, INPUT_PULLUP);
  39.   Serial.begin(9600); // Initialize serial communication
  40. }
  41.  
  42. void loop(void)
  43. {
  44.   // put your main code here, to run repeatedly:
  45.   readInputs(); // Call the function to read inputs
  46. }
  47.  
  48. void readInputs(void)
  49. {
  50.   Serial.print("Enter the amount of values: ");
  51.   while (Serial.available() == 0)
  52.   {
  53.     // Wait for user input
  54.   }
  55.   int amount = Serial.parseInt(); // Read the amount of values
  56.  
  57.   Serial.println("Please enter values for red light. Separate each value with a new line.");
  58.  
  59.   for (int i = 0; i < amount; i++)
  60.   {
  61.     while (Serial.available() == 0)
  62.     {
  63.       // Wait for user input
  64.     }
  65.     inputs[i] = Serial.parseInt(); // Read the input value
  66.   }
  67.  
  68.   // Print the inputs
  69.   Serial.println("Entered values:");
  70.   for (int i = 0; i < amount; i++)
  71.   {
  72.     Serial.println(inputs[i]);
  73.   }
  74. }
  75.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement