Bonjour cher aîné, voila mon programme d'affichage de vitesse de rotation dans le moniteur série de mon PC et ça fonctionne bien. j'aimerai passé du port Serie du PC au LCD 1602.
j'aimerai affiché cette vitesse sur mon écran LCD I2C. j'ai changé tout les Serials en LCD et quand je téléverse le programme et que je met le moteur en marche, rien ne s'affiche sur mon LCD. Alors je sollicite votre aide afin de résoudre mon problème.
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56 #include <TimerOne.h> const byte Led_Builtin; const byte Sensor = 2; const byte Green_Led =12; const byte Red_Led =8; const byte relais =10; volatile int cnt = 0; volatile int revs = 0; int speedLow = 500; int speedHigh = 2000; void ISR_pulse(){ cnt++; } void ISR_timerone(){ Timer1.detachInterrupt(); Serial.print("Vitesse_moteur:"); revs = (cnt*30.00); Serial.print(revs); Serial.println("RPM-"); cnt = 0; Timer1.attachInterrupt(ISR_timerone); } void setup() { // put your setup code here, to run once: Serial.begin(115200); pinMode(Led_Builtin,OUTPUT); digitalWrite(Led_Builtin, LOW); pinMode(Green_Led,OUTPUT); pinMode(Red_Led,OUTPUT); pinMode(relais,OUTPUT); attachInterrupt(digitalPinToInterrupt(Sensor), ISR_pulse,RISING); Timer1.initialize (2000000); Timer1.attachInterrupt(ISR_timerone); } void loop() { // put your main code here, to run repeatedly: if ( revs > speedLow){ digitalWrite(Green_Led,HIGH); } else{ digitalWrite(Green_Led,LOW); } if ( revs > speedHigh){ digitalWrite(Red_Led,HIGH); digitalWrite(relais,HIGH); } else{ digitalWrite(Red_Led,LOW); digitalWrite(relais,LOW); } }
merci !!!
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64 #include <Wire.h> #include <LiquidCrystal_I2C.h> #include <TimerOne.h> LiquidCrystal_I2C lcd(0x27,16,2); const byte Led_Builtin; const byte Sensor = 2; const byte Green_Led =12; const byte Red_Led =8; const byte relais =10; volatile int cnt = 0; volatile int revs = 0; int speedLow = 500; int speedHigh = 2000; void ISR_pulse(){ cnt++; } void ISR_timerone(){ lcd.init(); Timer1.detachInterrupt(); lcd.backlight(); lcd.setCursor(0,1); lcd.print("Vitesse_moteur:"); lcd.setCursor(0,1); revs = (cnt*30.00); lcd.print(revs); lcd.println("RPM-"); cnt = 0; Timer1.attachInterrupt(ISR_timerone); } void setup() { // put your setup code here, to run once: //lcd.begin(); pinMode(Led_Builtin,OUTPUT); digitalWrite(Led_Builtin, LOW); pinMode(Green_Led,OUTPUT); pinMode(Red_Led,OUTPUT); pinMode(relais,OUTPUT); attachInterrupt(digitalPinToInterrupt(Sensor), ISR_pulse,RISING); Timer1.initialize (2000000); Timer1.attachInterrupt(ISR_timerone); } void loop() { // put your main code here, to run repeatedly: if ( revs > speedLow){ digitalWrite(Green_Led,HIGH); } else{ digitalWrite(Green_Led,LOW); } if ( revs > speedHigh){ digitalWrite(Red_Led,HIGH); digitalWrite(relais,HIGH); } else{ digitalWrite(Red_Led,LOW); digitalWrite(relais,LOW); } }







Répondre avec citation
Partager