From 6da8f34ee5a11043e0afb78b4a2e9cf918d9b0de Mon Sep 17 00:00:00 2001 From: Amaury Date: Sun, 7 May 2017 13:36:47 +0200 Subject: [PATCH] dézippage de Test IMA3 P2 --- code arduino/Test IMA3 P2/test/test.ino | 36 ++++++++++++++++++++++++++++++++++++ code arduino/Test IMA3 P2/testCapteur/testCapteur.ino | 42 ++++++++++++++++++++++++++++++++++++++++++ code arduino/test_arduino.zip | Bin 1724 -> 0 bytes 3 files changed, 78 insertions(+), 0 deletions(-) create mode 100644 code arduino/Test IMA3 P2/test/test.ino create mode 100644 code arduino/Test IMA3 P2/testCapteur/testCapteur.ino delete mode 100644 code arduino/test_arduino.zip diff --git a/code arduino/Test IMA3 P2/test/test.ino b/code arduino/Test IMA3 P2/test/test.ino new file mode 100644 index 0000000..90f3907 --- /dev/null +++ b/code arduino/Test IMA3 P2/test/test.ino @@ -0,0 +1,36 @@ +/* Utilisation du capteur Ultrason HC-SR04 */ + +// définition des broches utilisées +int trig1 = 7; +int echo1 = 6; + +int trig2 = 8; +int echo2 = 5; +long lecture_echo; +long cm; + +void setup() +{ + pinMode(trig1, OUTPUT); + digitalWrite(trig1, LOW); + pinMode(echo1, INPUT); + + pinMode(trig2, OUTPUT); + digitalWrite(trig2, LOW); + pinMode(echo2, INPUT); + Serial.begin(9600); +} + +void loop() +{ + digitalWrite(trig1, HIGH); + digitalWrite(trig2, HIGH); + delayMicroseconds(10); + digitalWrite(trig1, LOW); + digitalWrite(trig2, LOW); + lecture_echo = pulseIn(echo2, HIGH); + cm = lecture_echo / 58; + Serial.print("Distancem : "); + Serial.println(cm); + delay(500); +} diff --git a/code arduino/Test IMA3 P2/testCapteur/testCapteur.ino b/code arduino/Test IMA3 P2/testCapteur/testCapteur.ino new file mode 100644 index 0000000..44bbf1e --- /dev/null +++ b/code arduino/Test IMA3 P2/testCapteur/testCapteur.ino @@ -0,0 +1,42 @@ + #include "Adafruit_BME280.h" + #include "Adafruit_Sensor.h" + //Library allows either I2C or SPI, so include both. + #include "Wire.h" + #include "SPI.h" + + BME280 capteur; + + void setup() { + + Serial.begin(9600); + while (!Serial) { + // Attente de l'ouverture du port série pour Arduino LEONARDO + } + //configuration du capteur + capteur.settings.commInterface = I2C_MODE; + capteur.settings.I2CAddress = 0x76; + capteur.settings.runMode = 3; + capteur.settings.tStandby = 0; + capteur.settings.filter = 0; + capteur.settings.tempOverSample = 1 ; + capteur.settings.pressOverSample = 1; + capteur.settings.humidOverSample = 1; + + Serial.println("Starting BME280... "); + delay(10); // attente de la mise en route du capteur. 2 ms minimum + // chargement de la configuration du capteur + capteur.begin(); + } + + void loop() { + Serial.print("Température: "); + Serial.print(capteur.readTempC(), 2); + Serial.print(" °C"); + Serial.print("\t Pression: "); + Serial.print(capteur.readFloatPressure(), 2); + Serial.print(" Pa"); + Serial.print("\t humidité relative : "); + Serial.print(capteur.readFloatHumidity(), 2); + Serial.println(" %"); + delay(1000); + } diff --git a/code arduino/test_arduino.zip b/code arduino/test_arduino.zip deleted file mode 100644 index fa65957..0000000 Binary files a/code arduino/test_arduino.zip and /dev/null differ -- libgit2 0.21.2