Advertisement
pleasedontcode

**Pin Control** rev_01

Jun 2nd, 2025
617
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: **Pin Control**
  13.     - Source Code NOT compiled for: Arduino Uno
  14.     - Source Code created on: 2025-06-02 21:43:39
  15.  
  16. ********* Pleasedontcode.com **********/
  17.  
  18. /****** SYSTEM REQUIREMENTS *****/
  19. /****** SYSTEM REQUIREMENT 1 *****/
  20.     /* Turn this code into tinkercad block code */
  21. /****** END SYSTEM REQUIREMENTS *****/
  22.  
  23. /* START CODE */
  24.  
  25. /****** DEFINITION OF LIBRARIES *****/
  26. #include <Arduino.h>
  27. #include <Tinkercad.h> // Include Tinkercad library for block code functionality
  28.  
  29. /****** FUNCTION PROTOTYPES *****/
  30. void setup(void);
  31. void loop(void);
  32.  
  33. // USER CODE VARIABLES
  34. int i;
  35. int time = 100;
  36. int readSpeed;
  37.  
  38. void setup(void)
  39. {
  40.     // put your setup code here, to run once:
  41.     pinMode(A0, INPUT); // Set A0 as input for reading analog values
  42.     for(i = 1; i <= 13; i++)
  43.     {
  44.         pinMode(i, OUTPUT); // Set pins 1 to 13 as outputs
  45.     }
  46. }
  47.  
  48. void loop(void)
  49. {
  50.     // put your main code here, to run repeatedly:
  51.     // Start Turn On
  52.     for(i = 1; i <= 13; i++)    
  53.     {
  54.         readSpeed = analogRead(A0); // Read the analog value from A0
  55.         time = map(readSpeed, 0, 1023, 100, 1000); // Map the read value to a time delay
  56.         digitalWrite(i, HIGH); // Turn on the current pin
  57.         delay(time); // Wait for the mapped time
  58.     }
  59.     // Start Turn Off
  60.     for(i = 1; i <= 13; i++)    
  61.     {
  62.         readSpeed = analogRead(A0); // Read the analog value from A0
  63.         time = map(readSpeed, 0, 1023, 100, 500); // Map the read value to a time delay
  64.         digitalWrite(i, LOW); // Turn off the current pin
  65.         delay(time); // Wait for the mapped time
  66.     }
  67. }
  68.  
  69. /* END CODE */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement