Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: RTC-DS1307 mbed
Revision 3:0fa42a66a4a6, committed 2016-04-18
- Comitter:
- Karrots3
- Date:
- Mon Apr 18 19:20:22 2016 +0000
- Parent:
- 2:d3b43d747191
- Commit message:
- .
Changed in this revision
| Servo.lib | Show diff for this revision Revisions of this file |
| main.cpp | Show annotated file Show diff for this revision Revisions of this file |
--- a/Servo.lib Mon Apr 18 17:05:24 2016 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,1 +0,0 @@ -http://developer.mbed.org/users/simon/code/Servo/#36b69a7ced07
--- a/main.cpp Mon Apr 18 17:05:24 2016 +0000
+++ b/main.cpp Mon Apr 18 19:20:22 2016 +0000
@@ -1,5 +1,4 @@
#include "mbed.h"
-#include "Servo.h"
#include "Rtc_Ds1307.h"
#include "note.h"
@@ -8,41 +7,36 @@
DigitalOut ledG(p24);
DigitalOut ledB(p26);
Rtc_Ds1307 rtc( p9,p10 );
-AnalogIn potenziometro(p17);
PwmOut piezo(p22);
Serial pc(USBTX, USBRX, "pc");
-bool flag1=0, flag2=0;
+bool flag1=0;
int ultimo_giorno=0;
int orario;
long long int c;
-/*
-struct orario {
- int ora;
- int minuti;
-};
-*/
+
-void setOrario_Pastiglia();
void suono(int frequenza, int beat);
-void scesa_della_pastiglia();
void seriale(Rtc_Ds1307::Time_rtc time);
int main()
{
Rtc_Ds1307::Time_rtc time= {};
- setOrario_Pastiglia();
+ seriale(time);
while(1) {
if(ultimo_giorno!=time.date) { //if ultimo giorno è oggi
if(orario == time.hour) { //if è l'ora della pappa
- scesa_della_pastiglia();
+ ledB=1;
+ suono(NOTE_B4,1);
ultimo_giorno=time.date;
} else if(bottone1 && time.hour==(orario-1) && time.min>=30) { //30 min prima
- scesa_della_pastiglia();
+ ledR=1;
+ suono(NOTE_B4,1);
ultimo_giorno=time.date;
} else if(bottone1 && time.hour>orario) { //l'ora è gia passata ma devo ancora prenderlo
- scesa_della_pastiglia();
+ ledG=1;
+ suono(NOTE_B4,1);
ultimo_giorno=time.date;
} else {
if(bottone1) { //l'ora deve ancora venire e premo bottone
@@ -61,72 +55,6 @@
}//while(1)
}//main
-void scesa_della_pastiglia()
-{
- ledB=1;
- suono(440,1);
- do {
- /*pastiglia*/
- c++;
- if(bottone1) {
- flag1=1;
- /////funzione del servo che gira per far scendere la pastiglia
- ledG=1;
- ledB=0;
- c=0;
- } else if(c>0 && c%1000==0) {
- suono(NOTE_D5, 1);
- }
- wait_ms(1);
- } while(!flag1) ;
- flag1=0;
- do {
- c++;
- if(bottone1) {
- flag1=1;
- ledG=0;
- suono(NOTE_A3,1);
- } else if(c>0 && c%1000==0) {
- suono(NOTE_D5, 1);
- }
- wait_ms(10);
- } while(!flag1);
-}
-
-void setOrario_Pastiglia()
-{
- bool pot=0;
- // bool seri=0;
- bool Fpot=0;
-
- do {
- if(bottone1)
- pot=1;
- wait_ms(1);
- } while(!pot);
-
- if(pot) {
- wait(0.2);
- ledR=1;
- ledG=1;
- ledB=1;
- suono(NOTE_A3, 2);
-
- do {
- if(bottone1) {
- ledR=0;
- ledG=0;
- ledB=0;
- orario=(potenziometro/1024)*24;
- Fpot=1;
- suono(NOTE_A3, 1);
- }
- wait_ms(1);
- } while(!Fpot);
-
- }
-}
-
void suono(int frequenza, int beat)
{
piezo.period(1.0 / frequenza);
@@ -138,7 +66,8 @@
-void seriale(Rtc_Ds1307::Time_rtc time) {
+void seriale(Rtc_Ds1307::Time_rtc time)
+{
int c;