feat: capteur-ultrason #27

Merged
Clement merged 2 commits from feat--capteur-ultrason into master 2023-04-24 08:47:14 +00:00
4 changed files with 23 additions and 2 deletions
Showing only changes of commit 7b5d4a071b - Show all commits

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);
} }