Advertisement
pleasedontcode

COT1 rev_03

Oct 29th, 2023
57
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-29 16:17:10
  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 brightness of led depending on */
  23.     /* potentiometer tuning */
  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;
  31.  
  32. /***** DEFINITION OF DIGITAL OUTPUT PINS *****/
  33. const uint8_t Led_LED_PIN_D2 = 2;
  34.  
  35. void setup(void)
  36. {
  37.     // Set the LED pin as an output
  38.     pinMode(Led_LED_PIN_D2, OUTPUT);
  39. }
  40.  
  41. void loop(void)
  42. {
  43.     // Read the potentiometer value
  44.     int potValue = analogRead(Potent_Potentiometer_Vout_PIN_A0);
  45.  
  46.     // Map the potentiometer value to the LED brightness range (0-255)
  47.     int brightness = map(potValue, 0, 1023, 0, 255);
  48.  
  49.     // Set the LED brightness
  50.     analogWrite(Led_LED_PIN_D2, brightness);
  51.  
  52.     // Delay for a short period of time
  53.     delay(10);
  54. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement