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: "Sensor Messaging"
- - Source Code NOT compiled for: Arduino Uno
- - Source Code created on: 2025-05-26 16:06:05
- ********* Pleasedontcode.com **********/
- /****** SYSTEM REQUIREMENTS *****/
- /****** SYSTEM REQUIREMENT 1 *****/
- /* generate the code for bluetooth sensor to send or */
- /* receive the data of flex sensor when flex is more */
- /* then high and low then bye and medium then nice to */
- /* meet you */
- /****** END SYSTEM REQUIREMENTS *****/
- /* START CODE */
- /****** DEFINITION OF LIBRARIES *****/
- #include <SoftwareSerial.h>
- /****** FUNCTION PROTOTYPES *****/
- void setup(void);
- void loop(void);
- void sendFlexSensorData(int flexValue);
- /***** DEFINITION OF Software Serial *****/
- const uint8_t YD_HC05_mySerial_PIN_SERIAL_TX_A2 = A2;
- const uint8_t YD_HC05_mySerial_PIN_SERIAL_RX_A3 = A3;
- SoftwareSerial YD_HC05_mySerial(YD_HC05_mySerial_PIN_SERIAL_RX_A3, YD_HC05_mySerial_PIN_SERIAL_TX_A2);
- void setup(void)
- {
- // Initialize the Bluetooth serial communication
- YD_HC05_mySerial.begin(9600);
- }
- void loop(void)
- {
- // Simulated flex sensor value for demonstration
- int flexSensorValue = analogRead(A0); // Read from an analog pin
- // Check the flex sensor value and send corresponding messages
- if (flexSensorValue > 700) { // High flex
- sendFlexSensorData(1); // Send "bye"
- } else if (flexSensorValue < 300) { // Low flex
- sendFlexSensorData(2); // Send "high"
- } else { // Medium flex
- sendFlexSensorData(3); // Send "nice to meet you"
- }
- delay(1000); // Delay for a second before the next reading
- }
- void sendFlexSensorData(int flexValue)
- {
- // Send messages based on flex value
- if (flexValue == 1) {
- YD_HC05_mySerial.println("bye");
- } else if (flexValue == 2) {
- YD_HC05_mySerial.println("high");
- } else if (flexValue == 3) {
- YD_HC05_mySerial.println("nice to meet you");
- }
- }
- /* END CODE */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement