Bonjour,
(bouton = capteur tactile, j'ai une teensy lc et chaque leds à son "bouton")
Je suis à la phase final de mon projet et j'ai besoin d'aide pour faire en sorte que lorsque je touche le "bouton", la led reste allumée une seconde. Sauf que j'ai une matrice de 9 leds avec chacune un "bouton" pour pouvoir activer et lorsque par exemple je met delay dans le programme et que je touche le "bouton" et bien la led s'allume mais je ne peux pas allumer d'autres leds tant qu'elle ne s'éteint pas. J'aimerais quelque chose de fluide, en gros, lorsque je touche une led, elle s'allume et quand je relache elle reste allumée au moins 1 seconde et pendant qu'elle reste allumée je touche déjà un autre "bouton" pour qu'une autre s'allume et quand je relâche elle reste également 1 seconde allumée. J'espère que c'est assez clair. Dites moi si c'est compréhensible? Merci en avance !
Voici mon programme:
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
65
66
67
68
69
70
71
72
73
74
75 int ledPin = 11; int ledPin1 = 2; int ledPin2 = 3; int ledPin3 = 5; int ledPin4 = 20; int ledPin5 = 6; int ledPin6 = 7; int ledPin7 = 8; int ledPin8 = 9; const uint8_t touchPin = 0; const uint8_t touchPin1 = 1; const uint8_t touchPin2 = 15; const uint8_t touchPin3 = 16; const uint8_t touchPin4 = 4; const uint8_t touchPin5 = 18; const uint8_t touchPin6 = 19; const uint8_t touchPin7 = 22; const uint8_t touchPin8 = 23; int touchVal; const int threshold = 840; void setup() { Serial.begin(115200); pinMode(ledPin, OUTPUT); pinMode(ledPin1, OUTPUT); pinMode(ledPin2, OUTPUT); pinMode(ledPin3, OUTPUT); pinMode(ledPin4, OUTPUT); pinMode(ledPin5, OUTPUT); pinMode(ledPin6, OUTPUT); pinMode(ledPin7, OUTPUT); pinMode(ledPin8, OUTPUT); } void loop() { { touchVal = touchRead(touchPin); Serial.print(touchVal); digitalWrite(ledPin, touchVal > threshold); } { touchVal = touchRead(touchPin1); Serial.print(touchVal); digitalWrite(ledPin1, touchVal > threshold); } { touchVal = touchRead(touchPin2); Serial.print(touchVal); digitalWrite(ledPin2, touchVal > threshold); } { touchVal = touchRead(touchPin3); Serial.print(touchVal); digitalWrite(ledPin3, touchVal > threshold); } { touchVal = touchRead(touchPin4); Serial.print(touchVal); digitalWrite(ledPin4, touchVal > threshold); } { touchVal = touchRead(touchPin5); Serial.print(touchVal); digitalWrite(ledPin5, touchVal > threshold); } { touchVal = touchRead(touchPin6); Serial.print(touchVal); digitalWrite(ledPin6, touchVal > threshold); } { touchVal = touchRead(touchPin7); Serial.print(touchVal); digitalWrite(ledPin7, touchVal > threshold); } { touchVal = touchRead(touchPin8); delay(750); Serial.print(touchVal); digitalWrite(ledPin8, touchVal > threshold); } }
Partager