Commit 6da8f34ee5a11043e0afb78b4a2e9cf918d9b0de
1 parent
7078d80c
dézippage de Test IMA3 P2
Showing
3 changed files
with
78 additions
and
0 deletions
Show diff stats
... | ... | @@ -0,0 +1,36 @@ |
1 | +/* Utilisation du capteur Ultrason HC-SR04 */ | |
2 | + | |
3 | +// définition des broches utilisées | |
4 | +int trig1 = 7; | |
5 | +int echo1 = 6; | |
6 | + | |
7 | +int trig2 = 8; | |
8 | +int echo2 = 5; | |
9 | +long lecture_echo; | |
10 | +long cm; | |
11 | + | |
12 | +void setup() | |
13 | +{ | |
14 | + pinMode(trig1, OUTPUT); | |
15 | + digitalWrite(trig1, LOW); | |
16 | + pinMode(echo1, INPUT); | |
17 | + | |
18 | + pinMode(trig2, OUTPUT); | |
19 | + digitalWrite(trig2, LOW); | |
20 | + pinMode(echo2, INPUT); | |
21 | + Serial.begin(9600); | |
22 | +} | |
23 | + | |
24 | +void loop() | |
25 | +{ | |
26 | + digitalWrite(trig1, HIGH); | |
27 | + digitalWrite(trig2, HIGH); | |
28 | + delayMicroseconds(10); | |
29 | + digitalWrite(trig1, LOW); | |
30 | + digitalWrite(trig2, LOW); | |
31 | + lecture_echo = pulseIn(echo2, HIGH); | |
32 | + cm = lecture_echo / 58; | |
33 | + Serial.print("Distancem : "); | |
34 | + Serial.println(cm); | |
35 | + delay(500); | |
36 | +} | ... | ... |
code arduino/Test IMA3 P2/testCapteur/testCapteur.ino
0 → 100644
... | ... | @@ -0,0 +1,42 @@ |
1 | + #include "Adafruit_BME280.h" | |
2 | + #include "Adafruit_Sensor.h" | |
3 | + //Library allows either I2C or SPI, so include both. | |
4 | + #include "Wire.h" | |
5 | + #include "SPI.h" | |
6 | + | |
7 | + BME280 capteur; | |
8 | + | |
9 | + void setup() { | |
10 | + | |
11 | + Serial.begin(9600); | |
12 | + while (!Serial) { | |
13 | + // Attente de l'ouverture du port série pour Arduino LEONARDO | |
14 | + } | |
15 | + //configuration du capteur | |
16 | + capteur.settings.commInterface = I2C_MODE; | |
17 | + capteur.settings.I2CAddress = 0x76; | |
18 | + capteur.settings.runMode = 3; | |
19 | + capteur.settings.tStandby = 0; | |
20 | + capteur.settings.filter = 0; | |
21 | + capteur.settings.tempOverSample = 1 ; | |
22 | + capteur.settings.pressOverSample = 1; | |
23 | + capteur.settings.humidOverSample = 1; | |
24 | + | |
25 | + Serial.println("Starting BME280... "); | |
26 | + delay(10); // attente de la mise en route du capteur. 2 ms minimum | |
27 | + // chargement de la configuration du capteur | |
28 | + capteur.begin(); | |
29 | + } | |
30 | + | |
31 | + void loop() { | |
32 | + Serial.print("Température: "); | |
33 | + Serial.print(capteur.readTempC(), 2); | |
34 | + Serial.print(" °C"); | |
35 | + Serial.print("\t Pression: "); | |
36 | + Serial.print(capteur.readFloatPressure(), 2); | |
37 | + Serial.print(" Pa"); | |
38 | + Serial.print("\t humidité relative : "); | |
39 | + Serial.print(capteur.readFloatHumidity(), 2); | |
40 | + Serial.println(" %"); | |
41 | + delay(1000); | |
42 | + } | ... | ... |
code arduino/test_arduino.zip deleted
No preview for this file type