Un saluto a tutta la comunity.
Al contrario di chi pensa che l' open sia solo un modo per poter ottenere informazioni e poi tranne profitto, volevo condividere una mia idea su di un progetto alquanto "strano".
Creare un orologio a lancette con arduino.
Pensandoci un pò, sono arrivato alla conclusione che sia fattibilissimo, senza usare marchingegni o artifizi particolari.
Certo un pò costoso rispetto ad un orologio da parete, ma comunque credo originale.
Userò un arduino uno, 3 servo motori, tre pulsanti e tre resistenze da 10k(non per forza necessarie) come per LCD.
Inizialmente pensavo ad uno o più motori passo passo, ma credo non semplice come realizzazione del meccanismo di posizionamento, mentre sapevo per certo che i servomotori si posizionano dove voglio con un range di ben 180 posizioni ed in modo molto preciso.
Allora dopo l'acquisto dei servo, ecco il mio primo prototipo che ho chiamato ArduoServoTime.
Buon divertimento, e per chi è interessato, via all ' evoluzioni creative.
/* Sketch ArduoServoTime R.0.0
________________________________________________________________________________________________________________
Invent & Create by Giuseppe G. (giusby & gengysghey) 16/04/2013
Basic design first published in the "http://www.arduoservotime.blogspot.it" site
Enjoy.
________________________________________________________________________________________________________________
Version By Giuseppe G.
Update:16/01/2013
Revision:0.0
________________________________________________________________________________________________________________
Compiled with Arduino IDE 1.0.4 Windows XP 32bit
________________________________________________________________________________________________________________
Caracteristics R.0.0
1 servo motor for hour
1 servo motor for minute
1 servo motor for second
_________________________________________________________________________________________________________________
Hardware Basic components R.0.0
1 Arduino Uno
3 servo motor
3 button
3 resistor 10K
1 LCD 16x2 6 wire
1 trimmer 10K
________________________________________________________________________________________________________________
The circuit:
* LCD RS pin to digital pin 12
* LCD Enable pin to digital pin 11
* LCD D4 pin to digital pin 7
* LCD D5 pin to digital pin 6
* LCD D6 pin to digital pin 5
* LCD D7 pin to digital pin 4
* LCD R/W pin to ground
* LCD ends to +5V and ground
* wiper to LCD VO pin (10K resistor trimmer)
* control motor servo 1 hour digital pin 8
* control motor servo 2 minute digital pin 9
* control motor servo 3 second digital pin 10
* button up hour digital pin 2
* button up minute digital pin 3
* button up second digital pin 13
*/
//************************************************************************************************************
// SKETCH Arduo Servo Time Version for ARDUINO UNO By Giuseppe G. with HD R0.0
//************************************************************************************************************
// use this if is necessary for IDE
//#if defined(ARDUINO) && ARDUINO >= 100
//#include "Arduino.h"
//#else
//#include "WProgram.h"
//#endif
// include the library code:
#include <LiquidCrystal.h>
#include <Time.h>
#include <Servo.h>
//DECLARATION VARIABLES:
Servo servoH; //motor hout
Servo servoM; //motor minute
Servo servoS; //motor second
byte adjs=48; // automatic correction second for day without RTC
boolean memltime=0; // memory DST adjast
int ore; //hours
int minuti; //minutes
int secondi; //seconds
byte keyH=2; // button hour
byte keyM=3; // button minute
byte keyS=13; // button second
boolean selb=0; // memory change pressed buttons
// initialize the LCD library with the numbers of the interface pins
LiquidCrystal lcd(12, 11, 4, 5, 6, 7);//(RS,E,D4,D5,D6,D7)
//*************************************************************************************
void setup() {
Serial.begin(9600); //enable serial monitor
pinMode(keyS, INPUT); //configure pin button second
pinMode(keyM, INPUT); //configure pin button minute
pinMode(keyH, INPUT); //configure pin button hour
servoH.attach(8); //define motor hour
servoM.attach(9); //define motor minute
servoS.attach(10); //define motor second
// set up the LCD's number of columns and rows:
lcd.begin(16, 2);
// Print a message version project to the LCD on start-up.
delay (500); //wait 1 second
//set restart device Time default(hr,min,sec,day,month,yr);
setTime(00,00,00,16,4,2013);
}// end setup
//*************************************************************************************
void loop() {//main subroutine program of device
check_time();
view_dt(0,0);
ore = map(hour(), 0, 23, 0, 180);
minuti = map(minute(), 0, 59, 0, 180);
secondi = map(second(), 0, 59, 0, 180);
int oreT=hour();
int minutiT=minute();
int secondiT=second();
servoH.write(ore);
servoM.write(minuti);
servoS.write(secondi);
if(digitalRead(keyH) ==1 && selb == 0) {selb = 1; oreT++; setTime(oreT,minutiT,secondiT,1,1,2013);delay(100);}
if(digitalRead(keyM) ==1 && selb == 0) {selb = 1; minutiT++; setTime(oreT,minutiT,secondiT,1,1,2013);delay(100);}
if(digitalRead(keyS)==1 && selb == 0) {selb = 1; secondiT++; setTime(oreT,minutiT,secondiT,1,1,2013);delay(100);}
if(digitalRead(keyH)==0 && digitalRead(keyM)==0 && digitalRead(keyS)==0){selb = 0;} //reset memory pressed buttons
} //end loop
//*************************************************************************************
void check_time(){
// adj real time correction(increase adjs second for day"
if (hour() == 23 && minute() == 59 && second() == 60 - adjs){
setTime(23,59,59,day(),month(),year());
}
// alignment daylight saving time correction +1
if (hour() == 2 && minute() == 00 && second() == 00 && weekday() == 1 && month() == 3 && day() > 24 ){
setTime(03,00,00,day(),month(),year());
memltime=0;
}
// alignment daylight saving time correction -1
if (memltime == 0 && hour() == 3 && minute() == 00 && second() == 00 && weekday() == 1 && month() == 10 && day() > 24 ){
setTime(02,00,00,day(),month(),year());
memltime=1;
}
}
//*************************************************************************************
void view_dt(int col,int rig) {
// view time on LCD
lcd.setCursor(col,rig);
printDigit(hour());
lcd.print(F(":"));
printDigit(minute());
lcd.print(F(":"));
printDigit(second());
// view time on serial terminal
printDigit_ser(hour());
Serial.print(":");
printDigit_ser(minute());
Serial.print(":");
printDigit_ser(second());
Serial.println(".");
}
//*************************************************************************************
void printDigit(int digits){ // utility function for digital clock display: prints preceding colon and leading 0
if(digits < 10){lcd.print(F("0"));}
lcd.print(digits);
}
//*************************************************************************************
void printDigit_ser(int digits){ // utility function for digital clock on serial terminal: prints preceding colon and leading 0
if(digits < 10){Serial.print("0");}
Serial.print(digits);
}
//*********************************************************************************************************************************************************************************
//end sketch PROJECT By Giuseppe G. Site:"http://www.arduoservotime.blogspot.it" Mail:"cimice96@hotmail.it" Post:"www.arduino.cc/forum"
//*********************************************************************************************************************************************************************************