Advertisement
pleasedontcode

Scanner rev_129

Nov 12th, 2023
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. /********* Pleasedontcode.com **********
  2.  
  3.     Pleasedontcode thanks you for automatic code generation! Enjoy your code!
  4.  
  5.     - Terms and Conditions:
  6.     You have a non-exclusive, revocable, worldwide, royalty-free license
  7.     for personal and commercial use. Attribution is optional; modifications
  8.     are allowed, but you're responsible for code maintenance. We're not
  9.     liable for any loss or damage. For full terms,
  10.     please visit pleasedontcode.com/termsandconditions.
  11.  
  12.     - Project: Scanner
  13.     - Source Code compiled for: Arduino Uno
  14.     - Source Code created on: 2023-11-12 17:06:49
  15.     - Source Code generated by: AlexWind
  16.  
  17. ********* Pleasedontcode.com **********/
  18.  
  19. /********* User code review feedback **********
  20. #### Feedback 1 ####
  21. - complete the code
  22. ********* User code review feedback **********/
  23.  
  24. /****** DEFINITION OF LIBRARIES *****/
  25. #include <Arduino.h>
  26. #include <SoftwareSerial.h>
  27.  
  28. /****** SYSTEM REQUIREMENT 1 *****/
  29. /* get hc05 signal and change PWM signal reducing */
  30. /* percentage if receiving DOWN data or increasing */
  31. /* percentage if receiving UP data. */
  32.  
  33. /****** FUNCTION PROTOTYPES *****/
  34. void setup(void);
  35. void loop(void);
  36.  
  37. /***** DEFINITION OF PWM OUTPUT PINS *****/
  38. const uint8_t activation_PIN_D3 = 3;
  39.  
  40. /***** DEFINITION OF Software Serial *****/
  41. const uint8_t bluetooth_HC05_mySerial_PIN_SERIAL_TX_A0 = A0;
  42. const uint8_t bluetooth_HC05_mySerial_PIN_SERIAL_RX_A1 = A1;
  43. SoftwareSerial bluetooth_HC05_mySerial(bluetooth_HC05_mySerial_PIN_SERIAL_RX_A1, bluetooth_HC05_mySerial_PIN_SERIAL_TX_A0);
  44.  
  45. void setup(void)
  46. {
  47.   // put your setup code here, to run once:
  48.   pinMode(activation_PIN_D3, OUTPUT);
  49.   bluetooth_HC05_mySerial.begin(9600);
  50. }
  51.  
  52. void loop(void)
  53. {
  54.   // put your main code here, to run repeatedly:
  55.   // Read data from HC05 module
  56.   if (bluetooth_HC05_mySerial.available()) {
  57.     char data = bluetooth_HC05_mySerial.read();
  58.     // Check if data is 'U' for UP or 'D' for DOWN
  59.     if (data == 'U') {
  60.       // Increase PWM signal percentage
  61.       // Add your code here
  62.       analogWrite(activation_PIN_D3, 200); // Example: Set PWM signal to 80% duty cycle
  63.     } else if (data == 'D') {
  64.       // Decrease PWM signal percentage
  65.       // Add your code here
  66.       analogWrite(activation_PIN_D3, 100); // Example: Set PWM signal to 40% duty cycle
  67.     }
  68.   }
  69. }
  70.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement