Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //I涎
- #include <stdio.h>
- #include <wiringPi.h>
- #include <wiringPiI2C.h>
- //Pin 2 is 5V
- //Pin 3 is SDA_GPIO2
- #define SDA 8
- //Pin 5 is SCL_GPIO3
- #define SCL 9
- //Pin 9 is GND
- int main (void) // Programme principal
- {
- int sec = 0;
- int min = 0;
- int hour = 0;
- int jour=0,mois=0,annee=0;
- int fd;
- int day;
- wiringPiSetup();
- // Initialise la carte avec l'adresse
- /*
- fd=wiringPiI2CSetup(0x68);
- sec = wiringPiI2CWriteReg8(fd,0x00,0x00);
- min = wiringPiI2CWriteReg8(fd,0x01,0x08);
- hour = wiringPiI2CWriteReg8(fd,0x02,0x16);
- day = wiringPiI2CWriteReg8(fd,0x03,0x01);
- jour = wiringPiI2CWriteReg8(fd,0x04,0x1);
- mois = wiringPiI2CWriteReg8(fd,0x05,0x12);
- annee = wiringPiI2CWriteReg8(fd,0x06,0x2015);
- */
- while(1)
- {
- fd=wiringPiI2CSetup(0x68);
- sec = wiringPiI2CReadReg8(fd,0x00);
- min = wiringPiI2CReadReg8(fd,0x01);
- hour = wiringPiI2CReadReg8(fd,0x02);
- day = wiringPiI2CReadReg8(fd,0x03);
- jour = wiringPiI2CReadReg8(fd,0x04);
- mois = wiringPiI2CReadReg8(fd,0x05);
- annee = wiringPiI2CReadReg8(fd,0x06);
- if (mois == 0){
- if (day == 1) {
- printf("Nous sommes le Lundi %x Janvier 20%x et ", jour, annee);
- printf(" il est %xh %xmin %xsec \n", hour, min, sec);
- }
- if (day == 2) {
- printf("Nous sommes le Mardi %x Janvier 20%x et ", jour, annee);
- printf(" il est %xh %xmin %xsec \n", hour, min, sec);
- }
- if (day == 3) {
- printf("Nous sommes le Mercredi %x Janvier 20%x et ", jour, annee);
- printf(" il est %xh %xmin %xsec \n", hour, min, sec);
- }
- if (day == 4) {
- printf("Nous sommes le Jeudi %x Janvier 20%x et ", jour, annee);
- printf(" il est %xh %xmin %xsec \n", hour, min, sec);
- }
- if (day == 5) {
- printf("Nous sommes le Vendredi %x Janvier 20%x et ", jour, annee);
- printf(" il est %xh %xmin %xsec \n", hour, min, sec);
- }
- if (day == 6) {
- printf("Nous sommes le Samedi %x Janvier 20%x et ", jour, annee);
- printf(" il est %xh %xmin %xsec \n", hour, min, sec);
- }
- if (day == 7) {
- printf("Nous sommes le Dimanche %x Janvier 20%x et ", jour, annee);
- printf(" il est %xh %xmin %xsec \n", hour, min, sec);
- }
- }
- else if(mois ==1){
- if (day == 1) {
- printf("Nous sommes le Lundi %x Fevrier 20%x et ", jour, annee);
- printf(" il est %xh %xmin %xsec \n", hour, min, sec);
- }
- if (day == 2) {
- printf("Nous sommes le Mardi %x Fevrier 20%x et ", jour, annee);
- printf(" il est %xh %xmin %xsec \n", hour, min, sec);
- }
- if (day == 3) {
- printf("Nous sommes le Mercredi %x Fevrier 20%x et ", jour, annee);
- printf(" il est %xh %xmin %xsec \n", hour, min, sec);
- }
- if (day == 4) {
- printf("Nous sommes le Jeudi %x Fevrier 20%x et ", jour, annee);
- printf(" il est %xh %xmin %xsec \n", hour, min, sec);
- }
- if (day == 5) {
- printf("Nous sommes le Vendredi %x Fevrier 20%x et ", jour, annee);
- printf(" il est %xh %xmin %xsec \n", hour, min, sec);
- }
- if (day == 6) {
- printf("Nous sommes le Samedi %x Fevrier 20%x et ", jour, annee);
- printf(" il est %xh %xmin %xsec \n", hour, min, sec);
- }
- if (day == 7) {
- printf("Nous sommes le Dimanche %x Fevrier 20%x et ", jour, annee);
- printf(" il est %xh %xmin %xsec \n", hour, min, sec);
- }
- }
- else if(mois ==2){
- if (day == 1) {
- printf("Nous sommes le Lundi %x Mars 20%x et ", jour, annee);
- printf(" il est %xh %xmin %xsec \n", hour, min, sec);
- }
- if (day == 2) {
- printf("Nous sommes le Mardi %x Mars 20%x et ", jour, annee);
- printf(" il est %xh %xmin %xsec \n", hour, min, sec);
- }
- if (day == 3) {
- printf("Nous sommes le Mercredi %x Mars 20%x et ", jour, annee);
- printf(" il est %xh %xmin %xsec \n", hour, min, sec);
- }
- if (day == 4) {
- printf("Nous sommes le Jeudi %x Mars 20%x et ", jour, annee);
- printf(" il est %xh %xmin %xsec \n", hour, min, sec);
- }
- if (day == 5) {
- printf("Nous sommes le Vendredi %x Mars 20%x et ", jour, annee);
- printf(" il est %xh %xmin %xsec \n", hour, min, sec);
- }
- if (day == 6) {
- printf("Nous sommes le Samedi %x Mars 20%x et ", jour, annee);
- printf(" il est %xh %xmin %xsec \n", hour, min, sec);
- }
- if (day == 7) {
- printf("Nous sommes le Dimanche %x Mars 20%x et ", jour, annee);
- printf(" il est %xh %xmin %xsec \n", hour, min, sec);
- }
- }
- else if(mois ==3){
- if (day == 1) {
- printf("Nous sommes le Lundi %x Avril 20%x et ", jour, annee);
- printf(" il est %xh %xmin %xsec \n", hour, min, sec);
- }
- if (day == 2) {
- printf("Nous sommes le Mardi %x Avril 20%x et ", jour, annee);
- printf(" il est %xh %xmin %xsec \n", hour, min, sec);
- }
- if (day == 3) {
- printf("Nous sommes le Mercredi %x Avril 20%x et ", jour, annee);
- printf(" il est %xh %xmin %xsec \n", hour, min, sec);
- }
- if (day == 4) {
- printf("Nous sommes le Jeudi %x Avril 20%x et ", jour, annee);
- printf(" il est %xh %xmin %xsec \n", hour, min, sec);
- }
- if (day == 5) {
- printf("Nous sommes le Vendredi %x Avril 20%x et ", jour, annee);
- printf(" il est %xh %xmin %xsec \n", hour, min, sec);
- }
- if (day == 6) {
- printf("Nous sommes le Samedi %x Avril 20%x et ", jour, annee);
- printf(" il est %xh %xmin %xsec \n", hour, min, sec);
- }
- if (day == 7) {
- printf("Nous sommes le Dimanche %x Avril 20%x et ", jour, annee);
- printf(" il est %xh %xmin %xsec \n", hour, min, sec);
- }
- }
- else if(mois ==4){
- if (day == 1) {
- printf("Nous sommes le Lundi %x Mai 20%x et ", jour, annee);
- printf(" il est %xh %xmin %xsec \n", hour, min, sec);
- }
- if (day == 2) {
- printf("Nous sommes le Mardi %x Mai 20%x et ", jour, annee);
- printf(" il est %xh %xmin %xsec \n", hour, min, sec);
- }
- if (day == 3) {
- printf("Nous sommes le Mercredi %x Mai 20%x et ", jour, annee);
- printf(" il est %xh %xmin %xsec \n", hour, min, sec);
- }
- if (day == 4) {
- printf("Nous sommes le Jeudi %x Mai 20%x et ", jour, annee);
- printf(" il est %xh %xmin %xsec \n", hour, min, sec);
- }
- if (day == 5) {
- printf("Nous sommes le Vendredi %x Mai 20%x et ", jour, annee);
- printf(" il est %xh %xmin %xsec \n", hour, min, sec);
- }
- if (day == 6) {
- printf("Nous sommes le Samedi %x Mai 20%x et ", jour, annee);
- printf(" il est %xh %xmin %xsec \n", hour, min, sec);
- }
- if (day == 7) {
- printf("Nous sommes le Dimanche %x Mai 20%x et ", jour, annee);
- printf(" il est %xh %xmin %xsec \n", hour, min, sec);
- }
- }
- else if(mois ==5){
- if (day == 1) {
- printf("Nous sommes le Lundi %x Juin 20%x et ", jour, annee);
- printf(" il est %xh %xmin %xsec \n", hour, min, sec);
- }
- if (day == 2) {
- printf("Nous sommes le Mardi %x Juin 20%x et ", jour, annee);
- printf(" il est %xh %xmin %xsec \n", hour, min, sec);
- }
- if (day == 3) {
- printf("Nous sommes le Mercredi %x Juin 20%x et ", jour, annee);
- printf(" il est %xh %xmin %xsec \n", hour, min, sec);
- }
- if (day == 4) {
- printf("Nous sommes le Jeudi %x Juin 20%x et ", jour, annee);
- printf(" il est %xh %xmin %xsec \n", hour, min, sec);
- }
- if (day == 5) {
- printf("Nous sommes le Vendredi %x Juin 20%x et ", jour, annee);
- printf(" il est %xh %xmin %xsec \n", hour, min, sec);
- }
- if (day == 6) {
- printf("Nous sommes le Samedi %x Juin 20%x et ", jour, annee);
- printf(" il est %xh %xmin %xsec \n", hour, min, sec);
- }
- if (day == 7) {
- printf("Nous sommes le Dimanche %x Juin 20%x et ", jour, annee);
- printf(" il est %xh %xmin %xsec \n", hour, min, sec);
- }
- }
- else if(mois ==6){
- if (day == 1) {
- printf("Nous sommes le Lundi %x Juillet 20%x et ", jour, annee);
- printf(" il est %xh %xmin %xsec \n", hour, min, sec);
- }
- if (day == 2) {
- printf("Nous sommes le Mardi %x Juillet 20%x et ", jour, annee);
- printf(" il est %xh %xmin %xsec \n", hour, min, sec);
- }
- if (day == 3) {
- printf("Nous sommes le Mercredi %x Juillet 20%x et ", jour, annee);
- printf(" il est %xh %xmin %xsec \n", hour, min, sec);
- }
- if (day == 4) {
- printf("Nous sommes le Jeudi %x Juillet 20%x et ", jour, annee);
- printf(" il est %xh %xmin %xsec \n", hour, min, sec);
- }
- if (day == 5) {
- printf("Nous sommes le Vendredi %x Juillet 20%x et ", jour, annee);
- printf(" il est %xh %xmin %xsec \n", hour, min, sec);
- }
- if (day == 6) {
- printf("Nous sommes le Samedi %x Juillet 20%x et ", jour, annee);
- printf(" il est %xh %xmin %xsec \n", hour, min, sec);
- }
- if (day == 7) {
- printf("Nous sommes le Dimanche %x Juillet 20%x et ", jour, annee);
- printf(" il est %xh %xmin %xsec \n", hour, min, sec);
- }
- }
- else if(mois ==7){
- if (day == 1) {
- printf("Nous sommes le Lundi %x Aout 20%x et ", jour, annee);
- printf(" il est %xh %xmin %xsec \n", hour, min, sec);
- }
- if (day == 2) {
- printf("Nous sommes le Mardi %x Aout 20%x et ", jour, annee);
- printf(" il est %xh %xmin %xsec \n", hour, min, sec);
- }
- if (day == 3) {
- printf("Nous sommes le Mercredi %x Aout 20%x et ", jour, annee);
- printf(" il est %xh %xmin %xsec \n", hour, min, sec);
- }
- if (day == 4) {
- printf("Nous sommes le Jeudi %x Aout 20%x et ", jour, annee);
- printf(" il est %xh %xmin %xsec \n", hour, min, sec);
- }
- if (day == 5) {
- printf("Nous sommes le Vendredi %x Aout 20%x et ", jour, annee);
- printf(" il est %xh %xmin %xsec \n", hour, min, sec);
- }
- if (day == 6) {
- printf("Nous sommes le Samedi %x Aout 20%x et ", jour, annee);
- printf(" il est %xh %xmin %xsec \n", hour, min, sec);
- }
- if (day == 7) {
- printf("Nous sommes le Dimanche %x Aout 20%x et ", jour, annee);
- printf(" il est %xh %xmin %xsec \n", hour, min, sec);
- }
- }
- else if(mois ==8){
- if (day == 1) {
- printf("Nous sommes le Lundi %x Septembre 20%x et ", jour, annee);
- printf(" il est %xh %xmin %xsec \n", hour, min, sec);
- }
- if (day == 2) {
- printf("Nous sommes le Mardi %x Septembre 20%x et ", jour, annee);
- printf(" il est %xh %xmin %xsec \n", hour, min, sec);
- }
- if (day == 3) {
- printf("Nous sommes le Mercredi %x Septembre 20%x et ", jour, annee);
- printf(" il est %xh %xmin %xsec \n", hour, min, sec);
- }
- if (day == 4) {
- printf("Nous sommes le Jeudi %x Septembre 20%x et ", jour, annee);
- printf(" il est %xh %xmin %xsec \n", hour, min, sec);
- }
- if (day == 5) {
- printf("Nous sommes le Vendredi %x Septembre 20%x et ", jour, annee);
- printf(" il est %xh %xmin %xsec \n", hour, min, sec);
- }
- if (day == 6) {
- printf("Nous sommes le Samedi %x Septembre 20%x et ", jour, annee);
- printf(" il est %xh %xmin %xsec \n", hour, min, sec);
- }
- if (day == 7) {
- printf("Nous sommes le Dimanche %x Septembre 20%x et ", jour, annee);
- printf(" il est %xh %xmin %xsec \n", hour, min, sec);
- }
- }
- else if(mois ==9){
- if (day == 1) {
- printf("Nous sommes le Lundi %x Octobre 20%x et ", jour, annee);
- printf(" il est %xh %xmin %xsec \n", hour, min, sec);
- }
- if (day == 2) {
- printf("Nous sommes le Mardi %x Octobre 20%x et ", jour, annee);
- printf(" il est %xh %xmin %xsec \n", hour, min, sec);
- }
- if (day == 3) {
- printf("Nous sommes le Mercredi %x Octobre 20%x et ", jour, annee);
- printf(" il est %xh %xmin %xsec \n", hour, min, sec);
- }
- if (day == 4) {
- printf("Nous sommes le Jeudi %x Octobre 20%x et ", jour, annee);
- printf(" il est %xh %xmin %xsec \n", hour, min, sec);
- }
- if (day == 5) {
- printf("Nous sommes le Vendredi %x Octobre 20%x et ", jour, annee);
- printf(" il est %xh %xmin %xsec \n", hour, min, sec);
- }
- if (day == 6) {
- printf("Nous sommes le Samedi %x Octobre 20%x et ", jour, annee);
- printf(" il est %xh %xmin %xsec \n", hour, min, sec);
- }
- if (day == 7) {
- printf("Nous sommes le Dimanche %x Octobre 20%x et ", jour, annee);
- printf(" il est %xh %xmin %xsec \n", hour, min, sec);
- }
- }
- else if(mois ==10){
- if (day == 1) {
- printf("Nous sommes le Lundi %x Novembre 20%x et ", jour, annee);
- printf(" il est %xh %xmin %xsec \n", hour, min, sec);
- }
- if (day == 2) {
- printf("Nous sommes le Mardi %x Novembre 20%x et ", jour, annee);
- printf(" il est %xh %xmin %xsec \n", hour, min, sec);
- }
- if (day == 3) {
- printf("Nous sommes le Mercredi %x Novembre 20%x et ", jour, annee);
- printf(" il est %xh %xmin %xsec \n", hour, min, sec);
- }
- if (day == 4) {
- printf("Nous sommes le Jeudi %x Novembre 20%x et ", jour, annee);
- printf(" il est %xh %xmin %xsec \n", hour, min, sec);
- }
- if (day == 5) {
- printf("Nous sommes le Vendredi %x Novembre 20%x et ", jour, annee);
- printf(" il est %xh %xmin %xsec \n", hour, min, sec);
- }
- if (day == 6) {
- printf("Nous sommes le Samedi %x Novembre 20%x et ", jour, annee);
- printf(" il est %xh %xmin %xsec \n", hour, min, sec);
- }
- if (day == 7) {
- printf("Nous sommes le Dimanche %x Novembre 20%x et ", jour, annee);
- printf(" il est %xh %xmin %xsec \n", hour, min, sec);
- }
- }
- else {
- if (day == 1) {
- printf("Nous sommes le Lundi %x Decembre 20%x et ", jour, annee);
- printf(" il est %xh %xmin %xsec \n", hour, min, sec);
- }
- if (day == 2) {
- printf("Nous sommes le Mardi %x Decembre 20%x et ", jour, annee);
- printf(" il est %xh %xmin %xsec \n", hour, min, sec);
- }
- if (day == 3) {
- printf("Nous sommes le Mercredi %x Decembre 20%x et ", jour, annee);
- printf(" il est %xh %xmin %xsec \n", hour, min, sec);
- }
- if (day == 4) {
- printf("Nous sommes le Jeudi %x Decembre 20%x et ", jour, annee);
- printf(" il est %xh %xmin %xsec \n", hour, min, sec);
- }
- if (day == 5) {
- printf("Nous sommes le Vendredi %x Decembre 20%x et ", jour, annee);
- printf(" il est %xh %xmin %xsec \n", hour, min, sec);
- }
- if (day == 6) {
- printf("Nous sommes le Samedi %x Decembre 20%x et ", jour, annee);
- printf(" il est %xh %xmin %xsec \n", hour, min, sec);
- }
- if (day == 7) {
- printf("Nous sommes le Dimanche %x Decembre 20%x et ", jour, annee);
- printf(" il est %xh %xmin %xsec \n", hour, min, sec);
- }
- }
- delay(1000);
- system("clear");
- }
- return 0 ;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement