Robotic Button Masher Clock

by JimRD in Circuits > Robots

1165 Views, 8 Favorites, 0 Comments

Robotic Button Masher Clock

clock1.JPG
Robotic Button Masher Clock

This is a rather crazy clock: the Arduino reads a real time clock module and then a servo controlled "finger" punches in each number on a Grove 4-digit display. You have to see the video to understand.,

I haven't really show how to build it as I doubt anyone would want such a beast but I have included the code in case anyone is interested in how to hook everything up.

Ciao as this is my final project. LLAP.

Servos, Switches and Arduino

clock4.JPG
clock2.JPG
clock3.JPG
clock5.JPG

First photo shows 4 contact push buttons glued into a piece of wood.

Second photo shows finger using 1 servo to push and pull finger up and down.

Third photo shows slider servo that pushes finger left and right.,

Final photo shows 4 digit display and Arduino Uno. I used a RTC clock module to get real time and a GROVE 4-digit display (TM1637) which only needs two wires to control (not 12 wires like some displays).

Here Is Arduino Sketch...

#include Wire.h

#include SoftwareSerial.h

//put brackets around library names

#include Suli.h

#include Four_Digit_Display_Arduino.h

#include Wire.h

#include "RTClib.h"

#include Servo.h

#include SoftwareSerial.h

Servo servo1,servo2,servo3;

const int buttonPin4 = 13,buttonPin3=11,buttonPin2=12; int val1,val2,val3,val4; int but1,but2,but3,but4,curMin,oldMin,keyPress; Four_Digit_Display_Arduino disp;

void myServo(int curAngle,int newAngle,int angleInc,int incDelay,int servoNum) { if (curAngle < newAngle) { for(int angle=curAngle;angle < newAngle;angle += angleInc) { if (servoNum == 1) servo1.write(angle); if (servoNum == 2) servo2.write(angle); if (servoNum == 3) servo3.write(angle); delay(incDelay); } } else if (curAngle > newAngle) { for(int angle=curAngle;angle > newAngle;angle -= angleInc) { if (servoNum == 1) servo1.write(angle); if (servoNum == 2) servo2.write(angle); if (servoNum == 3) servo3.write(angle); delay(incDelay); } } } /*-----( Declare objects )-----*/ RTC_DS1307 rtc; // Create a RealTimeClock object void keyDown() { servo1.write(43); delay(250); } void keyUp() { servo1.write(120); delay(100); } void slideFinger(int pos) { servo3.write(pos); delay(1000); } int getKeyPress(int switchNo) { while(1) { int but = digitalRead(switchNo); delay(20); if (but==LOW) { Serial.print("but=low");Serial.println(but); but=HIGH; return 1; } } } void setup() { Serial.begin(9600); // Set up for Serial Monitor to be able to see this work servo1.attach(7); // finger servo delay(10);delay(1000); servo1.write(90); servo3.attach(9); //slider servo delay(10); servo3.write(90); delay(5000);

Wire.begin(); disp.begin(2,3); disp.clear(); disp.pointOn(); pinMode(buttonPin4,INPUT_PULLUP); pinMode(buttonPin3,INPUT_PULLUP); rtc.begin(); // Start the RTC library code

/*----( SET the date and time. Comment OUT these lines after setting )----*/ // Put these "//" in front of the line you do NOT want to use // following line sets the RTC to the date & time this sketch was compiled rtc.adjust(DateTime(F(__DATE__), F(__TIME__))); // This line sets the RTC with an explicit date & time, for example to set // May 21, 2015 at 6pm you would call: (use 24 hour time) // rtc.adjust(DateTime(2015, 5, 21, 18, 0, 0));

}//--(end setup )---

void loop() { ////String testString = "4"; //val4 = testString.toInt(); //val4= testString.charAt(1); //val4=9; //disp.pointOn(); //disp.begin(2,3); //disp.clear(); DateTime now = rtc.now(); // Read data from the RTC Chip curMin = now.minute() % 10; //keyPress = getKeyPress(); if (curMin != oldMin) { disp.clear(); val1 = now.hour() / 10; val2 = now.hour() % 10; val3 = now.minute() / 10; val4 = now.minute() % 10; slideFinger(36); //move slider for (int i=0;i <= val4;i++) { keyDown(); // finger down Serial.print("keypress=");Serial.println(i); if (getKeyPress(13) == 1) { disp.display(3,i); delay(10); keyUp(); //finger up delay(100); } // disp mins } slideFinger(72); //move slider for (int i=0;i <= val3;i++) { keyDown(); // finger down Serial.print("keypress=3.");Serial.println(i); if (getKeyPress(11) == 1) { disp.display(2,i); delay(10); keyUp(); //finger up delay(100); } // disp mins } slideFinger(101); //move slider for (int i=0;i <= val2;i++) { keyDown(); // finger down Serial.print("keypress=");Serial.println(i); if (getKeyPress(12) == 1) { disp.display(1,i); delay(10); keyUp(); //finger up delay(100); } // disp mins } slideFinger(139); //move slider for (int i=0;i <= val1;i++) { keyDown(); // finger down Serial.print("keypress=");Serial.println(i); if (getKeyPress(10) == 1) { disp.display(0,i); delay(10); keyUp(); //finger up delay(100); } // disp mins } //disp.display(0, now.hour() / 10); //disp.display(1, now.hour() % 10); //disp.display(2, now.minute() / 10); //disp.display(3, now.minute() % 10); servo3.write(90); delay(3000); // disp.clear(); //disp.display(0,1); delay(3000); //disp.pointOff(); //disp.pointOn();

Serial.print(now.year(), DEC); // Serial.print('/'); Serial.print(now.month(), DEC); Serial.print('/'); Serial.print(now.day(), DEC); Serial.print(' '); Serial.print(now.hour() % 10 , DEC); Serial.print(':'); Serial.print(now.minute(), DEC); Serial.print(':'); Serial.print(now.second(), DEC); Serial.println(); oldMin = curMin; } // oldMin }