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: ESC Control - Source Code NOT compiled for: Arduino Nano - Source Code created on: 2024-10-19 13:55:46 ********* Pleasedontcode.com **********/ /****** SYSTEM REQUIREMENTS *****/ /****** SYSTEM REQUIREMENT 1 *****/ /* code to control two escs connected to specify */ /* pins, start with calibration and arming for 30s */ /* then run the motors for 45s with 50% of speed */ /* after that turn off the motors */ /****** END SYSTEM REQUIREMENTS *****/ /****** DEFINITION OF LIBRARIES *****/ #include
//https://github.com/arduino-libraries/Servo /****** FUNCTION PROTOTYPES *****/ void setup(void); void loop(void); void updateOutputs(void); /***** DEFINITION OF PWM OUTPUT PINS *****/ const uint8_t esc1_PIN_D6 = 6; // Pin for ESC1 const uint8_t esc2_PIN_D9 = 9; // Pin for ESC2 /***** DEFINITION OF OUTPUT RAW VARIABLES *****/ /***** used to store raw data *****/ uint8_t esc1_PIN_D6_rawData = 0; uint8_t esc2_PIN_D9_rawData = 0; /****** DEFINITION OF LIBRARIES CLASS INSTANCES*****/ // Create Servo objects for each ESC Servo esc1; // Object for ESC1 Servo esc2; // Object for ESC2 void setup(void) { // Attach the Servo objects to the corresponding pins esc1.attach(esc1_PIN_D6); // Attach ESC1 to pin D6 esc2.attach(esc2_PIN_D9); // Attach ESC2 to pin D9 // Initialize ESCs for calibration and arming for (int i = 0; i < 30; i++) { // 30 seconds for calibration esc1.write(0); // Send minimum signal to ESC1 esc2.write(0); // Send minimum signal to ESC2 delay(1000); // Wait for 1 second } // After calibration, send a signal to arm the ESCs esc1.write(90); // Send a neutral signal to ESC1 esc2.write(90); // Send a neutral signal to ESC2 delay(2000); // Wait for 2 seconds to ensure ESCs are armed // Run the motors at 50% speed for 45 seconds for (int i = 0; i < 45; i++) { // 45 seconds esc1.write(127); // Set ESC1 to 50% speed esc2.write(127); // Set ESC2 to 50% speed delay(1000); // Wait for 1 second } // Turn off the motors esc1.write(0); // Send minimum signal to ESC1 esc2.write(0); // Send minimum signal to ESC2 } void loop(void) { // The loop function is empty as all actions are handled in setup } /* END CODE */
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)