Advertisement
pleasedontcode

Arduino Setup rev_196

Jan 14th, 2024
73
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: Arduino Setup
  13.     - Source Code compiled for: ESP32 DevKit V1
  14.     - Source Code created on: 2024-01-14 16:39:03
  15.  
  16. ********* Pleasedontcode.com **********/
  17.  
  18. /****** SYSTEM REQUIREMENTS *****/
  19. /****** SYSTEM REQUIREMENT 1 *****/
  20.     /* if button is pressed so set out to 128. */
  21. /****** SYSTEM REQUIREMENT 2 *****/
  22.     /* read gps from spi and generate sinusoide signal if */
  23.     /* position is moving. */
  24. /****** END SYSTEM REQUIREMENTS *****/
  25.  
  26. /****** DEFINITION OF LIBRARIES *****/
  27. #include <Arduino.h>
  28. #include <SPI.h>
  29. #include <EasyButton.h>
  30.  
  31. /****** FUNCTION PROTOTYPES *****/
  32. void setup(void);
  33. void loop(void);
  34.  
  35. /***** DEFINITION OF DIGITAL INPUT PINS *****/
  36. const uint8_t butt_PushButton_PIN_D4 = 4;
  37. const uint8_t ditpullup_PIN_D14 = 14;
  38. const uint8_t ditpulldown_PIN_D16 = 16;
  39.  
  40. /***** DEFINITION OF DAC OUTPUT PINS *****/
  41. const uint8_t out_PIN_D25 = 25;
  42.  
  43. /***** DEFINITION OF SPI PINS *****/
  44. const uint8_t spi_PIN_MOSI_D23 = 23;
  45. const uint8_t spi_PIN_MISO_D19 = 19;
  46. const uint8_t spi_PIN_SCLK_D18 = 18;
  47. const uint8_t spi_PIN_CS_D5 = 5;
  48.  
  49. /****** DEFINITION OF LIBRARIES CLASS INSTANCES*****/
  50. EasyButton button(butt_PushButton_PIN_D4, true, true); // Instantiate the EasyButton object with the pin and enable pullup and inverted state
  51.  
  52. void setup(void)
  53. {
  54.   // put your setup code here, to run once:
  55.   pinMode(butt_PushButton_PIN_D4, INPUT_PULLUP);
  56.   pinMode(ditpullup_PIN_D14, INPUT_PULLUP);
  57.   pinMode(ditpulldown_PIN_D16, INPUT_PULLDOWN);
  58.  
  59.   pinMode(spi_PIN_CS_D5, OUTPUT);
  60.   // start the SPI library:
  61.   SPI.begin();
  62.  
  63.   button.begin(); // Initialize the button object
  64. }
  65.  
  66. void loop(void)
  67. {
  68.   // put your main code here, to run repeatedly:
  69.   button.read(); // Read the button state
  70.  
  71.   if (button.wasPressed()) {
  72.     // Button was pressed
  73.     // Add your code here
  74.     analogWrite(out_PIN_D25, 128); // Set the DAC output to 128
  75.   }
  76.  
  77.   // Read GPS data from SPI and generate sinusoidal signal if position is moving
  78.   // Add your code here
  79.  
  80.   delay(100); // Delay for stability
  81. }
  82.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement