Archives
Trending
Support
Login
clear text
XML
Django
JavaScript
MATLAB
C
C++
C#
Python
SQL
Shell
Bash
Markdown
YAML
JSON
HTML
CSS
PHP
Java
Ruby
Go
Rust
Swift
Kotlin
Arduino
TypeScript
Perl
Autohotkey
Lua
SQF
R
Scala
Haskell
Groovy
Dart
Clojure
VB.NET
Objective-C
PowerShell
Bash
CoffeeScript
Verilog
/********* Pleasedontcode.com ********** Pleasedontcode thanks you for automatic code generation! Enjoy your code! - Terms and Conditions: You have a non-exclusive, revocable, worldwide, royalty-free license for personal and commercial use. Attribution is optional; modifications are allowed, but you're responsible for code maintenance. We're not liable for any loss or damage. For full terms, please visit pleasedontcode.com/termsandconditions. - Project: "Digital Input & DAC" - Source Code compiled for: ESP32 DevKit V1 - Source Code created on: 2024-01-15 23:00:17 ********* Pleasedontcode.com **********/ /****** SYSTEM REQUIREMENTS *****/ /****** SYSTEM REQUIREMENT 1 *****/ /* if button is pressed so set out to 128. */ /****** SYSTEM REQUIREMENT 2 *****/ /* read gps from spi and generate sinusoide signal if */ /* position is moving. */ /****** END SYSTEM REQUIREMENTS *****/ /****** DEFINITION OF LIBRARIES *****/ #include
#include
#include
/****** FUNCTION PROTOTYPES *****/ void setup(void); void loop(void); void updateOutputs(void); /***** DEFINITION OF DIGITAL INPUT PINS *****/ const uint8_t butt_PushButton_PIN_D4 = 4; const uint8_t ditpullup_PIN_D14 = 14; const uint8_t ditpulldown_PIN_D16 = 16; const uint8_t temp_DS18B20_DQ_PIN_D13 = 13; /***** DEFINITION OF DAC OUTPUT PINS *****/ const uint8_t out_PIN_D25 = 25; /***** DEFINITION OF OUTPUT RAW VARIABLES *****/ /***** used to store raw data *****/ uint8_t out_PIN_D25_rawData = 0; /***** DEFINITION OF OUTPUT PHYSICAL VARIABLES *****/ /***** used to store data after characteristic curve transformation *****/ float out_PIN_D25_phyData = 0.0; /****** DEFINITION OF LIBRARIES CLASS INSTANCES*****/ EasyButton butt_PushButton(butt_PushButton_PIN_D4); OneWire oneWire(temp_DS18B20_DQ_PIN_D13); void setup(void) { // put your setup code here, to run once: pinMode(ditpullup_PIN_D14, INPUT_PULLUP); pinMode(ditpulldown_PIN_D16, INPUT_PULLDOWN); butt_PushButton.begin(); } void loop(void) { // put your main code here, to run repeatedly: butt_PushButton.read(); /****** SYSTEM REQUIREMENT 1 *****/ if (butt_PushButton.isPressed()) { out_PIN_D25_rawData = 128; } else { out_PIN_D25_rawData = 0; } /****** SYSTEM REQUIREMENT 2 *****/ // Read GPS from SPI and check if position is moving bool isMoving = false; // Replace with actual logic to determine if position is moving if (isMoving) { // Generate sinusoidal signal float amplitude = 100.0; // Replace with desired amplitude float frequency = 1.0; // Replace with desired frequency out_PIN_D25_phyData = amplitude * sin(frequency * millis() / 1000.0); out_PIN_D25_rawData = map(out_PIN_D25_phyData, -amplitude, amplitude, 0, 255); } else { out_PIN_D25_phyData = 0.0; out_PIN_D25_rawData = 0; } updateOutputs(); // Refresh output data } void updateOutputs(void) { dac_output_voltage(DAC_CHANNEL_1, out_PIN_D25_rawData); }
Mark as private (unlisted)
for 30 minutes
for 6 hours
for 1 day
for 1 week
for 1 month
for 1 year
everlasting (like CCCP)