Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /********* Pleasedontcode.com **********
- Pleasedontcode thanks you for automatic code generation! Enjoy your code!
- - Terms and Conditions:
- You have a non-exclusive, revocable, worldwide, royalty-free license
- for personal and commercial use. Attribution is optional; modifications
- are allowed, but you're responsible for code maintenance. We're not
- liable for any loss or damage. For full terms,
- please visit pleasedontcode.com/termsandconditions.
- - Project: "Bluetooth LED Control"
- - Source Code compiled for: Arduino Uno
- - Source Code created on: 2024-03-27 13:06:14
- ********* Pleasedontcode.com **********/
- /****** SYSTEM REQUIREMENTS *****/
- /****** SYSTEM REQUIREMENT 1 *****/
- /* Striscia led cambiamento luminosità e controllo */
- /* tramite Bluetooth */
- /****** SYSTEM REQUIREMENT 2 *****/
- /* Collega un applicazione al circuito per inviare i */
- /* comandi */
- /****** END SYSTEM REQUIREMENTS *****/
- /****** DEFINITION OF LIBRARIES *****/
- #include <SoftwareSerial.h>
- /****** FUNCTION PROTOTYPES *****/
- void setup(void);
- void loop(void);
- /****** SYSTEM REQUIREMENTS *****/
- // SYSTEM REQUIREMENT 1: Striscia led cambiamento luminosità e controllo tramite Bluetooth
- const uint8_t LED_PIN = 9; // Pin connected to the LED strip
- // SYSTEM REQUIREMENT 2: Collega un applicazione al circuito per inviare i comandi
- const uint8_t Bluetooth_HC05_mySerial_PIN_SERIAL_TX_A0 = A0; // Bluetooth module TX pin connected to Arduino A0
- const uint8_t Bluetooth_HC05_mySerial_PIN_SERIAL_RX_A1 = A1; // Bluetooth module RX pin connected to Arduino A1
- SoftwareSerial Bluetooth_HC05_mySerial(Bluetooth_HC05_mySerial_PIN_SERIAL_RX_A1, Bluetooth_HC05_mySerial_PIN_SERIAL_TX_A0);
- void setup(void)
- {
- // put your setup code here, to run once:
- pinMode(LED_PIN, OUTPUT); // Set LED pin as output
- Bluetooth_HC05_mySerial.begin(9600); // Initialize Bluetooth serial communication
- }
- void loop(void)
- {
- // put your main code here, to run repeatedly:
- if (Bluetooth_HC05_mySerial.available()) {
- // Read the incoming command from Bluetooth
- char command = Bluetooth_HC05_mySerial.read();
- // Perform action based on the received command
- switch (command) {
- case '0': // Turn off the LED
- digitalWrite(LED_PIN, LOW);
- break;
- case '1': // Turn on the LED
- digitalWrite(LED_PIN, HIGH);
- break;
- default:
- break;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement