cc

Dependencies:   mbed TextLCD

Files at this revision

API Documentation at this revision

Comitter:
Couscousiste
Date:
Thu Jun 25 16:30:18 2020 +0000
Commit message:
ghkvg

Changed in this revision

Partie_1/Exercice2.cpp Show annotated file Show diff for this revision Revisions of this file
Partie_1/Exercice5.cpp Show annotated file Show diff for this revision Revisions of this file
Partie_2/Exercice_1.cpp Show annotated file Show diff for this revision Revisions of this file
Partie_2/Exercice_2.cpp Show annotated file Show diff for this revision Revisions of this file
Partie_2/Exercice_3.cpp Show annotated file Show diff for this revision Revisions of this file
Partie_2/Exercice_4.cpp Show annotated file Show diff for this revision Revisions of this file
Partie_2/Exercice_5.cpp Show annotated file Show diff for this revision Revisions of this file
Partie_2/Exercice_6.cpp Show annotated file Show diff for this revision Revisions of this file
Partie_2/Exercice_7.cpp Show annotated file Show diff for this revision Revisions of this file
Partie_3/Exercice_1.cpp Show annotated file Show diff for this revision Revisions of this file
Partie_3/Exercice_2/LCD.cpp Show annotated file Show diff for this revision Revisions of this file
Partie_3/Exercice_2/LCD.h Show annotated file Show diff for this revision Revisions of this file
Partie_3/Exercice_2/main.cpp Show annotated file Show diff for this revision Revisions of this file
Partie_3/Exercice_3.cpp Show annotated file Show diff for this revision Revisions of this file
Partie_4/Exercice_1.cpp Show annotated file Show diff for this revision Revisions of this file
Partie_5/Exercice_1.cpp Show annotated file Show diff for this revision Revisions of this file
Partie_5/Exercice_2.cpp Show annotated file Show diff for this revision Revisions of this file
Partie_5/Exercice_3.cpp Show annotated file Show diff for this revision Revisions of this file
Partie_6/Exercice_.cpp Show annotated file Show diff for this revision Revisions of this file
Partie_6/Exercice_1.cpp Show annotated file Show diff for this revision Revisions of this file
Partie_6/Prequel.cpp Show annotated file Show diff for this revision Revisions of this file
Partie_8/Exercice_1.cpp Show annotated file Show diff for this revision Revisions of this file
Partie_9/Exercice.cpp Show annotated file Show diff for this revision Revisions of this file
Partie_9/Exercice_2.cpp Show annotated file Show diff for this revision Revisions of this file
Partie_9/Exercice_3.cpp Show annotated file Show diff for this revision Revisions of this file
TextLCD.lib Show annotated file Show diff for this revision Revisions of this file
main.cpp Show annotated file Show diff for this revision Revisions of this file
mbed.bld Show annotated file Show diff for this revision Revisions of this file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Partie_1/Exercice2.cpp	Thu Jun 25 16:30:18 2020 +0000
@@ -0,0 +1,34 @@
+/*#include "mbed.h" 
+DigitalOut rouge(p5); 
+DigitalOut orange(p8);
+DigitalOut vert(p6); 
+DigitalIn  switchinput(p7); 
+int main() { 
+  switchinput.mode(PullUp); 
+  while(1) { 
+    if (switchinput==1) { 
+      vert.write(1); 
+      orange.write(0);
+      rouge.write(0); 
+      wait(2);
+      vert.write(0); 
+      orange.write(1);
+      rouge.write(0); 
+      wait(0.5);
+      vert.write(0); 
+      orange.write(0);
+      rouge.write(1); 
+      wait(2);
+    } 
+    else if (switchinput==0) { 
+        vert.write(0);
+        orange.write(0);
+        rouge.write(0);
+        wait(2);
+        vert.write(0);
+        orange.write(1);
+        rouge.write(0);
+        wait(2);  
+    } 
+  } 
+} */
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Partie_1/Exercice5.cpp	Thu Jun 25 16:30:18 2020 +0000
@@ -0,0 +1,29 @@
+/*#include "mbed.h" 
+DigitalOut rouge(p5);
+DigitalOut orange(p8);
+DigitalOut vert(p6);
+DigitalIn  switchinput(p7); 
+int main() { 
+    switchinput.mode(PullUp);
+    vert.write(0);
+    orange.write(0);
+    rouge.write(0); 
+    int cpt=0;
+    while(1) { 
+     if (switchinput==0) { 
+      vert.write(1);
+            orange.write(0);
+            rouge.write(0);
+     wait(0.2);
+     
+     }
+        if (switchinput==0) { 
+            cpt=cpt+1;
+            if(cpt==10){
+            vert.write(0);
+            orange.write(1);
+            rouge.write(0);
+            }           
+        }
+    }
+} */
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Partie_2/Exercice_1.cpp	Thu Jun 25 16:30:18 2020 +0000
@@ -0,0 +1,14 @@
+/* // Reads input through the ADC,  
+// and transfers to PC terminal 
+#include "mbed.h" 
+Serial pc(USBTX, USBRX); 
+AnalogIn Ain(p20); 
+float ADCdata; 
+int main() { 
+  pc.printf("ADC Data Values... \n\r"); 
+  while (1) { 
+    ADCdata=Ain.read();  
+    pc.printf("%f \n\r",ADCdata); 
+    wait (0.5); 
+  } 
+} */ 
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Partie_2/Exercice_2.cpp	Thu Jun 25 16:30:18 2020 +0000
@@ -0,0 +1,51 @@
+/* // Reads input through the ADC,  
+// and transfers to PC terminal 
+#include "mbed.h" 
+
+DigitalOut led1 (LED1);
+DigitalOut led2 (LED2);
+DigitalOut led3 (LED3);
+DigitalOut led4 (LED4);
+
+Serial pc(USBTX, USBRX); 
+AnalogIn Ain(p20); 
+float ADCdata; 
+int main() { 
+  pc.printf("ADC Data Values... \n\r"); 
+  while (1) { 
+    ADCdata=Ain.read();  
+    pc.printf("%f \n\r",ADCdata); 
+    wait (0.5);
+    
+    if(ADCdata<0.2){
+        led1.write(1);
+        led2.write(1);
+        led3.write(1);
+        led4.write(1);
+    }
+    else if(0.2<ADCdata && ADCdata<0.4){
+        led1.write(0);
+        led2.write(1);
+        led3.write(1);
+        led4.write(1);
+    }
+    else if(0.4<ADCdata && ADCdata<0.6){
+        led1.write(0);
+        led2.write(0);
+        led3.write(1);
+        led4.write(1);  
+    }
+    else if(0.6<ADCdata && ADCdata<0.8){
+        led1.write(0);
+        led2.write(0);
+        led3.write(0);
+        led4.write(1); 
+    }
+    else{
+        led1.write(0);
+        led2.write(0);
+        led3.write(0);
+        led4.write(0); 
+    }
+  } 
+}  */
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Partie_2/Exercice_3.cpp	Thu Jun 25 16:30:18 2020 +0000
@@ -0,0 +1,14 @@
+/*
+#include "mbed.h" 
+int main() { 
+  AnalogOut Sortie(p18); 
+  while(1) { 
+  Sortie.write(0.25); // 0.25*3.3V = 0.825V 
+  wait(1); 
+  Sortie.write(0.5);  // 0.5*3.3V = 1.65V 
+  wait(1); 
+  Sortie.write(0.75); // 0.75*3.3V = 2.475V 
+  wait(1); 
+  }
+}
+*/
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Partie_2/Exercice_4.cpp	Thu Jun 25 16:30:18 2020 +0000
@@ -0,0 +1,16 @@
+/*
+//Sawtooth waveform on DAC output to view on oscilloscope
+ 
+#include "mbed.h" 
+AnalogOut Aout(p18); 
+float i; 
+int main() { 
+  while(1)  
+  { 
+    for (i=0;i<1;i=i+0.1) 
+    { 
+      Aout.write(i);  
+      wait(0.001);  
+    } 
+  } 
+} */
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Partie_2/Exercice_5.cpp	Thu Jun 25 16:30:18 2020 +0000
@@ -0,0 +1,16 @@
+/*
+//Sawtooth waveform on DAC output to view on oscilloscope
+ 
+#include "mbed.h" 
+AnalogOut Aout(p18); 
+float i; 
+int main() { 
+  while(1)  
+  { 
+    for (i=0;i<1;i=i+0.01) 
+    { 
+      Aout.write(i);  
+      wait(0.001);  
+    } 
+  } 
+} */
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Partie_2/Exercice_6.cpp	Thu Jun 25 16:30:18 2020 +0000
@@ -0,0 +1,21 @@
+/*
+//Sawtooth waveform on DAC output to view on oscilloscope
+ 
+#include "mbed.h" 
+AnalogOut Aout(p18); 
+float i; 
+int main() { 
+  while(1)  
+  { 
+    for (i=0;i<1;i=i+0.01) 
+    { 
+      Aout.write(i);  
+      wait(0.001);  
+    } 
+    for (i=1;i>0;i=i-0.01) 
+    { 
+      Aout.write(i);  
+      wait(0.001);  
+    } 
+  } 
+} */
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Partie_2/Exercice_7.cpp	Thu Jun 25 16:30:18 2020 +0000
@@ -0,0 +1,22 @@
+/*//Sawtooth waveform on DAC output to view on oscilloscope
+ 
+#include "mbed.h" 
+AnalogOut Aout(p18);
+AnalogIn pot(p20); 
+float i,x; 
+int main() { 
+  while(1)  
+  { 
+    x=pot.read();
+    for (i=0;i<1;i=i+0.01) 
+    { 
+      Aout.write(i*x);  
+      wait(0.001);  
+    } 
+    for (i=1;i>0;i=i-0.01) 
+    { 
+      Aout.write(i*x);  
+      wait(0.001);  
+    } 
+  } 
+} */
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Partie_3/Exercice_1.cpp	Thu Jun 25 16:30:18 2020 +0000
@@ -0,0 +1,27 @@
+/*
+#include "mbed.h" 
+BusOut myleds(LED4, LED3, LED2, LED1); 
+int main() { 
+  char x; 
+  while(1) {  
+    x=1;   
+    myleds.write(x);  
+    wait(0.2); 
+    x=2;     
+    myleds.write(x);  
+    wait(0.2);
+    x=4;   
+    myleds.write(x);  
+    wait(0.2); 
+    x=8;     
+    myleds.write(x);  
+    wait(0.2);
+    x=4;     
+    myleds.write(x);  
+    wait(0.2); 
+    x=2;   
+    myleds.write(x);  
+    wait(0.2);
+  } 
+}  
+*/
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Partie_3/Exercice_2/LCD.cpp	Thu Jun 25 16:30:18 2020 +0000
@@ -0,0 +1,49 @@
+/*
+// LCD.cpp file 
+#include "LCD.h" 
+DigitalOut RS(p19); 
+DigitalOut E(p20); 
+BusOut data(p21, p22, p23, p24); 
+void toggle_enable(void){ 
+  E.write(1); 
+  wait(0.001); 
+  E.write(0); 
+  wait(0.001); 
+} 
+void LCD_init(void){ 
+  wait(0.02); 
+  RS.write(0); 
+  E.write(0); 
+                 //function mode 
+  data.write(0x2); 
+  toggle_enable(); 
+  data.write(0x8); 
+  toggle_enable(); 
+               //display mode 
+  data.write(0x0); 
+  toggle_enable(); 
+  data.write(0xF); 
+  toggle_enable(); 
+               //clear display 
+  data.write(0x0); 
+  toggle_enable(); 
+  data.write(0x1); 
+  toggle_enable(); 
+} 
+//display function 
+void display_to_LCD(char value ){ 
+  RS.write(1); 
+  data.write(value>>4); 
+  toggle_enable(); 
+  data.write(value&0x0F);  
+  toggle_enable();  
+} 
+
+void mafonction(char t[]){
+    int i=0;
+    while(t[i]!='\0'){
+        display_to_LCD(t[i]);
+        i++;
+    }
+}
+*/
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Partie_3/Exercice_2/LCD.h	Thu Jun 25 16:30:18 2020 +0000
@@ -0,0 +1,11 @@
+/*
+// LCD.h file 
+#ifndef LCD_H 
+#define LCD_H 
+#include "mbed.h" 
+void display_to_LCD(char value); //fonction d'affichage des carac. 
+void mafonction(char t[]);
+void toggle_enable(void); //fonction d'inversion du bit enable 
+void LCD_init(void); // fonction d'initialisation du LCD 
+#endif  
+*/
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Partie_3/Exercice_2/main.cpp	Thu Jun 25 16:30:18 2020 +0000
@@ -0,0 +1,13 @@
+/*
+#include "LCD.h" 
+int main() { 
+  char tab[20]="charo";
+  LCD_init(); 
+  display_to_LCD(0x48); // ‘H’ 
+  display_to_LCD(0x45); // ‘E’ 
+  display_to_LCD(0x4C); // ‘L’ 
+  display_to_LCD(0x4C); // ‘L’ 
+  display_to_LCD(0x4F); // ‘O’
+  mafonction(tab); 
+} 
+*/
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Partie_3/Exercice_3.cpp	Thu Jun 25 16:30:18 2020 +0000
@@ -0,0 +1,10 @@
+/*
+#include "TextLCD.h"
+TextLCD MonLCD(p19,p20,p21,p22,p23,p24);
+int main(){
+    MonLCD.cls();
+    MonLCD.printf("Hello");
+    MonLCD.locate(3,1);
+    MonLCD.printf("World !");
+}
+*/
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Partie_4/Exercice_1.cpp	Thu Jun 25 16:30:18 2020 +0000
@@ -0,0 +1,31 @@
+/*
+#include "mbed.h"  
+BusOut myleds(LED4, LED3, LED2, LED1); 
+Timer timer1; // définition du timer 
+DigitalOut sortie1(p5); 
+//void tache1(void); // prototype de tache1
+int main() { 
+    char x=0;
+    timer1.start(); // déclenchement du timer 
+    while(1) { 
+        myleds.write(x);
+        if(timer1.read_ms()>=1000){
+            if(x==15){
+                x=0;
+            }
+            else{
+                x++;
+                }
+            timer1.reset();
+        } 
+        if(timer1.read_ms()>=200)//
+        {  
+            tache1(); // appel de la fonction tache1
+            timer1.reset(); // remise à zéro du timer 
+        } 
+    } 
+} 
+void tache1(void){ // fonction
+sortie1.write(!(sortie1.read()); // inversion
+} 
+*/
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Partie_5/Exercice_1.cpp	Thu Jun 25 16:30:18 2020 +0000
@@ -0,0 +1,16 @@
+/*#include "mbed.h"
+Serial pc(USBTX,USBRX);
+LocalFileSystem local("local");
+int donnee_a_ecrire;
+int donnee_lue;
+int main ()
+{
+    FILE* File1 = fopen("/local/datafile.txt","w"); //ouverture d'un fichier
+    donnee_a_ecrire =0x23; //0x23 = #
+    fputc(donnee_a_ecrire, File1);
+    fclose(File1);
+    FILE* File2 = fopen ("/local/datafile.txt","r");//ouverture du second fichier
+    donnee_lue = fgetc(File2); //lire une donnée
+    fclose(File2);
+    pc.printf("input value = %c \n", donnee_lue); // ecrit sur tera term 
+}*/
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Partie_5/Exercice_2.cpp	Thu Jun 25 16:30:18 2020 +0000
@@ -0,0 +1,15 @@
+/*#include "mbed.h" 
+Serial pc(USBTX,USBRX);  
+LocalFileSystem local("local");  
+char read_string[64];  
+int main () 
+{ 
+  FILE* File1 = fopen("/local/textfile.txt","w");  // ouvre un fichier
+  fputs("Beaucoup de mots et de lettres...", File1) //ecrit ds le fichier
+;  
+  fclose(File1);     //ferme le fichier
+  FILE* File2 = fopen ("/local/textfile.txt","r"); 
+  fgets(read_string,256,File2);    //lis le fichier 
+  fclose(File2);      
+  pc.printf("text data: %s \n",read_string);    //Ecrit sur teraterm
+} */
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Partie_5/Exercice_3.cpp	Thu Jun 25 16:30:18 2020 +0000
@@ -0,0 +1,22 @@
+/*#include "mbed.h" 
+InterruptIn button(p30);  
+DigitalOut led1(LED1);  
+Timer debounce;  
+LocalFileSystem local("local");  
+void toggle(void);  
+int main() { 
+button.mode(PullUp); 
+debounce.start();     
+button.rise(&toggle);     
+while(1); 
+} 
+void toggle() { 
+  if (debounce.read_ms()>200) {  
+    led1.write(!led1.read());  
+    FILE* pfile = fopen ("/local/log.txt","a");  
+    fprintf(pfile,"time=%.3fs: setting led=%d\n\r",
+debounce.read(),led1.read()); 
+    fclose(pfile); // close file 
+    debounce.reset(); // reset debounce timer  
+  }  
+} */ 
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Partie_6/Exercice_.cpp	Thu Jun 25 16:30:18 2020 +0000
@@ -0,0 +1,22 @@
+/*#include "mbed.h"
+Serial pc(USBTX, USBRX);
+PwmOut Vs(LED1);
+float intensite=0.0;
+int main()
+{
+    pc.printf("Contrôle de l’intensité de la Led\n\r");
+    pc.printf("Pressez ‘+’ ou ‘-’\n\r");
+    while(1) {
+        char c = pc.getc();
+        wait(0.001);
+        if((c == '+') && (intensite < 0.1)) {
+            intensite += 0.001;
+            Led.write(intensite);
+        }
+        if((c == '-') && (intensite > 0.0)) {
+            intensite-= 0.001;
+            Led.write(intensite);
+        }
+        pc.printf("%c %1.3f\n\r",c, intensite);
+    }
+}*/
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Partie_6/Exercice_1.cpp	Thu Jun 25 16:30:18 2020 +0000
@@ -0,0 +1,22 @@
+/*#include "mbed.h"
+Serial pc(USBTX, USBRX);
+PwmOut Led(LED1);
+float intensite=0.0;
+int main()
+{
+    pc.printf("Contrôle de l’intensité de la Led\n\r");
+    pc.printf("Pressez ‘+’ ou ‘-’\n\r");
+    while(1) {
+        char c = pc.getc();
+        wait(0.001);
+        if((c == '+') && (intensite < 0.1)) {
+            intensite += 0.001;
+            Led.write(intensite);
+        }
+        if((c == '-') && (intensite > 0.0)) {
+            intensite-= 0.001;
+            Led.write(intensite);
+        }
+        pc.printf("%c %1.3f\n\r",c, intensite);
+    }
+}*/
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Partie_6/Prequel.cpp	Thu Jun 25 16:30:18 2020 +0000
@@ -0,0 +1,9 @@
+/*#include "mbed.h"
+PwmOut Ve(p23);
+
+int main(){
+    Ve.period_us(20000);
+    while(1){    
+        Ve.pulsewidth_us(18500);
+    }
+}*/
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Partie_8/Exercice_1.cpp	Thu Jun 25 16:30:18 2020 +0000
@@ -0,0 +1,15 @@
+/*#include "mbed.h"
+Serial pc(USBTX, USBRX); // tx, rx - Liaison série 1
+Serial device(p13, p14);  // tx, rx - Liaison série 2
+int main()
+{
+    while(1) {
+        device.baud(19200);
+        if(pc.readable()) {
+            device.putc(pc.getc());
+        }
+        if(device.readable()) {
+            pc.putc(device.getc());
+        }
+    }
+}*/
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Partie_9/Exercice.cpp	Thu Jun 25 16:30:18 2020 +0000
@@ -0,0 +1,17 @@
+/*#include "mbed.h"
+AnalogOut pain(p18);
+int main()
+{
+    
+    int i,j;
+    while(1) {
+        for(i=0;i<1;i=i+0.1){
+            pain.write(i);
+            wait(0.2);
+        }
+        for(j=1;j>0;j=j-0.1){
+            pain.write(j);
+            wait(0.2);
+        }
+    }
+}*/
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Partie_9/Exercice_2.cpp	Thu Jun 25 16:30:18 2020 +0000
@@ -0,0 +1,8 @@
+/*#include "mbed.h"
+SPI spi(p11,p12,p13); //mosi miso sclk
+DigitalOut CS(p10);
+int main()
+{
+    spi.format(8.1);
+    spi.frequency(500000);
+}*/
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Partie_9/Exercice_3.cpp	Thu Jun 25 16:30:18 2020 +0000
@@ -0,0 +1,18 @@
+/*#include "mbed.h"
+SPI spi(p11,p12,p13); //mosi miso sclk
+DigitalOut cs(p14);
+int main()
+{
+    
+    cs = 1;                //initialisation de CS à ‘1’
+    spi.format(16,0);       //communication sur 16 bits/ mode 0
+    spi.frequency(1000000); //fréquence de 1MHz
+    while(1) {
+        cs = 0;                 //CS à ‘0’ <-> activation du circuit
+        unsigned int valeur = spi.write(0x00); //Lecture de la valeur en //écrivant n’importe //quoi...
+        valeur = (valeur>>1)&0x0FFF;           //Mise en forme des deux
+//bits lus et décalage de //1bits pour ne pas tenir//compte du deuxième B1
+        printf("valeur lue = %d\n\r", valeur); //Affichage sur la //console
+        cs = 1;                     //CS à ‘1’ <-> désactivation
+    }
+}*/
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/TextLCD.lib	Thu Jun 25 16:30:18 2020 +0000
@@ -0,0 +1,1 @@
+https://os.mbed.com/users/simon/code/TextLCD/#308d188a2d3a
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed.bld	Thu Jun 25 16:30:18 2020 +0000
@@ -0,0 +1,1 @@
+https://os.mbed.com/users/mbed_official/code/mbed/builds/3a7713b1edbc
\ No newline at end of file