Outils pour utilisateurs

Outils du site


wiki:divers:preparation_are_2019

Différences

Ci-dessous, les différences entre deux révisions de la page.

Lien vers cette vue comparative

Prochaine révision
Révision précédente
wiki:divers:preparation_are_2019 [2019/01/09 16:05]
Christian Simon Essai du capteur réflectif IR Vishay V69 CNY70 sur un M5 Stack.
wiki:divers:preparation_are_2019 [2019/01/09 16:14] (Version actuelle)
Christian Simon
Ligne 11: Ligne 11:
  
 Bref. Bref.
 +
 +On utilise deux résistances : 
 +  * protection de la LED IR : 100 Ω
 +  * émetteur phototransistor : 56 kΩ
 +
 +Les mesures obtenues par AnalogRead vont de 0 (capteur pointé vers le ciel) à 4095 (capteur au contact).
 +
 +Le code :
 +<code>
 +#include <M5Stack.h>
 +
 +
 +unsigned long temps;
 +char affichage[12];
 +int sensorPin = 2;  
 +// the setup routine runs once when M5Stack starts up
 +void setup() {
 +  
 +  // initialize the M5Stack object
 +  M5.begin();
 +  pinMode(sensorPin,INPUT);
 +
 +  // Lcd display
 +
 +  M5.Lcd.fillScreen(BLACK);
 +
 +  // text print
 +  M5.Lcd.fillScreen(BLACK);
 +  M5.Lcd.setCursor(10, 10);
 +  M5.Lcd.setTextColor(WHITE);
 +  M5.Lcd.setTextSize(1);
 +  M5.Lcd.printf("Started!");
 +
 + 
 +}
 +
 +// the loop routine runs over and over again forever
 +void loop(){
 +  int level;
 +  
 +  temps = millis();
 +  ltoa(temps,affichage,12);
 +  level = analogRead(sensorPin);
 +  M5.Lcd.setCursor(10, 10);
 +  M5.Lcd.printf(affichage);
 +  M5.Lcd.setCursor(10, 30);
 +  M5.Lcd.printf("%d",level);
 +  delay(1000);
 +  M5.Lcd.fillScreen(BLACK);
 +  M5.update();
 +}</code>
  
wiki/divers/preparation_are_2019.1547049945.txt.gz · Dernière modification: 2019/01/09 16:05 de Christian Simon