Aide pour Teensy Lc

JPP39

New member
Bonjour, je viens de recevoir une Teensy LC et j'aimerais savoir si quelqu'un à un programme rapide pour faire que lorsque je touche un Gpio tactile, ça allume une Led et quand je relâche elle s'éteint. Après je me débrouillerai pour allumer 9 autres Leds avec 9 autres Gpio. (Je ne connais rien au langage de programme) Mais si vous avez un peu de temps pour m'expliquer vôtre programme ce serait top ! Je vous remercie beaucoup pour vôtre temps! Désolé si je ne suis pas sur le bon fil! Bonne journée !

Mon montage :

https://apis.mail.yahoo.com/ws/v3/m...lNorrin&downloadWhenThumbnailFails=true&pid=2
 
Web translate:

Help for Teensy Lc
Hello, I just received a Teensy LC and I would like to know if someone has a quick program to make that when I touch a Touch Gpio, it turns on an LED and when I release it turns off. After I will manage to light 9 more LEDs with 9 other Gpio. (I don't know anything about program language) But if you have a little time to explain your program to me it would be great! Thank you very much for your time! Sorry if I'm not on the right track! Have a nice day!
 
Hello, I just received a Teensy LC and I would like to know if someone has a quick program to make that when I touch a Touch Gpio, it turns on an LED and when I release it turns off. After I will manage to light 9 more LEDs with 9 other Gpio. (I don't know anything about program language) But if you have a little time to explain your program to me it would be great! Thank you very much for your time! Sorry if I'm not on the right track! Have a nice day! Sorry i'm french!
 
Voila, touchRead() starter sketch for LC:

Code:
#define THRESHOLD 2000
#define LEDPIN 13

void setup() {
  Serial.begin(9600);
  while (!Serial);
  pinMode(LEDPIN, OUTPUT);
}

void loop() {
  int v = touchRead(23);   // touch pin
  Serial.println(v);
  if (v > THRESHOLD) digitalWrite(LEDPIN, HIGH);
  else digitalWrite(LEDPIN, LOW);
  delay(1000);
}
Touch jumper wire to pin 23. touchRead() can take several milliseconds ...
Experiment to determine THRESHOLD for your environment.


Code:
835
882
959
4206
4670
4123
4685
4903
839
822
822

----------------------------------------------------------
9-pin version: you need 9 LEDs and 9 resistors (e.g. 470 ohm or more)
Code:
#define THRESHOLD 2000
#define PINS 9

int leds[PINS] = {2, 5,  6,  7,  8,  9, 10, 11, 13}; // LEDs;
int tch[PINS] =  {3, 4, 15, 16, 17, 18, 19, 22, 23};  // touch

void setup() {
  Serial.begin(9600);
 // while (!Serial);
  for (int i = 0; i < PINS; i++) pinMode(leds[i], OUTPUT);
}

void loop() {
  for (int i = 0; i < PINS; i++) {
    int v = touchRead(tch[i]);   // touch pin
    //Serial.println(v);
    if (v > THRESHOLD) digitalWrite(leds[i], HIGH);
    else digitalWrite(leds[i], LOW);
  }
  //  delay(1000);
}

How does TouchRead do its measurment?
 
Last edited:
Back
Top