feat: add ultrasonic sensor and exemple
This commit is contained in:
parent
2e4b24df10
commit
7b5d4a071b
@ -1,6 +1,9 @@
|
||||
#ifndef PROGRAM_H
|
||||
#define PROGRAM_H
|
||||
|
||||
#include <Arduino.h>
|
||||
#include <Ultrasonic.h>
|
||||
|
||||
class Program{
|
||||
public:
|
||||
/**
|
||||
@ -17,5 +20,11 @@ public:
|
||||
|
||||
private:
|
||||
/* data */
|
||||
|
||||
/**
|
||||
* @brief capteur ultra son pour le niveau de remplissage de la poubelle
|
||||
*
|
||||
*/
|
||||
Ultrasonic *ultrasonic;
|
||||
};
|
||||
#endif
|
@ -1,10 +1,18 @@
|
||||
#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(){
|
||||
distance = this->ultrasonic->read();
|
||||
|
||||
Serial.print("Distance in CM: ");
|
||||
Serial.println(distance);
|
||||
delay(1000);
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user