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 Control"
- - Source Code NOT compiled for: Arduino Mega
- - Source Code created on: 2024-06-03 01:07:15
- ********* Pleasedontcode.com **********/
- /****** SYSTEM REQUIREMENTS *****/
- /****** SYSTEM REQUIREMENT 1 *****/
- /* Create a retro console on Arduino using */
- /* SoftwareSerial for dual Bluetooth HC-05 modules. */
- /* The system initializes serial communication at */
- /* 9600 baud for both modules, enabling wireless data */
- /* transfer. */
- /****** END SYSTEM REQUIREMENTS *****/
- /****** DEFINITION OF LIBRARIES *****/
- #include <SoftwareSerial.h>
- /****** FUNCTION PROTOTYPES *****/
- void setup(void);
- void loop(void);
- void updateOutputs(void);
- /***** DEFINITION OF DIGITAL OUTPUT PINS *****/
- const uint8_t myLED_RGB_LEDRGB_Red_PIN_D2 = 2;
- const uint8_t myLED_RGB_LEDRGB_Green_PIN_D3 = 3;
- const uint8_t myLED_RGB_LEDRGB_Blue_PIN_D4 = 4;
- /***** DEFINITION OF Software Serial *****/
- const uint8_t bluetooth_HC05_mySerial1_PIN_SERIAL_TX_A0 = A0;
- const uint8_t bluetooth_HC05_mySerial1_PIN_SERIAL_RX_A1 = A1;
- const uint8_t bluetooth_HC05_mySerial2_PIN_SERIAL_TX_A2 = A2;
- const uint8_t bluetooth_HC05_mySerial2_PIN_SERIAL_RX_A3 = A3;
- // Instantiate SoftwareSerial objects for both Bluetooth modules
- SoftwareSerial bluetooth_HC05_mySerial1(bluetooth_HC05_mySerial1_PIN_SERIAL_RX_A1, bluetooth_HC05_mySerial1_PIN_SERIAL_TX_A0);
- SoftwareSerial bluetooth_HC05_mySerial2(bluetooth_HC05_mySerial2_PIN_SERIAL_RX_A3, bluetooth_HC05_mySerial2_PIN_SERIAL_TX_A2);
- /***** DEFINITION OF OUTPUT RAW VARIABLES *****/
- /***** used to store raw data *****/
- bool myLED_RGB_LEDRGB_Red_PIN_D2_rawData = 0;
- bool myLED_RGB_LEDRGB_Green_PIN_D3_rawData = 0;
- bool myLED_RGB_LEDRGB_Blue_PIN_D4_rawData = 0;
- /***** DEFINITION OF OUTPUT PHYSICAL VARIABLES *****/
- /***** used to store data after characteristic curve transformation *****/
- float myLED_RGB_LEDRGB_Red_PIN_D2_phyData = 0.0;
- float myLED_RGB_LEDRGB_Green_PIN_D3_phyData = 0.0;
- float myLED_RGB_LEDRGB_Blue_PIN_D4_phyData = 0.0;
- void setup(void)
- {
- // put your setup code here, to run once:
- pinMode(myLED_RGB_LEDRGB_Red_PIN_D2, OUTPUT);
- pinMode(myLED_RGB_LEDRGB_Green_PIN_D3, OUTPUT);
- pinMode(myLED_RGB_LEDRGB_Blue_PIN_D4, OUTPUT);
- // Initialize both Bluetooth modules at 9600 baud
- bluetooth_HC05_mySerial1.begin(9600);
- bluetooth_HC05_mySerial2.begin(9600);
- }
- void loop(void)
- {
- // put your main code here, to run repeatedly:
- updateOutputs(); // Refresh output data
- // Example of reading from one Bluetooth module and writing to another
- if (bluetooth_HC05_mySerial1.available())
- {
- char data = bluetooth_HC05_mySerial1.read();
- bluetooth_HC05_mySerial2.write(data);
- }
- if (bluetooth_HC05_mySerial2.available())
- {
- char data = bluetooth_HC05_mySerial2.read();
- bluetooth_HC05_mySerial1.write(data);
- }
- }
- void updateOutputs()
- {
- digitalWrite(myLED_RGB_LEDRGB_Red_PIN_D2, myLED_RGB_LEDRGB_Red_PIN_D2_rawData);
- digitalWrite(myLED_RGB_LEDRGB_Green_PIN_D3, myLED_RGB_LEDRGB_Green_PIN_D3_rawData);
- digitalWrite(myLED_RGB_LEDRGB_Blue_PIN_D4, myLED_RGB_LEDRGB_Blue_PIN_D4_rawData);
- }
- /* END CODE */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement