#include <Wire.h>
#include <SoftwareSerial.h>
SoftwareSerial BTserial(2,3);
int analogInput = A0;
const int sampleWindow = 50;
unsigned int sample;
void setup(){
BTserial.begin(9600);
Serial.begin(9600);
pinMode(analogInput, INPUT);
}
void loop(){
unsigned long startMillis = millis();
unsigned int PeaktoPeak = 0;
unsigned int SignalMax = 0;
unsigned int SignalMin = 675;
while ( millis() - startMillis < sampleWindow ){
sample = analogRead(analogInput);
if (sample < 675) {
if (sample > SignalMax){
SignalMax = sample;
}
else if (sample < SignalMin){
SignalMin = sample;
}
}
}
PeaktoPeak = SignalMax - SignalMin;
float MeterValue = ( PeaktoPeak * 3.3 /675) * 10;
BTserial.println(MeterValue*10);
delay(100);
}
Immediate guidance needed
Hi ,
i'm working dB meter project. I'm new to arduino programming , i like to know in which bit i'm getting sensor data from pin A0. and sending the sensor to bluetooth. I need to mention in which byte my sensor data available.
Kindly help me
Sorry, i just noted for example but actually i didnt know
in which byte i'm getting my sensor data. i need to find in which byte i'm getting my sensor value.
The code doesn't send the raw sensor data from A0 over bluetooth. I'm no audio expert but it looks like the code is performing some calculation on the peak to peak reading as sampled on A0 and sending the result over bluetooth.
Yes exactly, but my android developer asking me, in which byte you sending sound sensor output value over bluetooth, but i dont how to assign specific byte for sound value. i'm simply use this line BTserial.println(MeterValue);
to send data to apk.