depot git
This commit is contained in:
@@ -0,0 +1,69 @@
|
||||
#include <Arduino_HS300x.h>
|
||||
#include <Arduino_APDS9960.h>
|
||||
#include <HCSR04.h>
|
||||
#include <PDM.h>
|
||||
|
||||
// #define SAMPLE_BUFFER_SIZE 512
|
||||
// short sampleBuffer[SAMPLE_BUFFER_SIZE];
|
||||
// volatile int samplesRead = 0;
|
||||
// static const char channels = 1;
|
||||
// static const int frequency = 16000;
|
||||
|
||||
// Ultrasonic instructions
|
||||
byte triggerPin = 11;
|
||||
byte echoPin = 12;
|
||||
|
||||
void setup() {
|
||||
Serial.begin(9600);
|
||||
while (!Serial);
|
||||
|
||||
if (!HS300x.begin()) {
|
||||
Serial.println("Failed to initialize humidity temperature sensor!");
|
||||
while (1);
|
||||
}
|
||||
// if (!PDM.begin(channels, frequency)) {
|
||||
// Serial.println("Failed to start PDM!");
|
||||
// while (1);
|
||||
// }
|
||||
// PDM.onReceive(onPDMdata);
|
||||
HCSR04.begin(triggerPin, echoPin);
|
||||
}
|
||||
|
||||
void loop()
|
||||
{
|
||||
// int volume = getVolume();
|
||||
float temperature = HS300x.readTemperature();
|
||||
Serial.print("Heat: ");
|
||||
Serial.println(temperature);
|
||||
|
||||
double* distances = HCSR04.measureDistanceCm();
|
||||
Serial.print("Distance: ");
|
||||
Serial.println(distances[0]);
|
||||
// Serial.print(volume);
|
||||
delay(2500);
|
||||
}
|
||||
|
||||
// int getVolume()
|
||||
// {
|
||||
// int volume = 0;
|
||||
// int sum = 0;
|
||||
|
||||
// Serial.print("non");
|
||||
// if (samplesRead) {
|
||||
// Serial.print("yes");
|
||||
// for (int i = 0; i < samplesRead; i++) {
|
||||
// sum += abs(sampleBuffer[i]);
|
||||
// }
|
||||
// volume = sum / samplesRead;
|
||||
// samplesRead = 0;
|
||||
// }
|
||||
|
||||
// return (volume);
|
||||
// }
|
||||
|
||||
// void onPDMdata()
|
||||
// {
|
||||
// int bytesAvailable = PDM.available();
|
||||
// PDM.read(sampleBuffer, bytesAvailable);
|
||||
// samplesRead = bytesAvailable / 2;
|
||||
// }
|
||||
Reference in New Issue
Block a user