0% found this document useful (0 votes)
13 views

comptrondu

Uploaded by

uchihamadaraag
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
13 views

comptrondu

Uploaded by

uchihamadaraag
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 19

//tp1 app1

int LED_Rouge=13;

void setup() {

pinMode(LED_Rouge, OUTPUT);

void loop() {

digitalWrite(LED_Rouge, HIGH);

delay(1000);

digitalWrite(LED_Rouge, LOW);

delay(1000);

//tp1app2

int LED_Rouge=13;

int LED_Orange=12;

int LED_Vert=11;

void setup() {

pinMode(LED_Rouge,OUTPUT);

pinMode(LED_Orange,OUTPUT);

pinMode(LED_Vert,OUTPUT);

void loop() {

digitalWrite(LED_Rouge, HIGH);

delay(4000);

digitalWrite(LED_Rouge, LOW);

digitalWrite(LED_Orange, HIGH);

delay(1000);
digitalWrite(LED_Orange, LOW);

digitalWrite(LED_Vert, HIGH);

delay(4000);

digitalWrite(LED_Vert, LOW);

//tp1app3

int LED_Rouge=13;

int Button=1;

void setup() {

pinMode(LED_Rouge,OUTPUT);

pinMode(Button,INPUT);

void loop() {

if(digitalRead(Button)==HIGH){

digitalWrite(LED_Rouge,HIGH);

else{

digitalWrite(LED_Rouge,LOW);

//tp1app4

int LED_Rouge=12;

int Button1=1;

int Button2=2;

void setup() {
pinMode(LED_Rouge,OUTPUT);

pinMode(Button1,INPUT);

pinMode(Button2,INPUT);

void loop() {

if(digitalRead(Button1)==HIGH){

digitalWrite(LED_Rouge,HIGH);

if(digitalRead(Button2)==HIGH){

digitalWrite(LED_Rouge,LOW);

//tp3app1

// Définir les broches de l'Arduino connectées aux segments de l'afficheur

const int segmentPins[7] = {8,7,6,5,4,3,2};

// Tableau des configurations pour afficher les chiffres de 0 à 9

const byte digits[10][7] = {

// a, b, c, d, e, f, g

{1, 1, 1, 1, 1, 1, 0}, // 0

{0, 1, 1, 0, 0, 0, 0}, // 1

{1, 1, 0, 1, 1, 0, 1}, // 2

{1, 1, 1, 1, 0, 0, 1}, // 3

{0, 1, 1, 0, 0, 1, 1}, // 4

{1, 0, 1, 1, 0, 1, 1}, // 5

{1, 0, 1, 1, 1, 1, 1}, // 6
{1, 1, 1, 0, 0, 0, 0}, // 7

{1, 1, 1, 1, 1, 1, 1}, // 8

{1, 1, 1, 1, 0, 1, 1} // 9

};

void setup() {

// Configurer les broches comme sorties

for (int i = 0; i < 7; i++) {

pinMode(segmentPins[i], OUTPUT);

void loop() {

// Boucle pour compter de 0 à 9

for (int i = 0; i < 10; i++) {

displayDigit(i);

delay(1000); // Attendre 1 seconde avant de passer au chiffre suivant

void displayDigit(int num) {

// Afficher le chiffre en activant/désactivant les segments

for (int i = 0; i < 7; i++) {

digitalWrite(segmentPins[i], digits[num][i]);

//tp3app2

// Définition des broches pour les segments de l'afficheur 7 segments

const int a = 8;
const int b = 7;

const int c = 6;

const int d = 5;

const int e = 4;

const int f = 3;

const int g = 2;

// Définition de la broche du bouton poussoir

const int buttonPin = A1;

int digits[10][7] = {

{1, 1, 1, 1, 1, 1, 0}, // 0

{0, 1, 1, 0, 0, 0, 0}, // 1

{1, 1, 0, 1, 1, 0, 1}, // 2

{1, 1, 1, 1, 0, 0, 1}, // 3

{0, 1, 1, 0, 0, 1, 1}, // 4

{1, 0, 1, 1, 0, 1, 1}, // 5

{1, 0, 1, 1, 1, 1, 1}, // 6

{1, 1, 1, 0, 0, 0, 0}, // 7

{1, 1, 1, 1, 1, 1, 1}, // 8

{1, 1, 1, 1, 0, 1, 1} // 9

};

int currentDigit = 0;

bool lastButtonState = LOW;

void setup() {

// Initialiser les broches comme des sorties

pinMode(a, OUTPUT);
pinMode(b, OUTPUT);

pinMode(c, OUTPUT);

pinMode(d, OUTPUT);

pinMode(e, OUTPUT);

pinMode(f, OUTPUT);

pinMode(g, OUTPUT);

// Initialiser la broche du bouton comme une entrée

pinMode(buttonPin, INPUT);

// Afficher le premier chiffre

displayDigit(currentDigit);

void loop() {

bool buttonState = digitalRead(buttonPin);

if (buttonState == HIGH && lastButtonState == LOW) {

currentDigit = (currentDigit + 1) % 10;

displayDigit(currentDigit);

delay(200); // Debounce delay

lastButtonState = buttonState;

void displayDigit(int digit) {

digitalWrite(a, digits[digit][0]);

digitalWrite(b, digits[digit][1]);
digitalWrite(c, digits[digit][2]);

digitalWrite(d, digits[digit][3]);

digitalWrite(e, digits[digit][4]);

digitalWrite(f, digits[digit][5]);

digitalWrite(g, digits[digit][6]);

//tp4app1

The circuit:

* LCD RS pin to digital pin 12

* LCD Enable pin to digital pin 11

* LCD D4 pin to digital pin 5

* LCD D5 pin to digital pin 4

* LCD D6 pin to digital pin 3

* LCD D7 pin to digital pin 2

* LCD R/W pin to ground

* LCD VSS pin to ground

* LCD VCC pin to 5V

* 10K resistor:

* ends to +5V and ground

* wiper to LCD VO pin (pin 3)

// include the library code:

#include <LiquidCrystal.h>

// initialize the library by associating any needed LCD interface pin

// with the arduino pin number it is connected to

const int rs = 12, en = 11, d4 = 5, d5 = 4, d6 = 3, d7 = 2;

LiquidCrystal lcd(rs, en, d4, d5, d6, d7);


void setup() {

// set up the LCD's number of columns and rows:

lcd.begin(16, 2);

// Print a message to the LCD.

lcd.print("hello, world!");

void loop() {

// set the cursor to column 0, line 1

// (note: line 1 is the second row, since counting begins with 0):

lcd.setCursor(0, 1);

// print the number of seconds since reset:

lcd.print(millis() / 1000);

//tp4app2

// include the library code:

#include <LiquidCrystal.h>

// initialize the library by associating any needed LCD interface pin

// with the arduino pin number it is connected to

const int rs = 12, en = 11, d4 = 5, d5 = 4, d6 = 3, d7 = 2;

LiquidCrystal lcd(rs, en, d4, d5, d6, d7);

void setup() {

// set up the LCD's number of columns and rows:

lcd.begin(16, 2);
// Print a message to the LCD.

void loop() {

// set the cursor to column 0, line 1

// (note: line 1 is the second row, since counting begins with 0):

lcd.setCursor(4,0);

lcd.print("BIENVENUE");

lcd.setCursor(6,1);

lcd.print("ISET M");

//tp4app3

The circuit:

* LCD RS pin to digital pin 12

* LCD Enable pin to digital pin 11

* LCD D4 pin to digital pin 5

* LCD D5 pin to digital pin 4

* LCD D6 pin to digital pin 3

* LCD D7 pin to digital pin 2

* LCD R/W pin to ground

* 10K resistor:

* ends to +5V and ground

* wiper to LCD VO pin (pin 3)

// include the library code:

#include <LiquidCrystal.h>

// initialize the library by associating any needed LCD interface pin


// with the arduino pin number it is connected to

const int rs = 12, en = 11, d4 = 5, d5 = 4, d6 = 3, d7 = 2;

LiquidCrystal lcd(rs, en, d4, d5, d6, d7);

void setup() {

// set up the LCD's number of columns and rows:

lcd.begin(16, 2);

// Print a message to the LCD.

lcd.print("hello, world!");

delay(1000);

void loop() {

// scroll 13 positions (string length) to the left

// to move it offscreen left:

for (int positionCounter = 0; positionCounter < 13; positionCounter++) {

// scroll one position left:

lcd.scrollDisplayLeft();

// wait a bit:

delay(150);

// scroll 29 positions (string length + display length) to the right

// to move it offscreen right:

for (int positionCounter = 0; positionCounter < 29; positionCounter++) {

// scroll one position right:

lcd.scrollDisplayRight();

// wait a bit:

delay(150);
}

// scroll 16 positions (display length + string length) to the left

// to move it back to center:

for (int positionCounter = 0; positionCounter < 16; positionCounter++) {

// scroll one position left:

lcd.scrollDisplayLeft();

// wait a bit:

delay(150);

// delay at the end of the full loop:

delay(1000);

//tp4app4

#include <LiquidCrystal.h>

// Initialisation de la bibliothèque LCD avec les broches correspondantes

LiquidCrystal lcd(12, 11, 5, 4, 3, 2);

int pulsePin = 7; // Broche où le capteur d'impulsions est connecté

int pulseCount = 0; // Compteur d'impulsions

void setup() {

lcd.begin(16, 2); // Initialisation de l'écran LCD (16 colonnes et 2 lignes)

pinMode(pulsePin, INPUT); // Définir la broche du capteur comme entrée

lcd.print("Impulsions:"); // Afficher le texte initial sur l'écran LCD


}

void loop() {

if (digitalRead(pulsePin) == HIGH) { // Vérifier si une impulsion est


détectée

pulseCount++; // Incrémenter le compteur d'impulsions

lcd.setCursor(0, 1); // Déplacer le curseur à la deuxième ligne

lcd.print(pulseCount); // Afficher le nombre d'impulsions

delay(500); // Attendre un court instant pour éviter les rebonds

//tp4app5

#include <LiquidCrystal.h>

// Initialisation de la bibliothèque LCD avec les broches correspondantes

LiquidCrystal lcd(12, 11, 5, 4, 3, 2);

int buttonB1 = 6; // Broche du bouton B1

int buttonB2 = 7; // Broche du bouton B2

int buttonB3 = 13; // Broche du bouton B3

int ledD1 = 8; // Broche de la diode D1

int ledD2 = 9; // Broche de la diode D2

int ledD3 = 10; // Broche de la diode D3

void setup() {

lcd.begin(16, 2); // Initialisation de l'écran LCD (16 colonnes et 2 lignes)

pinMode(buttonB1, INPUT); // Définir la broche du bouton B1 comme


entrée
pinMode(buttonB2, INPUT); // Définir la broche du bouton B2 comme
entrée

pinMode(buttonB3, INPUT); // Définir la broche du bouton B3 comme


entrée

pinMode(ledD1, OUTPUT); // Définir la broche de la diode D1 comme


sortie

pinMode(ledD2, OUTPUT); // Définir la broche de la diode D2 comme


sortie

pinMode(ledD3, OUTPUT); // Définir la broche de la diode D3 comme


sortie

void loop() {

if (digitalRead(buttonB1) == HIGH) { // Vérifier si le bouton B1 est appuyé

lcd.clear();

lcd.print("BONJOUR"); // Afficher 'BONJOUR' sur l'écran LCD

digitalWrite(ledD1, HIGH); // Allumer la diode D1

delay(500); // Attendre 500 ms

digitalWrite(ledD1, LOW); // Éteindre la diode D1

delay(500); // Attendre 500 ms

} else if (digitalRead(buttonB2) == HIGH) { // Vérifier si le bouton B2 est


appuyé

lcd.clear();

lcd.print("BONSOIR"); // Afficher 'BONSOIR' sur l'écran LCD

digitalWrite(ledD2, HIGH); // Allumer la diode D2

delay(500); // Attendre 500 ms

digitalWrite(ledD2, LOW); // Éteindre la diode D2

delay(500); // Attendre 500 ms

} else if (digitalRead(buttonB3) == HIGH) { // Vérifier si le bouton B3 est


appuyé

lcd.clear();
lcd.print("SALAM"); // Afficher 'SALAM' sur l'écran LCD

digitalWrite(ledD3, HIGH); // Allumer la diode D3

delay(500); // Attendre 500 ms

digitalWrite(ledD3, LOW); // Éteindre la diode D3

delay(500); // Attendre 500 ms

//Tp5app1

/* @file HelloKeypad.pde

|| @version 1.0

|| @author Alexander Brevig

|| @contact [email protected]

||

|| @description

|| | Demonstrates the simplest use of the matrix Keypad library.

|| #

*/

#include <Keypad.h>

const byte ROWS = 4; //four rows

const byte COLS = 3; //three columns

char keys[ROWS][COLS] = {

{'1','2','3'},

{'4','5','6'},

{'7','8','9'},

{'*','0','#'}

};

byte rowPins[ROWS] = {5, 4, 3, 2}; //connect to the row pinouts of the


keypad
byte colPins[COLS] = {8, 7, 6}; //connect to the column pinouts of the
keypad

Keypad keypad = Keypad( makeKeymap(keys), rowPins, colPins, ROWS,


COLS );

void setup(){

Serial.begin(9600);

void loop(){

char key = keypad.getKey();

if (key){

Serial.println(key);

//tp5app2

#include <Keypad.h>

#include <LiquidCrystal.h>

// Initialiser la bibliothèque avec les broches de connexion de l'écran LCD

LiquidCrystal lcd(12, 11, 5, 4, 3, 2);

// Définir les dimensions du clavier matriciel

const byte ROWS = 4; // Quatre rangées

const byte COLS = 3; // Trois colonnes

// Définir les caractères pour chaque touche du clavier


char keys[ROWS][COLS] = {

{'1', '2', '3'},

{'4', '5', '6'},

{'7', '8', '9'},

{'*', '0', '#'}

};

// Connecter les broches de rangées et de colonnes du clavier à l'Arduino

byte rowPins[ROWS] = {9, 8, 7, 6}; // Connecter aux broches du clavier

byte colPins[COLS] = {A3, A2, A1}; // Connecter aux broches du clavier

// Initialiser le clavier

Keypad keypad = Keypad(makeKeymap(keys), rowPins, colPins, ROWS,


COLS);

void setup() {

// Initialiser l'écran LCD

lcd.begin(16, 2);

lcd.print("Entrez une touche:");

void loop() {

char key = keypad.getKey();

if (key) {

// Si une touche est pressée, l'afficher sur le LCD

lcd.clear();

lcd.setCursor(0, 0); // Positionner le curseur sur la première ligne

lcd.print("Touche:");
lcd.setCursor(0, 1); // Positionner le curseur sur la deuxième ligne

lcd.print(key);

}//tp5app3

#include <Keypad.h>

#include <LiquidCrystal.h>

// Initialiser la bibliothèque avec les broches de connexion de l'écran LCD

LiquidCrystal lcd(12, 11, 5, 4, 3, 2);

// Définir les dimensions du clavier matriciel

const byte ROWS = 4; // Quatre rangées

const byte COLS = 3; // Trois colonnes

// Définir les caractères pour chaque touche du clavier

char keys[ROWS][COLS] = {

{'1', '2', '3'},

{'4', '5', '6'},

{'7', '8', '9'},

{'*', '0', '#'}

};

// Connecter les broches de rangées et de colonnes du clavier à l'Arduino

byte rowPins[ROWS] = {9, 8, 7, 6}; // Connecter aux broches du clavier

byte colPins[COLS] = {A3, A2, A1}; // Connecter aux broches du clavier

// Initialiser le clavier

Keypad keypad = Keypad(makeKeymap(keys), rowPins, colPins, ROWS,


COLS);
// Mot de passe défini

const String password = "2050#";

String inputPassword = "";

void setup() {

// Initialiser l'écran LCD

lcd.begin(16, 2);

lcd.print("Enter Password:");

void loop() {

char key = keypad.getKey();

if (key) {

// Si une touche est pressée, l'ajouter au mot de passe entré

inputPassword += key;

// Afficher les caractères saisis sur l'écran LCD

lcd.clear();

lcd.setCursor(0, 0); // Positionner le curseur sur la première ligne

lcd.print("Enter Password:");

lcd.setCursor(0, 1); // Positionner le curseur sur la deuxième ligne

lcd.print(inputPassword);

// Si le mot de passe est complet (fini par '#')

if (key == '#') {

// Vérifier si le mot de passe est correct

if (inputPassword == password) {
lcd.clear();

lcd.setCursor(0, 0);

lcd.print("OPEN");

} else {

lcd.clear();

lcd.setCursor(0, 0);

lcd.print("ERREUR");

// Réinitialiser le mot de passe entré après vérification

inputPassword = "";

delay(2000); // Attendre 2 secondes avant de réinitialiser l'affichage

lcd.clear();

lcd.setCursor(0, 0);

lcd.print("Enter Password:");

You might also like