Show Posts
Pages: [1]
1  Using Arduino / Programming Questions / Complex number printing on: October 05, 2013, 09:42:21 am
How can I do a Serial.println() for an array variable which has been delared as a complex number?

the code below provides me with the following errors

sketch_oct05a.ino: In function 'void loop()':
sketch_oct05a:22: error: no matching function for call to 'UARTClass::println(complex&)'
C:\arduino-1.5.2\arduino-1.5.2\hardware\arduino\sam\cores\arduino/Print.h:67: note: candidates are: size_t Print::println(const __FlashStringHelper*)
C:\arduino-1.5.2\arduino-1.5.2\hardware\arduino\sam\cores\arduino/Print.h:68: note:                 size_t Print::println(const String&)
C:\arduino-1.5.2\arduino-1.5.2\hardware\arduino\sam\cores\arduino/Print.h:69: note:                 size_t Print::println(const char*)
C:\arduino-1.5.2\arduino-1.5.2\hardware\arduino\sam\cores\arduino/Print.h:70: note:                 size_t Print::println(char)
C:\arduino-1.5.2\arduino-1.5.2\hardware\arduino\sam\cores\arduino/Print.h:71: note:                 size_t Print::println(unsigned char, int)
C:\arduino-1.5.2\arduino-1.5.2\hardware\arduino\sam\cores\arduino/Print.h:72: note:                 size_t Print::println(int, int)
C:\arduino-1.5.2\arduino-1.5.2\hardware\arduino\sam\cores\arduino/Print.h:73: note:                 size_t Print::println(unsigned int, int)
C:\arduino-1.5.2\arduino-1.5.2\hardware\arduino\sam\cores\arduino/Print.h:74: note:                 size_t Print::println(long int, int)
C:\arduino-1.5.2\arduino-1.5.2\hardware\arduino\sam\cores\arduino/Print.h:75: note:                 size_t Print::println(long unsigned int, int)
C:\arduino-1.5.2\arduino-1.5.2\hardware\arduino\sam\cores\arduino/Print.h:76: note:                 size_t Print::println(double, int)
C:\arduino-1.5.2\arduino-1.5.2\hardware\arduino\sam\cores\arduino/Print.h:77: note:                 size_t Print::println(const Printable&)
C:\arduino-1.5.2\arduino-1.5.2\hardware\arduino\sam\cores\arduino/Print.h:78: note:                 size_t Print::println()

Code:
//   Include FFT header
#include "librowfft.h"
#include <stdio.h>
#include <complex.h>


complex *pSignal = new complex[1024];
int Mysignal;

void setup() {
  Serial.begin(57600);
}

void loop() {
  for (int i=0;i<1024;i++){
  pSignal[i]=analogRead(0);
  }
  CFFT::Forward(pSignal, 1024);
 
 for (int p=0;p<1024;p++){
    Serial.println(pSignal[p]);
 }

  Serial.println("fftdone");
  //}
  delay(10000);
}
2  Products / Arduino Due / Re: DUE's more advanced FFT capabilities on: September 16, 2013, 04:35:02 pm
How can I implement this code to do an FFT from an AnalogRead

I attempted to ad the following code in place of the specified test signal "float32_t testInput_f32_10khz[2048]"
Code:

for (int x=0;x<2048;x++){
   float32_t voltage = analogRead(A0) * (5 / 1023.0);
   testInput_f32_10khz[x]=voltage;
   x++;
   testInput_f32_10khz[x]=0.000000000000000;
  }
But it always replies with a 0 value for the testIndex
3  Products / Arduino Due / Re: Porting the ffft.h library to Arduino Due on: September 12, 2013, 09:52:44 am
Thank you Adam,

I will have a look at the code and let you know how it goes

Petrus
4  Products / Arduino Due / Re: linking with libarm_cortexM3l_math.a ? on: August 15, 2013, 09:08:59 am
When attempting to compile I receive the following error:

arm-none-eabi-g++: C:\arduino-1.5.2\hardware\arduino\sam\variants\arduino_due_x/libsam_sam3x8e_gcc_rel.aC:\arduino-1.5.2\hardware\arduino\sam\variants\arduino_due_x/libarm_cortexM3l_math.aC:\Users\PETRUS~1\AppData\Local\Temp\build6749693034922762752.tmp/core.a: Invalid argument

Did everything as explained but cant find the problem, please help
5  Products / Arduino Due / Porting the ffft.h library to Arduino Due on: August 13, 2013, 02:15:41 pm
Can anyone please help in porting the ffft.h library to the Arduino Due. Compiling problems start with the avr\pgmspace.h include but seems to persist even when correctly linked.

Code:
#ifndef FFT_N
#define FFT_N 128/* Number of samples (64,128,256,512). Don't forget to clean! */
//#define INPUT_NOUSE
//#define INPUT_IQ

#ifndef FFFT_ASM /* for c modules */

typedef struct _tag_complex_t {
int16_t r;
int16_t i;
} complex_t;


#ifndef INPUT_NOUSE
#ifdef INPUT_IQ
void fft_input (const complex_t *, complex_t *);
#else
extern "C" { void fft_input (const int16_t *, complex_t *); }
#endif
#endif
extern "C" {
void fft_execute (complex_t *);
void fft_output (complex_t *, uint16_t *);
int16_t fmuls_f (int16_t, int16_t);
}
//<C:\arduino-1.5.2\hardware\tools\avr\avr\include\avr\pgmspace.h>
#include <avr/pgmspace.h>
extern const prog_int16_t tbl_window[];



#else /* for asm module */

#define T0L r0
#define T0H r1
#define T2L r2
#define T2H r3
#define T4L r4
#define T4H r5
#define T6L r6
#define T6H r7
#define T8L r8
#define T8H r9
#define T10L r10
#define T10H r11
#define T12L r12
#define T12H r13
#define T14L r14
#define T14H r15
#define AL r16
#define AH r17
#define BL r18
#define BH r19
#define CL r20
#define CH r21
#define DL r22
#define DH r23
#define EL r24
#define EH r25
#define XL r26
#define XH r27
#define YL r28
#define YH r29
#define ZL r30
#define ZH r31

.macro ldiw dh,dl, abs
ldi \dl, lo8(\abs)
ldi \dh, hi8(\abs)
.endm

.macro subiw dh,dl, abs
subi \dl, lo8(\abs)
sbci \dh, hi8(\abs)
.endm

.macro addw dh,dl, sh,sl
add \dl, \sl
adc \dh, \sh
.endm

.macro addd d3,d2,d1,d0, s3,s2,s1,s0
add \d0, \s0
adc \d1, \s1
adc \d2, \s2
adc \d3, \s3
.endm

.macro subw dh,dl, sh,sl
sub \dl, \sl
sbc \dh, \sh
.endm

.macro subd d3,d2,d1,d0, s3,s2,s1,s0
sub \d0, \s0
sbc \d1, \s1
sbc \d2, \s2
sbc \d3, \s3
.endm

.macro lddw dh,dl, src
ldd \dl, \src
ldd \dh, \src+1
.endm

.macro ldw dh,dl, src
ld \dl, \src
ld \dh, \src
.endm

.macro stw dst, sh,sl
st \dst, \sl
st \dst, \sh
.endm

.macro clrw dh, dl
clr \dh
clr \dl
.endm

.macro lsrw dh, dl
lsr \dh
ror \dl
.endm

.macro asrw dh, dl
asr \dh
ror \dl
.endm

.macro lslw dh, dl
lsl \dl
rol \dh
.endm

.macro pushw dh, dl
push \dh
push \dl
.endm

.macro popw dh, dl
pop \dl
pop \dh
.endm

.macro lpmw dh,dl, src
lpm \dl, \src
lpm \dh, \src
.endm

.macro rjne lbl
breq 99f
rjmp \lbl
99:
.endm


.macro FMULS16 d3,d2,d1,d0 ,s1h,s1l, s2h,s2l ;Fractional Multiply (19clk)
fmuls \s1h, \s2h
movw \d2, T0L
fmul \s1l, \s2l
movw \d0, T0L
adc \d2, EH ;EH: zero reg.
fmulsu \s1h, \s2l
sbc \d3, EH
add \d1, T0L
adc \d2, T0H
adc \d3, EH
fmulsu \s2h, \s1l
sbc \d3, EH
add \d1, T0L
adc \d2, T0H
adc \d3, EH
.endm


.macro SQRT32 ; 32bit square root (526..542clk)
clr T6L
clr T6H
clr T8L
clr T8H
ldi BL, 1
ldi BH, 0
clr CL
clr CH
ldi DH, 16
90: lsl T2L
rol T2H
rol T4L
rol T4H
rol T6L
rol T6H
rol T8L
rol T8H
lsl T2L
rol T2H
rol T4L
rol T4H
rol T6L
rol T6H
rol T8L
rol T8H
brpl 91f
add T6L, BL
adc T6H, BH
adc T8L, CL
adc T8H, CH
rjmp 92f
91: sub T6L, BL
sbc T6H, BH
sbc T8L, CL
sbc T8H, CH
92: lsl BL
rol BH
rol CL
andi BL, 0b11111000
ori BL, 0b00000101
sbrc T8H, 7
subi BL, 2
dec DH
brne 90b
lsr CL
ror BH
ror BL
lsr CL
ror BH
ror BL
.endm

#endif /* FFFT_ASM */

#endif /* FFT_N */

6  Using Arduino / Audio / Re: Arduino FFFT Lib and SD Card on: August 13, 2013, 01:31:31 pm
I m also attempting to port the ffft.h library to the Arduino Due without luck, the problem seems to be in the #include <avr\pgmspace.h> file.

Does anyone know of a workaround which might help to get this library working on the Arduino Due?
7  Using Arduino / Audio / Help with FFFT of an Array on: January 30, 2013, 07:21:15 am
I am busy implemeting an FFT routine on an Audio project. I am using the FFFT.h Library and need to trigger an FFT only when a set AnalogRead threshold has been exceeded. The FFT buffer should only be filled with samples when triggered and it should only do so for a set number of itterations (not yet set in the code)

The original code does not accept analogRead() statements, i have tried it every other way. Must be the way the ADC has been set-up but it works continiously and provides the correct data per frequency bin.

Code:
/*
This Example acquire analog signal from A0 of Arduino, and Serial out to Processing application to visualize.
Tested with preamplified audio data. Take a look at http://www.youtube.com/watch?v=drYWullBWcI

Analog signal is captured at 9.6 KHz, 64 spectrum bands each 150Hz which can be change from adcInit()
Load the this file to Arduio, run Processing application.

Original Fixed point FFT library is from ELM Chan, http://elm-chan.org/works/akilcd/report_e.html
Ported to the library and demo codes are from AMurchick http://arduino.cc/forum/index.php/topic,37751.0.html
Processing code is from boolscott http://boolscott.wordpress.com/2010/02/04/arduino-processing-analogue-bar-graph-2/
*/


#include <stdint.h>
#include <ffft.h>


#define  IR_AUDIO  0 // ADC channel to capture


volatile  byte  position = 0;
volatile  long  zero = 0;

int16_t capture[FFT_N]; /* Wave captureing buffer */
complex_t bfly_buff[FFT_N]; /* FFT buffer */
uint16_t spektrum[FFT_N/2]; /* Spectrum output buffer */

void setup()
{
  Serial.begin(57600);
  adcInit();
  adcCalb();
}

void loop()
{
  if (position == FFT_N)
  {
    fft_input(capture, bfly_buff);
    fft_execute(bfly_buff);
    fft_output(bfly_buff, spektrum);

    for (byte i = 0; i < 64; i++){
      Serial.print(",");
    if (spektrum[i]>10){
      Serial.print(spektrum[i]);
      }else{
        Serial.print("_");
      }
    }
    Serial.println("");
   position = 0;
   }
}

// free running ADC fills capture buffer
ISR(ADC_vect)
{
  if (position >= FFT_N)
    return;
 
  capture[position] = ADC + zero;
  if (capture[position] == -1 || capture[position] == 1)
    capture[position] = 0;

  position++;
}
void adcInit(){
  /*  REFS0 : VCC use as a ref, IR_AUDIO : channel selection, ADEN : ADC Enable, ADSC : ADC Start, ADATE : ADC Auto Trigger Enable, ADIE : ADC Interrupt Enable,  ADPS : ADC Prescaler  */
  // free running ADC mode, f = ( 16MHz / prescaler ) / 13 cycles per conversion
  ADMUX = _BV(REFS0) | IR_AUDIO; // | _BV(ADLAR);
//  ADCSRA = _BV(ADSC) | _BV(ADEN) | _BV(ADATE) | _BV(ADIE) | _BV(ADPS2) | _BV(ADPS1) //prescaler 64 : 19231 Hz - 300Hz per 64 divisions
  ADCSRA = _BV(ADSC) | _BV(ADEN) | _BV(ADATE) | _BV(ADIE) | _BV(ADPS2) | _BV(ADPS1) | _BV(ADPS0); // prescaler 128 : 9615 Hz - 150 Hz per 64 divisions, better for most music
  sei();
}
void adcCalb(){
  Serial.println("Start to calc zero");
  long midl = 0;
  // get 2 meashurment at 2 sec
  // on ADC input must be NO SIGNAL!!!
  for (byte i = 0; i < 2; i++)
  {
    position = 0;
    delay(100);
    midl += capture[0];
    delay(900);
  }
  zero = -midl/2;
  Serial.println("Done.");
}

My code provides me with garbage numbers in the lower bins from 1 up and it does not seem to fill the data to the correct bins. I am implementing Fast ADC instead of an unterupt Timer as in the original code, could this be the problem?

Code:
#include <stdint.h>
#include <ffft.h>

// Fast ADC defined
#define FASTADC 1

// Fast ADC defines for setting and clearing register bits
#ifndef cbi
#define cbi(sfr, bit) (_SFR_BYTE(sfr) &= ~_BV(bit))
#endif
#ifndef sbi
#define sbi(sfr, bit) (_SFR_BYTE(sfr) |= _BV(bit))
#endif


int AnalogVal=0;
volatile  byte  position = 0;
volatile  long  zero = 0;

int16_t capture[FFT_N];                 /* Spectrum input Array */
complex_t bfly_buff[FFT_N]; /* FFT buffer */
uint16_t spektrum[FFT_N/2]; /* Spectrum output buffer */

 
void setup()
{
Serial.begin(57600);
calibrateADC();
}

void loop()
{
#if FASTADC
  // set prescale to 16
 sbi(ADCSRA,ADPS2) ;
 cbi(ADCSRA,ADPS1) ;
 cbi(ADCSRA,ADPS0) ;
#endif
sei();

 AnalogVal=analogRead(0);
 if (AnalogVal>=600){// trigger to start getting samples
    FillArray();
 }
}

void FillArray()
{
  position=0;
 
  for (byte i = 0; i < FFT_N; i++){
  int Val= analogRead(A0); 
  capture[i] = ADC + zero;
  position++;
  }
  DoFFT();
}


void DoFFT()
{
if (position == FFT_N)
  {
    fft_input(capture, bfly_buff);
    fft_execute(bfly_buff);
    fft_output(bfly_buff, spektrum);
  }
  DoPrint();
}

void DoPrint()
{
   for (byte p = 0; p < 64; p++){
   Serial.print(","); 
   Serial.print(spektrum[p]);// print the 64 frequency bins
   }
   
   //int samples = endtime/64;
   Serial.println("");
   //Serial.println(endtime);// Total milliseconds to get 128 samples
   //Serial.println(samples);// Sample period in milliseconds
   position = 0;
}


void calibrateADC(){
  Serial.println("Start to calc zero");
  long midl = 0;
  // get 2 meashurment at 2 sec
  // on ADC input must be NO SIGNAL!!!
  for (byte i = 0; i < 2; i++)
  {
    position = 0;
    delay(100);
    midl += capture[0];
    delay(900);
  }
  zero = -midl/2;
  Serial.println("Done.");
}

I am new to FFT etc and I will appreciate any help in this matter
8  Using Arduino / Audio / Re: Sound Triangulation with 3 Microphones on: October 05, 2012, 02:35:38 am
I am using the sparkfun electret breakout board for sound collection which has a 100x opamp,  and have not paid any attention to shielding, that might sort the issue, the xbee is a 900mhz Pro uFL. I will also power the xbee from another rail to see if it improves.
9  Using Arduino / Audio / Sound Triangulation with 3 Microphones on: October 03, 2012, 02:45:18 pm
I am currently busy with a project and urgently need help in the right direction. I am a total newbie so please bear with me. I am trying to develop a device to triangulate a sound source. The final project will have multiple sensors the same as the the one I am busy with. The final triangulation will be done by the combined data from 2 or more sensors. The current sensor will only provide a compass bearing to the detected sound.

I have three microphones in an equal triangle formation, each spaced 1 meter apart. I numbered them 1 to 3 with number 1 at the point which will point north 0/360 degrees, number 2 at 120 degrees and three at 240 degrees. they are connected to Analog input pins 1,2 and 3 on an Arduino Mega 2560. Incorporated in this design is also a DS18B20 Thermometer to calculate the correct speed of sound at any given time. Please see the attached Fritzing image for the current setup.

I have used FASTADC as to do faster analog reads (currently reading at 18 microseconds). When the threshold of a microphone is exceeded, I check the remaining mics for a 2nd detection from where the bearing can be calculated.

I will probably add sound analyzing at a later stage, maybe on another microprocessor.

As I said, I am a newbie, please have a look at the code and give me comments on how to improve on the coding and design. When connecting an Xbee I realized that the analog Read values are pushed up quite a lot, normal quiet environment reads will be in the range of 500 to 600, with the Xbee they are pushed to 900 or more. Is it an issue with power distribution or something affecting the RX/TX ports on the Arduino?

Below is my current working code version

Code:
#include <OneWire.h>
#include <DallasTemperature.h>

// Detection Order Vars
int S1; // Var to hold 1st detection Mic number
int S2; // Var to hold 2nd detection Mic number

// Analog Read Values
int sensorCheck; // Var to hold Audio Value
int sensorValue1; // Var to hold detected Audio Value of Mic 1
int sensorValue2; // Var to hold detected Audio Value of Mic 2
int sensorValue3; // Var to hold detected Audio Value of Mic 3

// Timing Vars
double detectTime; // Var for detection time out
double time1; // Var to hold 1st detection time, time when 1st mic exceeded the set threshold
double time2; // Var to hold 2nd detection time, time when 2nd mic exceeded the set threshold


// Timing Calculation Vars
double calculatedMS1; // 2nd detection time - 1st detection time micro second value
double calculatedSeconds1= 0.0000000000; // Var to convert microseconds to seconds for angle calculation of 1st detection

// Distance, angle and bearing vars
double DistA = 0; // Calculated sound wave distance between 1st mic detection and 2nd mic detection in meter
double BearingResult1 =0; // Bearing result from 1st detection
double FinalBearing1 =0; // Adjusted and final compass bearing of 1st detection


// Constant Values
double LengthOfSide = 1; // Constant for Mic Array triangle side value in meter
double RadToDegrees = (360/(2*3.1415)); // Radians to degrees function
double temp =0; // Var to hold current temeprature Deg Celsius
double SpeedOfSound = 0; // Var to hold calculated speed of sound value for angle calculation
int micThreshold = 600; // Detection Threshold

// DS18B20 Temperature Sensor defined
#define ONE_WIRE_BUS 2
OneWire oneWire(ONE_WIRE_BUS);
DallasTemperature sensors(&oneWire);

// Fast ADC defined
#define FASTADC 1

// Fast ADC defines for setting and clearing register bits
#ifndef cbi
#define cbi(sfr, bit) (_SFR_BYTE(sfr) &= ~_BV(bit))
#endif
#ifndef sbi
#define sbi(sfr, bit) (_SFR_BYTE(sfr) |= _BV(bit))
#endif

 
void setup()
{
Serial.begin(57600);
sensors.begin();
}

void loop()
{
// Zero All Variables

// Analaog read vars
sensorValue1 =0;
sensorValue2 =0;
sensorValue3 =0;
sensorCheck =0;

// Timing Vars
detectTime =0;
time1=0;
time2=0;
calculatedMS1 = 0;
calculatedSeconds1=0;


// Distance, angle and bearing vars
DistA = 0;
BearingResult1 = 0;
FinalBearing1 = 0;

sensors.requestTemperatures(); // get current Temp
Serial.print("Current Temperature: ");
Serial.println(sensors.getTempCByIndex(0)); // print current temp
Serial.println("Waiting...................."); // show we are ready for detection

// Set the ADC for fast clock speed (18 microsecond per analogRead)
#if FASTADC
  // set prescale to 16
  sbi(ADCSRA,ADPS2) ;
  cbi(ADCSRA,ADPS1) ;
  cbi(ADCSRA,ADPS0) ;
#endif
 
 // Start the detection Sequence
 
 // Check Mic 1
 //------------------------------
 while (sensorCheck<micThreshold)
 {
  sensorCheck =0;
  sensorCheck = analogRead(1);
  if (sensorCheck>=micThreshold){ // Check If Mic 1 exceeded the threshold, save S1 Var to 1, time1 to current micros()
    time1= micros();
    sensorValue1 = sensorCheck;
    sensorCheck=0; // Reset sensorCheck Var
    S1=1;
    while (sensorValue1>micThreshold && sensorCheck<micThreshold){
      detectTime = micros()-time1;
      if (detectTime >5880) // check if 1st detection is timed out 1 -
      {
          NoDetect();
      }
      sensorCheck =0;
      sensorCheck = analogRead(2);
      if (sensorCheck>=micThreshold){ // While Mic 1 exceed threshold is true Check If Mic 2 exceeded the threshold
        time2= micros();
        sensorValue2 = sensorCheck;
        sensorCheck =0;
        S2=2;
        Action();
        }
      }
      sensorCheck =0;
      sensorCheck = analogRead(3);
      if (sensorCheck>=micThreshold){ // While Mic 1 exceed threshold is true Check If Mic 3 exceeded the threshold
        time2= micros();
        sensorValue3 = sensorCheck;
        sensorCheck =0;
        S2=3;
        Action();
      } 
    }

 // Check Mic 2
 //------------------------------
  sensorCheck =0;
  sensorCheck = analogRead(2);
  if (sensorCheck>=micThreshold){ // Check If Mic 2 exceeded the threshold, save S1 Var to 2, time1 to current micros()
     time1= micros();
     sensorValue2 = sensorCheck;
     sensorCheck=0;
     S1=2;
     while (sensorValue2>micThreshold && sensorCheck<micThreshold){
     detectTime = micros()-time1;
     if (detectTime >5880)// check if 1st detection is timed out 2 -
     {
       NoDetect();
     }
      sensorCheck =0;
      sensorCheck = analogRead(1);
      if (sensorCheck>=micThreshold){ // While Mic 2 exceed threshold is true Check If Mic 1 exceeded the threshold
        time2= micros();
        sensorValue1 = sensorCheck;
        sensorCheck =0;
        S2=1;
        Action();
      }
      sensorCheck =0;
      sensorCheck = analogRead(3);
      if (sensorCheck>=micThreshold){ // While Mic 2 exceed threshold is true Check If Mic 3 exceeded the threshold
        time2= micros();
        sensorValue3 = sensorCheck;
        sensorCheck =0;
        S2=3;
        Action();
      } 
    }
  }
 
 // Check Mic 3
 //------------------------------
  sensorCheck =0;
  sensorCheck = analogRead(3);
  if (sensorCheck>=micThreshold){ // Check If Mic 3 exceeded the threshold, save S1 Var to 3, time1 to current micros()
     time1= micros();
     sensorValue3 = sensorCheck;
     sensorCheck=0;
     S1=3;
     while (sensorValue3>micThreshold && sensorCheck<micThreshold){
     detectTime = micros()-time1;
     if (detectTime >5880)// check if 1st detection is timed out 3 -
     {
         NoDetect();
     }
      sensorCheck =0;
      sensorCheck = analogRead(1);
      if (sensorCheck>=micThreshold){ // While Mic 3 exceed threshold is true Check If Mic 1 exceeded the threshold
        time2= micros();
        sensorValue1 = sensorCheck;
        sensorCheck =0;
        S2=1;
        Action();
      }
      sensorCheck =0;
      sensorCheck = analogRead(2);
      if (sensorCheck>=micThreshold){ // While Mic 3 exceed threshold is true Check If Mic 2 exceeded the threshold
        time2= micros();
        sensorValue2 = sensorCheck;
        sensorCheck =0;
        S2=2;
        Action();
      } 
    }
  }
 }
}

void Action()
{
sensors.requestTemperatures();
temp = sensors.getTempCByIndex(0);
SpeedOfSound = (331.3 + (.606*temp));
// Do 1st Triangulation between 1st and 2nd detection
calculatedMS1 = time2 - time1;
calculatedSeconds1=calculatedMS1 / 1000000;
DistA=(calculatedSeconds1 * SpeedOfSound);
BearingResult1 = (acos(DistA / LengthOfSide)*RadToDegrees)-30;
 if (S1==1 && S2==2){
 FinalBearing1 = 0 + BearingResult1;
 }
 if (S1==1 && S2==3){
 FinalBearing1 = 360 - BearingResult1;
 }
 if (S1==2 && S2==1){
 FinalBearing1 = 120 - BearingResult1;
 }
 if (S1==2 && S2==3){
 FinalBearing1 = 120 + BearingResult1;
 }
 if (S1==3 && S2==1){
 FinalBearing1 = 240 + BearingResult1;
 }
 if (S1==3 && S2==2){
 FinalBearing1 = 240 - BearingResult1;
 }
Serial.print("Mics");
Serial.print(S1);
Serial.print("-");
Serial.print(S2);
Serial.print("; Seconds between detections:");
Serial.print(calculatedSeconds1,10);
Serial.print("; Measured Distance:");
Serial.print(DistA,10);
Serial.print("; Calculated Bearing:");
Serial.print(BearingResult1,2);
Serial.print("; Compass Bearing:");
Serial.println(FinalBearing1,2);
sensorCheck=0;
delay(1000);
loop();
}

void NoDetect()
{
Serial.println("Not enough detection data, detection timed-out. At least 2 of the 3 microphones must detect the event");
loop();
}

Pages: [1]