Skip navigation
2014
Andy Clark (Workshopshed)

RTC DS1307

Posted by Andy Clark (Workshopshed) Top Member Jan 28, 2014

I had a bit of a play with a run time clock module yesterday. It's an I2C device that I got as a cheap import from Hong Kong using the DS1307 chip.

Basically once you've got the right libary it's really simple to use, you don't even need to set the address, just set the date and time in code and read it back when you need it.

One of the key things to watch out for is some of these boards have a simple battery charge circuit so you'll need to use a LIR2032 not a CR2032.

 

Here's a bit more detail Workshopshed: Real Time Clock - DS1307

and the code I used https://github.com/Workshopshed/RTC_DS1307

I am trying to search for a code to couple the Centipede to the Arduino Mega2560, using the Cetipede 64 pin to work with a simple programme such as 1 input on the Mega and sequence of timings;

 

int pin2 = 2;
int pin3 = 3;
int pin4 = 4;
int pin5 = 5;
int pin6 = 6;
int pin7 = 7;
int pin8 = 8;
int pin9 = 9;
int pin10 = 10;
int pin11 = 11;
int pin12 = 12;
int pin13 = 13;
int pin14 = 14;
int pin15 = 15;
int pin16 = 16;
int pin17 = 17;
int pin18 = 18;
int pin19 = 19;
int pin20 = 20;
int pin21 = 21;
int pin22 = 22;
int pin23 = 23;
int pin24 = 24;
int pin25 = 25;
int timer1 = 500;
int timer2 = 500;
int timer3 = 500;
int val = 0;
int state = HIGH; // the current state of the output pin
int reading; // the current reading from the input pin
int previous = LOW; // the previous reading from the input pin
long time = 0; // the last time the output pin was toggled
long debounce = 200; // the debounce time, increase if the output flickers
int interval = 500;
void setup(){
pinMode(pin2, OUTPUT);
pinMode(pin3, OUTPUT);
pinMode(pin4, OUTPUT);
pinMode(pin5, OUTPUT);
pinMode(pin6, OUTPUT);
pinMode(pin7, OUTPUT);
pinMode(pin8, OUTPUT);
pinMode(pin9, OUTPUT);
pinMode(pin10, OUTPUT);
pinMode(pin11, OUTPUT);
pinMode(pin12, OUTPUT);
pinMode(pin13, OUTPUT);
pinMode(pin14, OUTPUT);
pinMode(pin15, OUTPUT);
pinMode(pin16, OUTPUT);
pinMode(pin17, OUTPUT);
pinMode(pin18, OUTPUT);
pinMode(pin19, OUTPUT);
pinMode(pin20, OUTPUT);
pinMode(pin21, OUTPUT);
pinMode(pin22, OUTPUT);
pinMode(pin23, OUTPUT);
pinMode(pin24, INPUT);
pinMode(pin25, INPUT);
}
void loop() {
reading = digitalRead(pin25);
// if the input just went from LOW and HIGH and we've waited long enough
// to ignore any noise on the circuit, toggle the output pin and remember
// the time
if (reading == HIGH && previous == LOW && millis() - time > debounce) {
// ... invert the output
if (state == HIGH)
state = LOW;
else
state = HIGH;
// ... and remember when the last button press was
time = millis();

digitalWrite(pin12, HIGH);
digitalWrite(pin10, HIGH);
delay(timer3);
digitalWrite(pin2, HIGH);
delay(timer1);

digitalWrite(pin3, HIGH);
delay(timer1);
digitalWrite(pin2, LOW);

digitalWrite(pin4, HIGH);
delay(timer1);
digitalWrite(pin3, LOW);

digitalWrite(pin5, HIGH);
delay(timer1);
digitalWrite(pin4, LOW);

digitalWrite(pin6, HIGH);
delay(timer1);
digitalWrite(pin5, LOW);

digitalWrite(pin7, HIGH);
delay(timer1);
digitalWrite(pin6, LOW);

digitalWrite(pin8, HIGH);
delay(timer1);
digitalWrite(pin7, LOW);

digitalWrite(pin9, HIGH);
delay(timer1);
digitalWrite(pin8, LOW);
delay(timer1);
digitalWrite(pin9, LOW);
digitalWrite(pin10, LOW);
digitalWrite(pin12, LOW);
delay(timer2);
}

//round2
reading = digitalRead(pin24);
// if the input just went from LOW and HIGH and we've waited long enough
// to ignore any noise on the circuit, toggle the output pin and remember
// the time
if (reading == HIGH && previous == LOW && millis() - time > debounce) {
// ... invert the output
if (state == HIGH)
state = LOW;
else
state = HIGH;
// ... and remember when the last button press was
time = millis();


digitalWrite(pin13, HIGH);
digitalWrite(pin11, HIGH);
delay(timer3);
digitalWrite(pin2, HIGH);
digitalWrite(pin9, HIGH);
delay(timer1);

digitalWrite(pin3, HIGH);
digitalWrite(pin8, HIGH);
delay(timer1);
digitalWrite(pin2, LOW);
digitalWrite(pin9, LOW);

digitalWrite(pin4, HIGH);
digitalWrite(pin7, HIGH);
delay(timer1);
digitalWrite(pin3, LOW);
digitalWrite(pin8, LOW);

digitalWrite(pin5, HIGH);
digitalWrite(pin6, HIGH);
delay(timer1);
digitalWrite(pin4, LOW);
digitalWrite(pin7, LOW);

delay(timer1);
digitalWrite(pin5, LOW);
digitalWrite(pin6, LOW);

digitalWrite(pin11, LOW);
digitalWrite(pin13, LOW);
delay(timer2);
}
}

 

Hope I get a reply, I am messed up.

Here is a video I posted with the description copied below of a simple slideshow project I made. It is rather easy for a beginner to put together and has some potential for adding more complex features. It can be done with any of the display shields or breakout boards available.

 

Created a photo slideshow to test out my Adafruit 1.8" TFT Shield with an Arduino Uno. I built around the sample function for drawing bitmaps in the Adafruit_ST7735 library to automatically rotate through all the files on the microSD card. The program is rather simple, making use of openNextFile() and rewindDirectory() from the Arduino SD library.

 

Features:

- Photo files not hard coded (no need to reprogram for new photos)

- Loops through photos once last file is reached

 

Future Upgrades:

- Interactive mode (use joystick to navigate photos)

- Include both landscape and horizontal photos

- Improve robustness (i.e. reject non-bitmap files)

- Auto-scale photos (currently photos were cropped to 128 x 160px)

 

Code:

https://github.com/mrmitche/arduino

 

Shield:

https://www.adafruit.com/products/802

In this project using only an Arduino with an Ethernet shield.

I’ll be controlling one LED and a servo, but you can apply this method to control a DC motors, buzzers, relays, stepper motors, etc..

 

Check this Video tutorial below ! (Includes demonstration)

 

 

Overview:

When you upload the the code provided in this tutorials. it creates a webserver in your LAN and you simply use the IP to access that webserver through your browser. After that it shows a webpage similar to that one below. When you press the button “Turn On LED” your url will change to: “http://192.168.1.178/?button1on” the arduino will read that information and It turns the LED On.

 

By default the IP is “192.168.1.178″. That also can be found on the Arduino code provided.

The Webpage will look like the image on the attachments.

 

Parts Required:


 

  • 1x Arduino Uno

  • 1x Ethernet Shield

  • 1x 220 Ohm Resistor

  • 1x LED

  • 1x Micro Servo Motor

  • 1x Breadboard

  • Jumper Cables

Schematics

Picture of Schematics

 

Upload this Arduino Code Below:

Click Here to Download!

 

Now you can create your own webserver!

And control any electronic device you desire.

 

Did you enjoyed this project?

Please support my work by sharing this project with a friend!

 

Make sure you like my Facebook page so you don't miss my next project!

 

Have a problem?

Leave a comment on my blog and I'll help you!

 

P.S. Click here to see my blog where I post weekly Projects and Electronics Tips!

For small robotic and other projects you can pick up small 28BYJ-48 stepper motors and gearbox with ULN2003ULN2003 driver boards quite cheaply. These motors are used in comercial projects like washing machines etc hence are made in very large quantities and are cheap. The gearbox means that they have a decent torque and can move a small robot ok. Because these have a gearbox I'll need to include a "home" sensor to work out when they are pointing at the top as my application I need to know the absolute position of the motor. I'm hoping to use a slotted opto sensorslotted opto sensor to do this and have made some disks to attach to the motor gears and will add a stripe to these so that I can detect an abosolute position.

 

OptoDisks.jpg

I initially had issues with the standard Arduino stepper library but Yuan Liu @LiuYuanster mentioned on twitter that the default Arduino Stepper library only works with cross-wire pin sequence e.g. 8,10,9,11 and sent me the following link for information about Small Steppers. I tried the cross wired approach and that worked just fine with the motors turning in both directions.

 

The small steppers article had a link to an alternative library AccelStepper which appears to have all of the features I need. It already has a "setposition" which I'll need when I wire up the optical sensor to detect the home position. I found another potential library via the Arduino playground called CustomStepper. This library works in a similar manner to the AccelStepper but has less features, I may need to switch to this if I run into memory issues with the AccelStepper library or even cut into that.

 

Workshopshed: stepper motor

Filter Blog

By date: By tag: