Advertisement
pleasedontcode

AnalemmaGPSArduino rev_01

Nov 16th, 2023
77
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: AnalemmaGPSArduino
  13.     - Source Code compiled for: Arduino Uno
  14.     - Source Code created on: 2023-11-16 19:32:24
  15.     - Source Code generated by: gianluca
  16.  
  17. ********* Pleasedontcode.com **********/
  18. /****** DEFINITION OF LIBRARIES *****/
  19. #include <Arduino.h>
  20. #include <Servo.h>
  21.  
  22. /****** SYSTEM REQUIREMENT 1 *****/
  23. /* Arduino must move the servo motor, every time the */
  24. /* GPS indicates that it is the tenth second */
  25.  
  26. /****** FUNCTION PROTOTYPES *****/
  27. void setup(void);
  28. void loop(void);
  29. void moveServo(void);
  30.  
  31. /***** DEFINITION OF PWM OUTPUT PINS *****/
  32. const uint8_t Servo_Servomotor_PWMSignal_PIN_D3 = 3;
  33.  
  34. /****** DEFINITION OF LIBRARIES CLASS INSTANCES*****/
  35. Servo myservo; // Instantiate the Servo class object
  36.  
  37. void setup(void)
  38. {
  39.   // put your setup code here, to run once:
  40.   myservo.attach(Servo_Servomotor_PWMSignal_PIN_D3); // Attach the servo motor to the PWM pin
  41. }
  42.  
  43. void loop(void)
  44. {
  45.   // put your main code here, to run repeatedly:
  46.   moveServo(); // Move the servo motor every tenth second
  47.   delay(1000); // Wait for one second
  48. }
  49.  
  50. void moveServo(void)
  51. {
  52.   // Check if it is the tenth second
  53.   if (millis() % 10000 == 0)
  54.   {
  55.     // Move the servo motor to a specific position
  56.     myservo.write(90); // Set the servo angle to 90 degrees
  57.     delay(500); // Wait for 500 milliseconds
  58.     myservo.write(0); // Set the servo angle to 0 degrees
  59.   }
  60. }
  61.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement