Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <Servo.h>
- Servo myservo; // create servo object to control a servo
- // twelve servo objects can be created on most boards
- int pos = 10; // variable to store the servo position
- void setup() {
- myservo.attach(9); // attaches the servo on pin 9 to the servo object
- }
- void loop() {
- for (pos = 10; pos <= 120; pos += 1) { // goes from 0 degrees to 180 degrees
- // in steps of 1 degree
- myservo.write(pos); // tell servo to go to position in variable 'pos'
- delay(15); // waits 15ms for the servo to reach the position
- }
- for (pos = 10; pos <= 120; pos += 1) { // goes from 0 degrees to 180 degrees
- // in steps of 1 degree
- myservo.write(10); // tell servo to go to position in variable 'pos'
- delay(50); // waits 15ms for the servo to reach the position
- }
- }
- #include <DS3231.h>
- // Init the DS3231 using the hardware interface
- DS3231 rtc(SDA, SCL);
- void setup()
- {
- // Setup Serial connection
- Serial.begin(9600);
- // Uncomment the next line if you are using an Arduino Leonardo
- //while (!Serial) {}
- // Initialize the rtc object
- rtc.begin();
- // The following lines can be uncommented to set the date and time
- //rtc.setDOW(SUNDAY); // Set Day-of-Week to SUNDAY
- //rtc.setTime(07, 47, 20); // Set the time to 12:00:00 (24hr format)
- //rtc.setDate(24, 03, 2019); // Set the date to March 23rd, 2019
- }
- void loop()
- {
- // Send Day-of-Week
- Serial.print(rtc.getDOWStr());
- Serial.print(" ");
- // Send date
- Serial.print(rtc.getDateStr());
- Serial.print(" -- ");
- // Send time
- Serial.println(rtc.getTimeStr());
- // Wait one second before repeating :)
- delay (1000);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement