Advertisement
pleasedontcode

myProject rev_48

Nov 15th, 2023
45
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-15 23:38:31
  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. /* I'm coding in Arduino and I'm trying to write a */
  23. /* code that will ask for a number of inputs and then */
  24. /* ask for each input individually. I set this */
  25. /* number to six for now. */
  26. const int numInputs = 6;
  27.  
  28. /****** SYSTEM REQUIREMENT 2 *****/
  29. /* I try entering in numbers but what happens is that */
  30. /* every time I enter a number, it puts in zero for */
  31. /* the next input without letting me choose: Ex: */
  32. /* `Enter the amount of values: Please enter values */
  33. /* for red light. Separate each value with a new */
  34. /* line. */
  35. int inputs[numInputs];
  36.  
  37. /****** FUNCTION PROTOTYPES *****/
  38. void setup(void);
  39. void loop(void);
  40.  
  41. /***** DEFINITION OF DIGITAL INPUT PINS *****/
  42. const uint8_t data_PushButton_PIN_D2 = 2;
  43.  
  44. void setup(void)
  45. {
  46.   // put your setup code here, to run once:
  47.   pinMode(data_PushButton_PIN_D2, INPUT_PULLUP);
  48.   Serial.begin(9600); // Initialize serial communication
  49. }
  50.  
  51. void loop(void)
  52. {
  53.   // put your main code here, to run repeatedly:
  54.   Serial.println("Enter the amount of values:");
  55.   while (!Serial.available()) {} // Wait for user input
  56.   int numValues = Serial.parseInt(); // Read the number of values
  57.  
  58.   Serial.println("Please enter values for red light. Separate each value with a new line:");
  59.   for (int i = 0; i < numInputs; i++) {
  60.     while (!Serial.available()) {} // Wait for user input
  61.     inputs[i] = Serial.parseInt(); // Read the input value
  62.   }
  63.  
  64.   // Print the entered values
  65.   Serial.println("Entered values:");
  66.   for (int i = 0; i < numInputs; i++) {
  67.     Serial.println(inputs[i]);
  68.   }
  69.  
  70.   delay(1000); // Wait for 1 second before repeating the loop
  71. }
  72.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement