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: mbed
Revision 6:288fd7e43c6e, committed 2021-11-19
- Comitter:
- Giamarchi
- Date:
- Fri Nov 19 17:29:11 2021 +0000
- Parent:
- 5:cfe7e243bb5f
- Commit message:
- Correction TP_01
Changed in this revision
| 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 |
--- a/main.cpp Fri Oct 29 22:14:53 2021 +0000
+++ b/main.cpp Fri Nov 19 17:29:11 2021 +0000
@@ -3,30 +3,76 @@
// Initiation à la Programmation
// Auteur : Frédéric Giamarchi
-// Date : 28 oct 2021
+// Date : 19 nov 2021
// TP 01 : Controle de 3 DELs en même temps
-// Modifier le programme pour obtenir que 3 Dels (Rouge, Verte et Bleu)
+// Modifier le programme pour obtenir que 3 Dels (Rouge, Jaune et Verte)
// clignotent à 3 fréquences différentes (1Hz, 2Hz et 4Hz).
+
+// Correction
//==============================================================================
#include "mbed.h"
// Déclaration du sens des broches
+DigitalOut DEL_RO(PA_11); // Ligne PA_11 sur la carte Nucléo
+DigitalOut DEL_JA(PB_5); // Ligne PB_5 sur la carte Nucléo
+DigitalOut DEL_VE(PB_4); // Ligne PB_4 sur la carte Nucléo
-DigitalOut DEL_VE(LED1); // Ligne PB_3 sur la carte Nucléo
+// Déclaration des variables
+uint8_t compteur; //
//==============================================================================
// Début du Programme
int main() // Fonction principale
{
-
+
//==============================================================================
while(1) // Boucle Infinie
{
- DEL_VE = 1; // Broche à 1 (DEL allumée)
- wait_ms(100); // Temporisation de 100ms (0.1s)
- DEL_VE = 0; // Broche à 0 (DEL éteinte)
- wait_ms(900);
-
+// Solution n°1
+/*
+ DEL_RO = 1;
+ DEL_JA = 1;
+ DEL_VE = 1; // Broche à 1 (DEL Verte allumée)
+ wait_ms(125); // Temporisation de 125ms (0.125s)
+ DEL_VE = 0; // Broche à 0 (DEL Verte éteinte)
+ wait_ms(125); // Temporisation de 125ms (0.125s)
+ DEL_JA = 0;
+ DEL_VE = 1; // Broche à 0 (DEL Verte éteinte)
+ wait_ms(125); // Temporisation de 125ms (0.125s)
+ DEL_VE = 0; // Broche à 0 (DEL Verte éteinte)
+ wait_ms(125); // Temporisation de 125ms (0.125s)
+ DEL_RO = 0;
+ DEL_JA = 1;
+ DEL_VE = 1; // Broche à 1 (DEL Verte allumée)
+ wait_ms(125); // Temporisation de 125ms (0.125s)
+ DEL_VE = 0; // Broche à 0 (DEL Verte éteinte)
+ wait_ms(125); // Temporisation de 125ms (0.125s)
+ DEL_JA = 0;
+ DEL_VE = 1; // Broche à 0 (DEL Verte éteinte)
+ wait_ms(125); // Temporisation de 125ms (0.125s)
+ DEL_VE = 0; // Broche à 0 (DEL Verte éteinte)
+ wait_ms(125); // Temporisation de 125ms (0.125s)
+*/
+// Solution n°2
+/*
+ DEL_RO = !DEL_RO; // Inversion logique sur la broche
+ DEL_JA = !DEL_JA;
+ DEL_VE = !DEL_VE;
+ wait_ms(125); // Temporisation de 125ms (0.125s)
+ DEL_VE = !DEL_VE; // Broche à 0 (DEL Verte éteinte)
+ wait_ms(125); // Temporisation de 125ms (0.125s)
+ DEL_JA = !DEL_JA;
+ DEL_VE = !DEL_VE; // Broche à 0 (DEL Verte éteinte)
+ wait_ms(125); // Temporisation de 125ms (0.125s)
+ DEL_VE = !DEL_VE; // Broche à 0 (DEL Verte éteinte)
+ wait_ms(125); // Temporisation de 125ms (0.125s)
+*/
+// Solution n°3
+ wait_ms(125); // Temporisation de 125ms (0.125s)
+ compteur = compteur + 1;
+ DEL_VE = compteur & 0x01;
+ DEL_JA = compteur & 0x02;
+ DEL_RO = compteur & 0x04;
} // Fin du while(1)
//==============================================================================
} // Fin du Programme
--- a/mbed.bld Fri Oct 29 22:14:53 2021 +0000 +++ b/mbed.bld Fri Nov 19 17:29:11 2021 +0000 @@ -1,1 +1,1 @@ -https://os.mbed.com/users/mbed_official/code/mbed/builds/e95d10626187 \ No newline at end of file +https://os.mbed.com/users/mbed_official/code/mbed/builds/65be27845400 \ No newline at end of file