Advertisement
pleasedontcode

**Communication Protocols** rev_01

Nov 4th, 2024
104
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: **Communication Protocols**
  13.     - Source Code NOT compiled for: Arduino Mega
  14.     - Source Code created on: 2024-11-04 14:07:30
  15.  
  16. ********* Pleasedontcode.com **********/
  17.  
  18. /****** SYSTEM REQUIREMENTS *****/
  19. /****** SYSTEM REQUIREMENT 1 *****/
  20.     /* print one time output. */
  21. /****** END SYSTEM REQUIREMENTS *****/
  22.  
  23. /* START CODE */
  24.  
  25. /****** DEFINITION OF LIBRARIES *****/
  26. #include <SPI.h>
  27. #include <Wire.h>
  28. #include <SoftwareSerial.h>
  29.  
  30. /****** FUNCTION PROTOTYPES *****/
  31. void setup(void);
  32. void loop(void);
  33.  
  34. /***** DEFINITION OF PWM OUTPUT PINS *****/
  35. const uint8_t out_PIN_D3        = 3;
  36.  
  37. /***** DEFINITION OF Hardware Serial *****/
  38. #define uarthw  Serial1 // TX_PIN: D18, RX_PIN: D19
  39.  
  40. /***** DEFINITION OF Software Serial *****/
  41. const uint8_t uartsw_PIN_SERIAL_TX_D4       = 4;
  42. const uint8_t uartsw_PIN_SERIAL_RX_A0       = A0;
  43. SoftwareSerial uartsw(uartsw_PIN_SERIAL_RX_A0, uartsw_PIN_SERIAL_TX_D4);
  44.  
  45. /***** DEFINITION OF I2C PINS *****/
  46. const uint8_t i2c_PIN_SDA_D20       = 20;
  47. const uint8_t i2c_PIN_SCL_D21       = 21;
  48.  
  49. /***** DEFINITION OF SPI PINS *****/
  50. const uint8_t spi_PIN_MOSI_D51      = 51;
  51. const uint8_t spi_PIN_MISO_D50      = 50;
  52. const uint8_t spi_PIN_SCLK_D52      = 52;
  53. const uint8_t spi_PIN_CS_D53        = 53;
  54.  
  55. /***** DEFINITION OF OUTPUT RAW VARIABLES *****/
  56. /***** used to store raw data *****/
  57. uint8_t out_PIN_D3_rawData      = 0;
  58.  
  59. /***** DEFINITION OF OUTPUT PHYSICAL VARIABLES *****/
  60. /***** used to store data after characteristic curve transformation *****/
  61. float   out_PIN_D3_phyData      = 0.0;
  62.  
  63. void setup(void)
  64. {
  65.     // put your setup code here, to run once:
  66.  
  67.     pinMode(out_PIN_D3,  OUTPUT);
  68.  
  69.     pinMode(spi_PIN_CS_D53,  OUTPUT);
  70.     // start the SPI library:
  71.     SPI.begin();
  72.  
  73.     uarthw.begin(300);
  74.  
  75.     uartsw.begin(300);
  76.  
  77.     // Print one-time output
  78.     Serial.begin(9600); // Initialize Serial for output
  79.     Serial.println("Setup complete. System is running."); // One-time output
  80. }
  81.  
  82. void loop(void)
  83. {
  84.     // put your main code here, to run repeatedly:
  85.  
  86.     updateOutputs(); // Refresh output data
  87.  
  88. }
  89.  
  90. void updateOutputs()
  91. {
  92.     analogWrite(out_PIN_D3, out_PIN_D3_rawData);
  93. }
  94.  
  95. /* END CODE */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement