Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /********* 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: AnalemmaGPSArduino
- - Source Code compiled for: Arduino Uno
- - Source Code created on: 2023-11-16 19:32:24
- - Source Code generated by: gianluca
- ********* Pleasedontcode.com **********/
- /****** DEFINITION OF LIBRARIES *****/
- #include <Arduino.h>
- #include <Servo.h>
- /****** SYSTEM REQUIREMENT 1 *****/
- /* Arduino must move the servo motor, every time the */
- /* GPS indicates that it is the tenth second */
- /****** FUNCTION PROTOTYPES *****/
- void setup(void);
- void loop(void);
- void moveServo(void);
- /***** DEFINITION OF PWM OUTPUT PINS *****/
- const uint8_t Servo_Servomotor_PWMSignal_PIN_D3 = 3;
- /****** DEFINITION OF LIBRARIES CLASS INSTANCES*****/
- Servo myservo; // Instantiate the Servo class object
- void setup(void)
- {
- // put your setup code here, to run once:
- myservo.attach(Servo_Servomotor_PWMSignal_PIN_D3); // Attach the servo motor to the PWM pin
- }
- void loop(void)
- {
- // put your main code here, to run repeatedly:
- moveServo(); // Move the servo motor every tenth second
- delay(1000); // Wait for one second
- }
- void moveServo(void)
- {
- // Check if it is the tenth second
- if (millis() % 10000 == 0)
- {
- // Move the servo motor to a specific position
- myservo.write(90); // Set the servo angle to 90 degrees
- delay(500); // Wait for 500 milliseconds
- myservo.write(0); // Set the servo angle to 0 degrees
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement