Stylo 3D, Allumer une led au bout d'un temps donné. March 16, 2014 02:31PM |
Registered: 10 years ago Posts: 25 |
Re: Stylo 3D, Allumer une led au bout d'un temps donné. March 17, 2014 05:36PM |
Registered: 10 years ago Posts: 25 |
Re: Stylo 3D, Allumer une led au bout d'un temps donné. March 17, 2014 07:22PM |
Registered: 10 years ago Posts: 88 |
Re: Stylo 3D, Allumer une led au bout d'un temps donné. March 17, 2014 08:23PM |
Registered: 10 years ago Posts: 2,014 |
Re: Stylo 3D, Allumer une led au bout d'un temps donné. March 18, 2014 03:39AM |
Registered: 10 years ago Posts: 88 |
Re: Stylo 3D, Allumer une led au bout d'un temps donné. March 18, 2014 04:25PM |
Registered: 10 years ago Posts: 25 |
Re: Stylo 3D, Allumer une led au bout d'un temps donné. March 19, 2014 07:57PM |
Registered: 10 years ago Posts: 88 |
----------- programme algo boucle test si 1000h alors allume la diode if bouton remise a zero alors ecrit dans l'eeprom 0 0 0 0 fin de si sinon si contact utilisation alors incremente seconde; ecrie de l'eeprom les bonnes valeur fin de si attend 1 seconde fin de si fin de boucle --------------- #include EEPROM.h int pin_led = 13; int pin_utilisation =12; // ton contact ILS, qui donnera du + quand c'est ok int pin_remise_a_zero =11; //(mettre interupteur entre + et pin 11 , on peut rajouter un pulldown(resistance 100ko à moins sur pin11)) int adr_sec=0; // sec int adr_min=1; // min int adr_heu=2; // h int adr_cen=3; // centaines h byte sec,min,heu,cen; void setup() { pinMode(pin_led , OUTPUT); // led pinMode(pin_utilisation , INTPUT); // pin contact utilisation pinMode(pin_remise_a_zero , INTPUT); // pin remise a zero } void loop() { if (EEPROM.read(adr_cen)==10) // lit si 10x100h =1000h { digitalWrite(pin_led, HIGH); if (digitalRead(pin_remise_a_zero)==HIGH) { // remise a zero EEPROM.write(adr_sec,0); EEPROM.write(adr_min,0); EEPROM.write(adr_heu,0); EEPROM.write(adr_cen,0); } } else { if (digitalRead(pin_utilisation) ==HIGH) // si utilisation { sec=EEPROM.read(adr_sec)+1; min=EEPROM.read(adr_min); heu=EEPROM.read(adr_heu); cen=EEPROM.read(adr_cen); if (sec==60) // + de 60s -> +1min { sec=0; min++; } if (min==60) // + de 60min -> +1h { min=0; heu++; } if (heu==100) // + de 100h -> +1centaine d'heure { heu=0; cen++; } // sauvegarde EEPROM.write(adr_sec,sec); EEPROM.write(adr_min,min); EEPROM.write(adr_heu,heu); EEPROM.write(adr_cen,cen); delay(1000); // 1 sec } } }
Re: Stylo 3D, Allumer une led au bout d'un temps donné. March 20, 2014 12:55AM |
Registered: 10 years ago Posts: 2,014 |
Re: Stylo 3D, Allumer une led au bout d'un temps donné. March 20, 2014 03:21AM |
Registered: 10 years ago Posts: 88 |
Re: Stylo 3D, Allumer une led au bout d'un temps donné. March 20, 2014 03:40AM |
Registered: 10 years ago Posts: 25 |
Re: Stylo 3D, Allumer une led au bout d'un temps donné. March 20, 2014 04:03AM |
Registered: 10 years ago Posts: 88 |
Re: Stylo 3D, Allumer une led au bout d'un temps donné. March 20, 2014 04:08AM |
Registered: 10 years ago Posts: 88 |
Re: Stylo 3D, Allumer une led au bout d'un temps donné. March 20, 2014 04:33AM |
Registered: 10 years ago Posts: 25 |
Re: Stylo 3D, Allumer une led au bout d'un temps donné. March 20, 2014 04:50AM |
Registered: 12 years ago Posts: 432 |
Quote
revolution07
oui, y a pas si longtemps on aurai utilisé 1 ne555, quelques compteur 74lsxxx, 3 composants, et c'était jouer.
maintenant, faut un super calculateur pour faire clignoté une led!
Re: Stylo 3D, Allumer une led au bout d'un temps donné. March 20, 2014 05:26AM |
Registered: 10 years ago Posts: 25 |
Re: Stylo 3D, Allumer une led au bout d'un temps donné. March 20, 2014 07:00AM |
Registered: 10 years ago Posts: 25 |
#include #include "DS1307.h" DS1307 clock;//define a object of DS1307 class void setup() { Serial.begin(9600); clock.begin(); clock.fillByYMD(2014,2,6);// 06 Fevrier,2014 clock.fillByHMS(17,50,30);//13:53 30" clock.fillDayOfWeek(THU);//Jeudi // clock.setTime();//write time to the RTC chip } void loop() { printTime(); } /*--------------------------------------------------* * Fonction: Affiche le temps sur le moniteur série * *--------------------------------------------------*/ void printTime() { clock.getTime(); Affiche_JOUR(); Serial.print(" "); Affiche_JMA(); Serial.println(" "); Affiche_HMS(); Serial.print(" "); delay(500); } void Affiche_HMS() { Serial.print(clock.hour, DEC); Serial.print(":"); Serial.print(clock.minute, DEC); Serial.print(":"); Serial.print(clock.second, DEC); } void Affiche_JOUR() { switch (clock.dayOfWeek)// Friendly printout the weekday { case MON: Serial.print("LUNDI "); break; case TUE: Serial.print("MARDI "); break; case WED: Serial.print("MERCREDI "); break; case THU: Serial.print("JEUDI "); break; case FRI: Serial.print("VENDREDI "); break; case SAT: Serial.print("SAMEDI "); break; case SUN: Serial.print("DIMANCHE "); break; } } void Affiche_JMA() { Serial.print(clock.dayOfMonth, DEC); Serial.print("/"); Serial.print(clock.month, DEC); Serial.print("/"); Serial.print(clock.year+2000, DEC); Serial.print(" "); }
Quote
Nous allons utiliser un capteur ILS, qui lorsque l'on retirera le stylo de son socle le mettra en marche (Mais ça ce n'est pas ma partie) et qui déclenchera le comptage du temps avec la RTC grove(Par contre la si). Une fois reposer sa arrêtera le comptage et mettra en mémoire le temps d'utilisation dans la ram de la rtc. Voila les directives de mon prof j'avoue que je suis un peu perdu...
Re: Stylo 3D, Allumer une led au bout d'un temps donné. March 20, 2014 09:44AM |
Registered: 10 years ago Posts: 2,014 |
Re: Stylo 3D, Allumer une led au bout d'un temps donné. March 20, 2014 11:42AM |
Registered: 10 years ago Posts: 25 |
Re: Stylo 3D, Allumer une led au bout d'un temps donné. March 21, 2014 10:53AM |
Registered: 10 years ago Posts: 25 |
Re: Stylo 3D, Allumer une led au bout d'un temps donné. March 26, 2014 12:47PM |
Registered: 10 years ago Posts: 25 |
#include #include "DS1307.h" DS1307 clock;//define a object of DS1307 class void setup() { Serial.begin(9600); clock.begin(); clock.fillByYMD(2014,2,6);// 06 Fevrier,2014 clock.fillByHMS(17,50,30);//13:53 30" clock.fillDayOfWeek(THU);//Jeudi // clock.setTime();//write time to the RTC chip } void loop() { printTime(); } /*--------------------------------------------------* * Fonction: Affiche le temps sur le moniteur série * *--------------------------------------------------*/ void printTime() { clock.getTime(); Affiche_JOUR(); Serial.print(" "); Affiche_JMA(); Serial.println(" "); Affiche_HMS(); Serial.print(" "); delay(500); } void Affiche_HMS() { Serial.print(clock.hour, DEC); Serial.print(":"); Serial.print(clock.minute, DEC); Serial.print(":"); Serial.print(clock.second, DEC); } void Affiche_JOUR() { switch (clock.dayOfWeek)// Friendly printout the weekday { case MON: Serial.print("LUNDI "); break; case TUE: Serial.print("MARDI "); break; case WED: Serial.print("MERCREDI "); break; case THU: Serial.print("JEUDI "); break; case FRI: Serial.print("VENDREDI "); break; case SAT: Serial.print("SAMEDI "); break; case SUN: Serial.print("DIMANCHE "); break; } } void Affiche_JMA() { Serial.print(clock.dayOfMonth, DEC); Serial.print("/"); Serial.print(clock.month, DEC); Serial.print("/"); Serial.print(clock.year+2000, DEC); Serial.print(" "); }
#include // the current address in the EEPROM (i.e. which byte // we're going to write to next) int addr = 0; void setup() { } void loop() { // need to divide by 4 because analog inputs range from // 0 to 1023 and each byte of the EEPROM can only hold a // value from 0 to 255. int val = analogRead(0) / 4; // write the value to the appropriate byte of the EEPROM. // these values will remain there when the board is // turned off. EEPROM.write(addr, val); // advance to the next address. there are 512 bytes in // the EEPROM, so go back to 0 when we hit 512. addr = addr + 1; if (addr == 512) addr = 0; delay(100); }
Re: Stylo 3D, Allumer une led au bout d'un temps donné. March 27, 2014 05:41AM |
Registered: 10 years ago Posts: 25 |
// Sauvegarde EEPROM.write(clock_hour,hour); EEPROM.write(clock_minute,minu); EEPROM.write(clock_second,sec); // advance to the next address. there are 512 bytes in // the EEPROM, so go back to 0 when we hit 512. clock_hour = clock_hour + 1; if (clock_hour == 512) clock_hour = 0; delay(100);
// advance to the next address. there are 512 bytes in // the EEPROM, so go back to 0 when we hit 512. clock_hour = clock_hour + 1; if (clock_hour == 512) clock_hour = 0; delay(100);
Re: Stylo 3D, Allumer une led au bout d'un temps donné. April 02, 2014 04:25PM |
Registered: 10 years ago Posts: 25 |
#include #include #include "DS1307.h" double SEC; const int buttonPin = A2; int buttonState = 0; DS1307 clock;//define a object of DS1307 class void setup() { Serial.begin(9600); clock.begin(); clock.fillByYMD(2014,3,27);// 06 Fevrier,2014 clock.fillByHMS(17,50,30);//13:53 30" clock.fillDayOfWeek(THU);//Jeudi clock.setTime();//write time to the RTC chip } void loop() { printTime(); calcul_SEC(); buttonState = digitalRead(buttonPin); } /*--------------------------------------------------* * Fonction: Affiche le temps sur le moniteur série * *--------------------------------------------------*/ void printTime() { clock.getTime(); Affiche_JOUR(); Serial.print(" "); Affiche_JMA(); Serial.println(" "); Affiche_HMS(); Serial.println(" "); delay(500); } void Affiche_HMS() { Serial.print(clock.hour, DEC); Serial.print(":"); Serial.print(clock.minute, DEC); Serial.print(":"); Serial.print(clock.second, DEC); } void Affiche_JOUR() { switch (clock.dayOfWeek)// Friendly printout the weekday { case MON: Serial.print("LUNDI "); break; case TUE: Serial.print("MARDI "); break; case WED: Serial.print("MERCREDI "); break; case THU: Serial.print("JEUDI "); break; case FRI: Serial.print("VENDREDI "); break; case SAT: Serial.print("SAMEDI "); break; case SUN: Serial.print("DIMANCHE "); break; } } void Affiche_JMA() { Serial.print(clock.dayOfMonth, DEC); Serial.print("/"); Serial.print(clock.month, DEC); Serial.print("/"); Serial.print(clock.year+2000, DEC); Serial.print(" "); } void calcul_SEC() { buttonState = digitalRead ( buttonPin ) ; if (buttonState == HIGH) { SEC= ((clock.hour)*36E2)+((clock.minute)*60)+ (clock.second); Serial.println(SEC); } }
/* * EEPROM Write * * Stores values read from analog input 0 into the EEPROM. * These values will stay in the EEPROM when the board is * turned off and may be retrieved later by another sketch. */ #include int clock_hour=0; int clock_minute=0; int clock_second=0; byte sec,minu,hour; /* the current address in the EEPROM (i.e. which byte we're going to write to next)*/ void setup() { } void loop() { // need to divide by 4 because analog inputs range from // 0 to 1023 and each byte of the EEPROM can only hold a // value from 0 to 255. int val = analogRead(0) / 4; // write the value to the appropriate byte of the EEPROM. // these values will remain there when the board is // turned off. // Sauvegarde EEPROM.write(clock_hour,hour); EEPROM.write(clock_minute,minu); EEPROM.write(clock_second,sec); // advance to the next address. there are 512 bytes in // the EEPROM, so go back to 0 when we hit 512. addr = addr + 1; if (addr == 512) addr = 0; delay(100); }