daily pastebin goal
63%
SHARE
TWEET

code_abm

a guest Mar 24th, 2019 60 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <Servo.h>
  2.  
  3. Servo myservo;  // create servo object to control a servo
  4. // twelve servo objects can be created on most boards
  5.  
  6. int pos = 10;    // variable to store the servo position
  7.  
  8. void setup() {
  9.   myservo.attach(9);  // attaches the servo on pin 9 to the servo object
  10. }
  11.  
  12. void loop() {
  13.   for (pos = 10; pos <= 120; pos += 1) { // goes from 0 degrees to 180 degrees
  14.     // in steps of 1 degree
  15.     myservo.write(pos);              // tell servo to go to position in variable 'pos'
  16.     delay(15);    // waits 15ms for the servo to reach the position
  17.   }
  18.  
  19.    for (pos = 10; pos <= 120; pos += 1) { // goes from 0 degrees to 180 degrees
  20.     // in steps of 1 degree
  21.     myservo.write(10);              // tell servo to go to position in variable 'pos'
  22.     delay(50);                       // waits 15ms for the servo to reach the position
  23.   }
  24. }
  25.  
  26. #include <DS3231.h>
  27.  
  28. // Init the DS3231 using the hardware interface
  29. DS3231  rtc(SDA, SCL);
  30.  
  31. void setup()
  32. {
  33.   // Setup Serial connection
  34.   Serial.begin(9600);
  35.   // Uncomment the next line if you are using an Arduino Leonardo
  36.   //while (!Serial) {}
  37.  
  38.   // Initialize the rtc object
  39.   rtc.begin();
  40.  
  41.   // The following lines can be uncommented to set the date and time
  42.   //rtc.setDOW(SUNDAY);     // Set Day-of-Week to SUNDAY
  43.   //rtc.setTime(07, 47, 20);     // Set the time to 12:00:00 (24hr format)
  44.   //rtc.setDate(24, 03, 2019);   // Set the date to March 23rd, 2019
  45. }
  46.  
  47. void loop()
  48. {
  49.   // Send Day-of-Week
  50.   Serial.print(rtc.getDOWStr());
  51.   Serial.print(" ");
  52.  
  53.   // Send date
  54.   Serial.print(rtc.getDateStr());
  55.   Serial.print(" -- ");
  56.  
  57.   // Send time
  58.   Serial.println(rtc.getTimeStr());
  59.  
  60.   // Wait one second before repeating :)
  61.   delay (1000);
  62. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top