Advertisement
pleasedontcode

LED Control rev_09

Jul 4th, 2025
240
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: LED Control
  13.     - Source Code NOT compiled for: Arduino Uno
  14.     - Source Code created on: 2025-07-05 00:38:05
  15.  
  16. ********* Pleasedontcode.com **********/
  17.  
  18. /****** SYSTEM REQUIREMENTS *****/
  19. /****** SYSTEM REQUIREMENT 1 *****/
  20.     /* blynk code */
  21. /****** END SYSTEM REQUIREMENTS *****/
  22.  
  23. /* START CODE */
  24.  
  25. /****** DEFINITION OF LIBRARIES *****/
  26. #include <Blynk.h>  //https://github.com/blynkkk/blynk-library
  27.  
  28. /****** FUNCTION PROTOTYPES *****/
  29. void setup(void);
  30. void loop(void);
  31. void updateOutputs();
  32.  
  33. /***** DEFINITION OF DIGITAL OUTPUT PINS *****/
  34. const uint8_t myLED_LED_PIN_D2 = 2;
  35.  
  36. /***** DEFINITION OF OUTPUT RAW VARIABLES *****/
  37. /***** used to store raw data *****/
  38. bool myLED_LED_PIN_D2_rawData = 0;
  39.  
  40. /***** DEFINITION OF OUTPUT PHYSICAL VARIABLES *****/
  41. /***** used to store data after characteristic curve transformation *****/
  42. float myLED_LED_PIN_D2_phyData = 0.0;
  43.  
  44. /****** DEFINITION OF LIBRARIES CLASS INSTANCES*****/
  45. // Initialize Blynk
  46. // Replace "YourAuthToken" with your actual Blynk Auth Token
  47. // For example: Blynk.begin("YourAuthToken");
  48. char auth[] = "YourAuthToken"; // <-- Replace with your actual token
  49.  
  50. // Create Blynk object
  51. // Using default constructor
  52. // The connection will be established in setup()
  53. Blynk Blynk;
  54.  
  55. /****** BLYNK VIRTUAL PIN HANDLERS *****/
  56. // Virtual pin V1 for toggling LED
  57. BLYNK_WRITE(V1)
  58. {
  59.     int value = param.asInt();
  60.     myLED_LED_PIN_D2_rawData = (value > 0);
  61. }
  62.  
  63. // Optional: Add a button to toggle the LED
  64. // Virtual pin V2 for reading the LED state
  65. BLYNK_READ(V2)
  66. {
  67.     Blynk.virtualWrite(V2, myLED_LED_PIN_D2_rawData);
  68. }
  69.  
  70. /* Setup function */
  71. void setup(void)
  72. {
  73.     // put your setup code here, to run once:
  74.     pinMode(myLED_LED_PIN_D2, OUTPUT);
  75.  
  76.     // Initialize serial for debugging
  77.     Serial.begin(9600);
  78.     // Connect to Blynk server
  79.     Blynk.begin(auth);
  80. }
  81.  
  82. /* Loop function */
  83. void loop(void)
  84. {
  85.     // Handle Blynk
  86.     Blynk.run();
  87.  
  88.     // Update outputs based on raw data
  89.     updateOutputs();
  90. }
  91.  
  92. /* Function to update physical outputs */
  93. void updateOutputs()
  94. {
  95.     digitalWrite(myLED_LED_PIN_D2, myLED_LED_PIN_D2_rawData);
  96. }
  97.  
  98. // END CODE
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement