feat: add ultrasonic sensor and exemple
This commit is contained in:
parent
2e4b24df10
commit
7b5d4a071b
@ -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
|
@ -1,10 +1,18 @@
|
|||||||
#include "Program.h"
|
#include "Program.h"
|
||||||
|
|
||||||
|
|
||||||
|
int distance;
|
||||||
|
|
||||||
|
|
||||||
Program::Program(){
|
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);
|
||||||
}
|
}
|
Loading…
x
Reference in New Issue
Block a user