feat: add ultrasonic sensor and exemple

This commit is contained in:
Clement 2023-04-04 15:37:55 +02:00
parent 2e4b24df10
commit 7b5d4a071b
2 changed files with 19 additions and 2 deletions

View File

@ -1,6 +1,9 @@
#ifndef PROGRAM_H #ifndef PROGRAM_H
#define PROGRAM_H #define PROGRAM_H
#include <Arduino.h>
#include <Ultrasonic.h>
class Program{ class Program{
public: public:
/** /**
@ -17,5 +20,11 @@ public:
private: private:
/* data */ /* data */
/**
* @brief capteur ultra son pour le niveau de remplissage de la poubelle
*
*/
Ultrasonic *ultrasonic;
}; };
#endif #endif

View File

@ -1,10 +1,18 @@
#include "Program.h" #include "Program.h"
Program::Program(){ int distance;
Program::Program(){
Serial.begin(MONITOR_SPEED);
this->ultrasonic = new Ultrasonic(ULTRA_SOUND_TRIGD, ULTRA_SOUND_ECHO);
} }
void Program::loop(){ void Program::loop(){
distance = this->ultrasonic->read();
Serial.print("Distance in CM: ");
Serial.println(distance);
delay(1000);
} }