Amonbofils / Stage_Manu

0 stars 0 forks source link

Coder le capteur de détection de présence #3

Open Amonbofils opened 2 years ago

Amonbofils commented 2 years ago

But : Réussir a coder les détecteur de présence, et trouver lequel est le mieux dans le cadre du projet

Specs : Le détecteur doit pouvoir fonctionner sur des bouteilles en verre pleines et vides. La détection sera positionnée sur un socle mobile pour pouvoir ajuster la distance de détection en fonction du format de bouteille.

emmameunier commented 2 years ago

1) Essai touch v1.1 ;

pas de sensibilité avec une bouteille

``const int SENSOR_PIN = A0; // the Arduino's input pin that connects to the sensor's SIGNAL pin

// Variables will change: int lastState = LOW; // the previous state from the input pin int currentState; // the current reading from the input pin

void setup() { // initialize serial communication at 9600 bits per second: Serial.begin(9600); // initialize the Arduino's pin as aninput pinMode(SENSOR_PIN, INPUT); }

void loop() { // read the state of the the input pin: currentState = digitalRead(SENSOR_PIN);

if(lastState == LOW && currentState == HIGH) Serial.println("1");

// save the the last state lastState = currentState; }

emmameunier commented 2 years ago

2) essai MH-sensor-séries

Aprés le réglage de la sensibilité la détection de la bouteille pleine non étiquetée est correcte, test effectué à 5 cm Après le réglage de la sensibilité la détection de la bouteille vide non étiquetée est correcte , test effectué à 5 cm Détection correcte sur une bouteille étiquetée, test à 5 cm

`int led = 8; int capteur = 3; int detection;

void setup() { pinMode(led, OUTPUT); pinMode(capteur, INPUT); }

void loop() {

// Lecture de la valeur de l'interface OUT du capteur detection = digitalRead(capteur);

// Si on détecte une personne, on allume la LED if (detection == 0) { digitalWrite(led, HIGH); }

// Si on ne détecte personne, on éteint la LED if (detection == 1) { digitalWrite(led, LOW); }`

emmameunier commented 2 years ago

3) Essai du JSN_SR04T

Détection des bouteilles aussi bien vides que pleines, cependant distances transmises très approximatives et surtout très souvent erronées , peut peut-être fonctionner plus efficacement avec l'ajout d'un ou deux JSN_SR04T qui pourraient communiquer entre eux ?

'

include

// Define Trig and Echo pin:

define trigPin 2

define echoPin 3

// Define variables: long duration; int distance;

void setup() { // Define inputs and outputs pinMode(trigPin, OUTPUT); pinMode(echoPin, INPUT);

// Begin Serial communication at a baudrate of 9600: Serial.begin(9600); }

void loop() { // Clear the trigPin by setting it LOW: digitalWrite(trigPin, LOW);

delay(500);

// Trigger the sensor by setting the trigPin high for 10 microseconds: digitalWrite(trigPin, HIGH); delay(100); digitalWrite(trigPin, LOW);

// Read the echoPin. pulseIn() returns the duration (length of the pulse) in microseconds: duration = pulseIn(echoPin, HIGH);

// Calculate the distance: distance = duration*0.034/2;

// Print the distance on the Serial Monitor (Ctrl+Shift+M): Serial.print("Distance = "); Serial.print(distance); Serial.println(" cm");

delay(100); }`

emmameunier commented 2 years ago

4) Essai HC-SR04

Détection de toutes les bouteilles, avec le renseignement d'une distance correcte. Nombre d'erreurs des mesures très faible.

` //Begin Serial communication at a baudrate of 9600: Serial.begin(9600); }

void loop() { // Clear the trigPin by setting it LOW: digitalWrite(trigPin, LOW); delayMicroseconds(5);

// Trigger the sensor by setting the trigPin high for 10 microseconds: digitalWrite(trigPin, HIGH); delayMicroseconds(10); digitalWrite(trigPin, LOW);

// Read the echoPin, pulseIn() returns the duration (length of the pulse) in microseconds: duration = pulseIn(echoPin, HIGH); // Calculate the distance: distance = duration * 0.034 / 2;

// Print the distance on the Serial Monitor (Ctrl+Shift+M): Serial.print("Distance = "); Serial.print(distance); Serial.println(" cm");

delay(50); `}``