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: Servo Sweep - Source Code NOT compiled for: Arduino Uno - Source Code created on: 2024-07-02 21:38:55 ********* Pleasedontcode.com **********/ /****** SYSTEM REQUIREMENTS *****/ /****** SYSTEM REQUIREMENT 1 *****/ /* Design an Arduino system to manage two SG90 */ /* servomotors using PWM on pins D3 and D5. Leverage */ /* the Servo and ArduinoLearningBoard libraries. */ /* Include setup for pin initialization and a loop */ /* function to handle continuous motor position */ /* updates. */ /****** END SYSTEM REQUIREMENTS *****/ /****** DEFINITION OF LIBRARIES *****/ #define USE_ALB_Servo // Define to include the Servo functions of the ArduinoLearningBoard Library #include "ArduinoLearningBoard.h" // Include the main ArduinoLearningBoard library /****** FUNCTION PROTOTYPES *****/ void setup(void); void loop(void); /***** DEFINITION OF PWM OUTPUT PINS *****/ const uint8_t sg90_Servomotor_PWMSignal_PIN_D3 = 3; const uint8_t sg90_Servomotor_PWMSignal_PIN_D5 = 5; /***** DEFINITION OF OUTPUT RAW VARIABLES *****/ /***** used to store raw data *****/ uint8_t sg90_Servomotor_PWMSignal_PIN_D3_rawData = 0; uint8_t sg90_Servomotor_PWMSignal_PIN_D5_rawData = 0; /***** DEFINITION OF OUTPUT PHYSICAL VARIABLES *****/ /***** used to store data after characteristic curve transformation *****/ float sg90_Servomotor_PWMSignal_PIN_D3_phyData = 0.0; float sg90_Servomotor_PWMSignal_PIN_D5_phyData = 0.0; /****** DEFINITION OF LIBRARIES CLASS INSTANCES*****/ Servo servo1; // Create a Servo object for the first servo Servo servo2; // Create a Servo object for the second servo void setup(void) { // put your setup code here, to run once: pinMode(sg90_Servomotor_PWMSignal_PIN_D3, OUTPUT); pinMode(sg90_Servomotor_PWMSignal_PIN_D5, OUTPUT); servo1.attach(sg90_Servomotor_PWMSignal_PIN_D3); // Attach the first servo to pin D3 servo2.attach(sg90_Servomotor_PWMSignal_PIN_D5); // Attach the second servo to pin D5 } void loop(void) { // put your main code here, to run repeatedly: // Sweep the first servo for (int pos = 0; pos <= 180; pos += 1) { servo1.write(pos); // Move the first servo to the current position delay(15); // Wait for 15 milliseconds } for (int pos = 180; pos >= 0; pos -= 1) { servo1.write(pos); // Move the first servo to the current position delay(15); // Wait for 15 milliseconds } // Sweep the second servo for (int pos = 0; pos <= 180; pos += 1) { servo2.write(pos); // Move the second servo to the current position delay(15); // Wait for 15 milliseconds } for (int pos = 180; pos >= 0; pos -= 1) { servo2.write(pos); // Move the second servo to the current position delay(15); // Wait for 15 milliseconds } } /* 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)