Advertisement
pleasedontcode

COT1 rev_01

Oct 22nd, 2023
70
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: COT1
  13.     - Source Code compiled for: Arduino Uno
  14.     - Source Code created on: 2023-10-22 11:58:22
  15.     - Source Code generated by: Shadrack
  16.  
  17. ********* Pleasedontcode.com **********/
  18. /****** DEFINITION OF LIBRARIES *****/
  19. #include <Arduino.h>
  20.  
  21. /****** SYSTEM REQUIREMENT 1 *****/
  22. /* Increase intensity of led when potentiometer is */
  23. /* tuned respectively */
  24.  
  25. /****** FUNCTION PROTOTYPES *****/
  26. void setup(void);
  27. void loop(void);
  28.  
  29. /***** DEFINITION OF ANALOG INPUT PINS *****/
  30. const uint8_t Potent_Potentiometer_Vout_PIN_A0 = A0; // Define analog input pin A0 for potentiometer
  31.  
  32. /***** DEFINITION OF DIGITAL OUTPUT PINS *****/
  33. const uint8_t Led_LED_PIN_D2 = 2; // Define digital output pin D2 for LED
  34.  
  35. void setup(void)
  36. {
  37.   // put your setup code here, to run once:
  38.  
  39.   pinMode(Potent_Potentiometer_Vout_PIN_A0, INPUT); // Set A0 pin as input
  40.   pinMode(Led_LED_PIN_D2, OUTPUT); // Set D2 pin as output
  41. }
  42.  
  43. void loop(void)
  44. {
  45.   // put your main code here, to run repeatedly:
  46.   int potValue = analogRead(Potent_Potentiometer_Vout_PIN_A0); // Read the analog value from the potentiometer
  47.  
  48.   // Map the potentiometer value to the LED intensity range (0-255)
  49.   int ledIntensity = map(potValue, 0, 1023, 0, 255);
  50.  
  51.   analogWrite(Led_LED_PIN_D2, ledIntensity); // Set the LED intensity based on the potentiometer value
  52.  
  53.   delay(10); // Delay for stability
  54. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement