Magie de L'ARDUINO:

avatar

image.png

https://tse4.mm.bing.net/th?id=OIP.WGDTTaW0mMGeEmgs4J5nzQHaEK

Specifications

We want to program a digital wattmeter to:

📌 Read the value of the direct current absorbed by a DC load. (You can use a potentiometer instead of the measured current sensor).

0V corresponds to 0A

5 V corresponds to 20 A

📌 Read the value of the direct voltage applied to a DC load. (You can use a potentiometer instead of the measured voltage sensor).

0V corresponds to 0V

5 V corresponds to 100 V.

📌 Indicate on 4 led diodes, the percentage of the measured power.
· Led1 lights up when the measured power is between 0% and 25% of Pmax,

· (Led1 and Led 2) light up when the measured power is between 25% and 50% of Pmax,

· (Led1, Led 2 and Led 3) light up when the measured power is between 50% and 75% of Pmax,

· (Led1, Led 2, Led 3 and Led 4) light up when the measured power is between 75% and 100% of Pmax,

Note: PMAX = IMAX.UMAX = 20 X 100 = 2000 W.

📌 Display on an LCD display (2x16):
The measured current (Imes =… .. A)

· The measured voltage (Umes =…. V);

The measured power (Pmes = …… .W)

Realization:

📜 Material list:

  • 220 ohm resistor (4)
  • potentiometer 10k ohms (3)
  • Led diode (4)
  • Display on an LCD display (2x16)
  • Connection wires
  • ARDUINO UNO card
  • Breadbord
  • PC

With tinkercard :link:https://www.tinkercad.com/things/gtHwr4iYvIC-funky-gaaris-leelo/editel?sharecode=ou1LTfyOR-jzJdU2t1oH9DPJ0ijXAYGjMbNBi2ezJqk

image.png

With IDE ARDUINO:

#include <LiquidCrystal.h> //inclure la bibliothèque
const int rs = 7;//déclaration constante de broche
const int E = 6;//déclaration constante de broche
const int d4 = 5;//déclaration constante de broche
const int d5 = 4;//déclaration constante de broche
const int d6 = 3;// déclaration constante de broche
const int d7 = 2;//déclaration constante de broche
LiquidCrystal lcd (rs,E,d4,d5,d6,d7); //initialisation lcd en mode 2 bits
#define Potentiometre1 = A0; //entré analogique du courant
#define Potentiometre2 = A1; //entré analogique de tension
//brochage des leds
#define LED1_PIN 9 //la led 1 liée à la broche 9 de la carte
#define LED2_PIN 10 // led2 à la broche10
#define LED3_PIN 11 //led3 à la broche n°11
#define LED4_PIN 12 // led4 au n°12
//déclaration et initialisation des variables courant, tension et puissance
int valeurA0 = 0;
int valeurA1 = 0;
float Imes = 0;
float Umes = 0;
float Pmes = 0;
void setup()
{
lcd.begin(16,2); //initialise le lcd avec 16 colonnes et 2 lignes
pinMode(A0,INPUT);//entrée analogique(courant)sur la brocheA0
pinMode(A1,INPUT);//entrée analogique(tension)sur la brocheA1
pinMode(LED1_PIN ,OUTPUT);//choisir la broche 9 en sortie numérique vers la diode 1
pinMode(LED2_PIN ,OUTPUT);//choisir la broche 10 en sortie numérique vers la diode 2
pinMode(LED3_PIN ,OUTPUT);//choisir la broche 11 en sortie numérique vers la diode 3
pinMode(LED4_PIN ,OUTPUT);//choisir la broche 12 en sortie numérique vers la diode 4
}
void loop() {
valeurA0 = analogRead(A0);//lire la valeur analogique du courant puis la convertir
Imes = (valeurA020.0/1023.0);//valeur du courant
valeurA1 = analogRead(A1);//lire la valeur convertie de la tension
Umes = (valeurA1
100.0/1023.0);//valeur réelle de la tension
Pmes = (Umes*Imes);//calculer la valeur de la puissance
//afficher le courant , la tension, la puissance sur LCD
lcd.setCursor(0,0);//initialiser l'afficheur lcd
lcd.print("Imes=");//afficher Imesuré
lcd.setCursor(5,0);//déplacer le curseur sur la colonne 6 de la ligne1
lcd.print(Imes);//afficher la valeur du courant
lcd.setCursor(9,0);//déplacer le curseur sur la colonne11 de la même ligne
lcd.print("A");//afficher l'unité Ampère
lcd.setCursor(11,0);//déplacer le curseur sur la colonne12 de la même ligne
lcd.print("Umes=");
lcd.setCursor(0,1);//déplacer le curseur sur la colonne1 du deuxième ligne
lcd.print(Umes);//afficher la valeur de la tension
lcd.setCursor(4,1);//déplacer le curseur
lcd.print("V");//afficher l'unité Volt
lcd.setCursor(6,1);//déplacer le curseur sur la colonne7 de la deuxième ligne
lcd.print("Pmes=");
lcd.setCursor(10,1);//déplacer le curseur vers la colonne12 de la mème ligne
lcd.print(Pmes);//afficher la valeur de la Puissance
lcd.setCursor(15,1);//déplacer le curseur
lcd.print("W");//afficher l'unité Watt
//commande des LEDS selon le pourcentage de Pmesurée
digitalWrite(LED1_PIN ,LOW);// initialiser les 4 leds à 0
digitalWrite(LED2_PIN ,LOW);
digitalWrite(LED3_PIN ,LOW);
digitalWrite(LED4_PIN ,LOW);
if (Pmes > 0 && Pmes <= 500);//si la puissance est comprise entre 0 et 25 pour cent de sa valeur ,allumer la led1
{
digitalWrite(LED1_PIN ,HIGH);
}
if (Pmes > 500 && Pmes <= 1000)//si la valeur de la puissance est entre 25 et 50 pour cent allumer led1 et led2
{
digitalWrite(LED1_PIN ,HIGH);
digitalWrite(LED2_PIN ,HIGH);
}
if (Pmes > 1000 && Pmes <= 1500)//si P est comprise entre50et75pour cent allumer led1,2,3
{
digitalWrite(LED1_PIN ,HIGH);
digitalWrite(LED2_PIN ,HIGH);
digitalWrite(LED3_PIN ,HIGH);
}
if (Pmes > 1500 && Pmes <= 2000)//enfin si la condition est vérifiée allumer les 4 diodes
{
digitalWrite(LED1_PIN ,HIGH);
digitalWrite(LED2_PIN ,HIGH);
digitalWrite(LED3_PIN ,HIGH);
digitalWrite(LED4_PIN ,HIGH);
}
}



0
0
0.000
1 comments
avatar

Congratulations @agrebi75! You have completed the following achievement on the Hive blockchain and have been rewarded with new badge(s):

You distributed more than 400 upvotes.
Your next target is to reach 500 upvotes.

You can view your badges on your board and compare yourself to others in the Ranking
If you no longer want to receive notifications, reply to this comment with the word STOP

Check out the last post from @hivebuzz:

Christmas Challenge - 1000 Hive Power Delegation Winner
Merry Christmas - Challenge Feedback - Win a 1000 HP delegation
Support the HiveBuzz project. Vote for our proposal!
0
0
0.000