Advertisement
pleasedontcode

Scanner rev_91

Nov 2nd, 2023
64
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 Mega
  14.     - Source Code created on: 2023-11-02 18:44:03
  15.     - Source Code generated by: AlexWind
  16.  
  17. ********* Pleasedontcode.com **********/
  18.  
  19. /********* User code review feedback **********
  20. #### Feedback 1 ####
  21. - is missing also to pass data from dsfgds to seril
  22. #### Feedback 2 ####
  23. - put also this requirement: "Use seril and dsfgds to pass TX and
  24. RX data in opposite way."
  25. ********* User code review feedback **********/
  26.  
  27. /****** DEFINITION OF LIBRARIES *****/
  28. #include <Arduino.h>
  29. #include <SoftwareSerial.h>
  30.  
  31. /****** SYSTEM REQUIREMENT 1 *****/
  32. /* Use seril and dsfgds to pass TX and RX data */
  33. /* between them. */
  34.  
  35. /****** FUNCTION PROTOTYPES *****/
  36. void setup(void);
  37. void loop(void);
  38.  
  39. /***** DEFINITION OF Software Serial *****/
  40. const uint8_t seril_PIN_SERIAL_TX_A0 = A0;
  41. const uint8_t seril_PIN_SERIAL_RX_D6 = 6;
  42. const uint8_t dsfgds_PIN_SERIAL_TX_A1 = A1;
  43. const uint8_t dsfgds_PIN_SERIAL_RX_A3 = A3;
  44. SoftwareSerial seril(seril_PIN_SERIAL_RX_D6, seril_PIN_SERIAL_TX_A0);
  45. SoftwareSerial dsfgds(dsfgds_PIN_SERIAL_RX_A3, dsfgds_PIN_SERIAL_TX_A1);
  46.  
  47. /****** SUBSYSTEM REQUIREMENT 1 *****/
  48. /* Initialize seril and dsfgds software serial ports */
  49. void initializeSerialPorts() {
  50.   seril.begin(300);
  51.   dsfgds.begin(300);
  52. }
  53.  
  54. /****** SUBSYSTEM REQUIREMENT 2 *****/
  55. /* Read data from seril and write it to dsfgds */
  56. void passData() {
  57.   if (seril.available()) {
  58.     char data = seril.read();
  59.     dsfgds.write(data);
  60.   }
  61.  
  62.   if (dsfgds.available()) {
  63.     char data = dsfgds.read();
  64.     seril.write(data);
  65.   }
  66. }
  67.  
  68. void setup(void) {
  69.   // put your setup code here, to run once:
  70.   initializeSerialPorts();
  71. }
  72.  
  73. void loop(void) {
  74.   // put your main code here, to run repeatedly:
  75.   passData();
  76. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement