Advertisement
pleasedontcode

Scanner rev_84

Nov 2nd, 2023
63
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 17:51:41
  15.     - Source Code generated by: AlexWind
  16.  
  17. ********* Pleasedontcode.com **********/
  18. /****** DEFINITION OF LIBRARIES *****/
  19. #include <Arduino.h>
  20. #include <SoftwareSerial.h>
  21.  
  22. /****** SYSTEM REQUIREMENT 1 *****/
  23. /* Connect two serial ports together and duplicate on HW serial */
  24.  
  25. /****** FUNCTION PROTOTYPES *****/
  26. void setup(void);
  27. void loop(void);
  28.  
  29. /***** DEFINITION OF Software Serial *****/
  30. const uint8_t SERIAL_PIN_RX = 6; // Connect to RX pin of the other serial port
  31. const uint8_t SERIAL_PIN_TX = 7; // Connect to TX pin of the other serial port
  32. SoftwareSerial serialPort(SERIAL_PIN_RX, SERIAL_PIN_TX);
  33.  
  34. void setup(void)
  35. {
  36.   // put your setup code here, to run once:
  37.   Serial.begin(9600); // Initialize the serial monitor
  38.   serialPort.begin(9600); // Initialize the software serial port
  39. }
  40.  
  41. void loop(void)
  42. {
  43.   // put your main code here, to run repeatedly:
  44.   if (serialPort.available())
  45.   {
  46.     char data = serialPort.read(); // Read data from the software serial port
  47.     Serial.print("Received data: ");
  48.     Serial.println(data); // Print the received data to the serial monitor
  49.   }
  50. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement