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 Automation
- - Source Code compiled for: Arduino Uno
- - Source Code created on: 2024-03-27 13:04:04
- ********* Pleasedontcode.com **********/
- /****** SYSTEM REQUIREMENTS *****/
- /****** SYSTEM REQUIREMENT 1 *****/
- /* Collegare il Bluetooth al display che permetta di */
- /* vedere l’ora con il sensore clook, poi il */
- /* Bluetooth verrà collegato al DFPlayer Mini che poi */
- /* verrà collegato allo speaker per far uscire il */
- /* suono, il Bluetooth verrà collegato anche alla */
- /* striscia led */
- /****** END SYSTEM REQUIREMENTS *****/
- /****** DEFINITION OF LIBRARIES *****/
- #include <SoftwareSerial.h>
- /****** FUNCTION PROTOTYPES *****/
- void setup(void);
- void loop(void);
- /***** DEFINITION OF Software Serial *****/
- const uint8_t Bluetooth_HC05_mySerial_PIN_SERIAL_TX_A0 = A0;
- const uint8_t Bluetooth_HC05_mySerial_PIN_SERIAL_RX_A1 = A1;
- SoftwareSerial Bluetooth_HC05_mySerial(Bluetooth_HC05_mySerial_PIN_SERIAL_RX_A1, Bluetooth_HC05_mySerial_PIN_SERIAL_TX_A0);
- // Define pin numbers for clock sensor, speaker, and LED strip
- const int clockSensorPin = 2;
- const int speakerPin = 3;
- const int ledStripPin = 4;
- void setup(void)
- {
- // Initialize Bluetooth communication
- Bluetooth_HC05_mySerial.begin(9600);
- // Set pin modes for other components
- pinMode(clockSensorPin, INPUT);
- pinMode(speakerPin, OUTPUT);
- pinMode(ledStripPin, OUTPUT);
- }
- void loop(void)
- {
- // Read the current time from the clock sensor
- int currentTime = digitalRead(clockSensorPin);
- // Send the current time to the Bluetooth display
- Bluetooth_HC05_mySerial.println(currentTime);
- // Play a sound using the speaker
- tone(speakerPin, 1000, 1000);
- // Change the color of the LED strip using Bluetooth commands
- if (Bluetooth_HC05_mySerial.available()) {
- char command = Bluetooth_HC05_mySerial.read();
- switch (command) {
- case 'R':
- // Red color command
- digitalWrite(ledStripPin, HIGH);
- break;
- case 'G':
- // Green color command
- digitalWrite(ledStripPin, LOW);
- break;
- case 'B':
- // Blue color command
- digitalWrite(ledStripPin, HIGH);
- delay(500);
- digitalWrite(ledStripPin, LOW);
- delay(500);
- break;
- }
- }
- }
- /* END CODE */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement