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: Wireless Controller
- - Source Code NOT compiled for: Arduino Pro Mini 5V
- - Source Code created on: 2025-11-05 01:35:46
- ********* Pleasedontcode.com **********/
- /****** SYSTEM REQUIREMENTS *****/
- /****** SYSTEM REQUIREMENT 1 *****/
- /* Check if digital data is received from bluetooth */
- /* and and use this data into MCP4725. Read */
- /* currentAcquisition and send it via bluetooth. The */
- /* data to be send has to be integer. */
- /****** END SYSTEM REQUIREMENTS *****/
- /* START CODE */
- /****** DEFINITION OF LIBRARIES *****/
- #include <SoftwareSerial.h>
- #include <Wire.h>
- #include <Adafruit_MCP4725.h> //https://github.com/adafruit/Adafruit_MCP4725
- /****** FUNCTION PROTOTYPES *****/
- void setup(void);
- void loop(void);
- /***** DEFINITION OF ANALOG INPUT PINS *****/
- const uint8_t currentAcquisition_PIN_A0 = A0;
- /***** DEFINITION OF Software Serial *****/
- const uint8_t DX_BT27_Slave_HC05_mySerial_PIN_SERIAL_TX_A1 = A1;
- const uint8_t DX_BT27_Slave_HC05_mySerial_PIN_SERIAL_RX_A2 = A2;
- SoftwareSerial DX_BT27_Slave_HC05_mySerial(DX_BT27_Slave_HC05_mySerial_PIN_SERIAL_RX_A2, DX_BT27_Slave_HC05_mySerial_PIN_SERIAL_TX_A1);
- /***** DEFINITION OF I2C PINS *****/
- const uint8_t MCP4725_PIN_SDA_A4 = A4;
- const uint8_t MCP4725_PIN_SCL_A5 = A5;
- /****** DEFINITION OF ANALOG INPUTS CHARACTERISTIC CURVES *****/
- const uint8_t SEGMENT_POINTS_voltage_Current_PIN_A0 = 2;
- const float voltage_Current_PIN_A0_lookup[2][SEGMENT_POINTS_voltage_Current_PIN_A0] =
- {
- {0.0 , 5.0}, //Voltage [V]
- {0.0 , 500.0} //Current [A]
- };
- /****** DEFINITION OF LIBRARIES CLASS INSTANCES*****/
- Adafruit_MCP4725 dac;
- // Add a variable to hold received Bluetooth data
- int receivedData = 0; // Assume integer data
- void setup(void)
- {
- // put your setup code here, to run once:
- dac.begin(0x62);
- xSerial.begin(9600);
- Serial.begin(9600);
- }
- void loop(void)
- {
- // Read data from Bluetooth Serial if available
- if (DX_BT27_Slave_HC05_mySerial.available()) {
- // Read the incoming byte and convert to integer
- receivedData = DX_BT27_Slave_HC05_mySerial.parseInt();
- //Set the DAC voltage based on received data
- dac.setVoltage(receivedData, false);
- // Send back the currentAcquisition value
- Serial.print("Current Acquisition: ");
- Serial.println(receivedData);
- // Send the currentAcquisition via Bluetooth
- DX_BT27_Slave_HC05_mySerial.print("Current Acquisition: ");
- DX_BT27_Slave_HC05_mySerial.println(receivedData);
- }
- // Read the sensor value and potentially process it if needed
- //uint16_t sensorValue = analogRead(currentAcquisition_PIN_A0); // Not used directly here
- }
- /* END CODE */
Advertisement
Add Comment
Please, Sign In to add comment