Hexi_Acceleromagnetic_Synth: Michael Yarnell, Alec Pierce, 2017 The program turns an NXP Hexiwear, its development board, and a Click buzzer collectively into an 'acceleromagnetic' synthesizer. That is to say that the synthesizer is controlled primarily via the on-board accelerometer and magnetometer units.

Dependencies:   FXOS8700 Hexi_KW40Z NeatGUI PWM_6_Tone_Library

Committer:
MTYarnell
Date:
Tue Apr 18 16:06:38 2017 +0000
Revision:
0:bec3a12e79e7
Final build without hardware changes.

Who changed what in which revision?

UserRevisionLine numberNew contents of line
MTYarnell 0:bec3a12e79e7 1 /* Hexi_Acceleromagnetic_Synth
MTYarnell 0:bec3a12e79e7 2 2017 Michael Yarnell, Alec Pierce
MTYarnell 0:bec3a12e79e7 3 Class Project: ECE49500 SP17 (MEMS/NEMS/IoT/Wearables)
MTYarnell 0:bec3a12e79e7 4 IUPUI - Purdue School of Engineering and Technology
MTYarnell 0:bec3a12e79e7 5
MTYarnell 0:bec3a12e79e7 6 The following program turns an NXP Hexiwear, its development board, and a Click
MTYarnell 0:bec3a12e79e7 7 buzzer collectively into an 'acceleromagnetic' synthesizer. That is to say
MTYarnell 0:bec3a12e79e7 8 that the synthsizer is controlled primarily via the onboard accelerometer and
MTYarnell 0:bec3a12e79e7 9 magnetometer units.
MTYarnell 0:bec3a12e79e7 10 Once the appropriate initializations have been made, the program plays a short,
MTYarnell 0:bec3a12e79e7 11 preprogrammed tune. If, at any time, the left or right screen buttons are
MTYarnell 0:bec3a12e79e7 12 pressed, they each emit unique "drumbeat" note sequences. The accelerometer
MTYarnell 0:bec3a12e79e7 13 and magnetometer are read. The accelerometer x and y (pitch and roll,
MTYarnell 0:bec3a12e79e7 14 respectively) control note selection. The magnetometer value RMS is
MTYarnell 0:bec3a12e79e7 15 calculated, and if the magnetic field RMS is greater than 250uT, the
MTYarnell 0:bec3a12e79e7 16 instrument will emit corresponding notes.
MTYarnell 0:bec3a12e79e7 17
MTYarnell 0:bec3a12e79e7 18 Adapted from examples:
MTYarnell 0:bec3a12e79e7 19 "Hexi_Magneto-v2_Example"
MTYarnell 0:bec3a12e79e7 20 https://developer.mbed.org/teams/Hexiwear/code/Hexi_Magneto-v2_Example/
MTYarnell 0:bec3a12e79e7 21 "Hexi_Accelero-v2_Example"
MTYarnell 0:bec3a12e79e7 22 https://developer.mbed.org/teams/Hexiwear/code/Hexi_Accelero-v2_Example/
MTYarnell 0:bec3a12e79e7 23 "Hexi_Click_Buzzer-v2_Example"
MTYarnell 0:bec3a12e79e7 24 https://developer.mbed.org/teams/Hexiwear/code/Hexi_Click_Buzzer-v2_Example/
MTYarnell 0:bec3a12e79e7 25 "Hexi_Bubble_Game"
MTYarnell 0:bec3a12e79e7 26 https://developer.mbed.org/teams/Hexiwear/code/Hexi_Bubble_Game/
MTYarnell 0:bec3a12e79e7 27 */
MTYarnell 0:bec3a12e79e7 28
MTYarnell 0:bec3a12e79e7 29 // TYPEDEFS
MTYarnell 0:bec3a12e79e7 30 typedef signed char int8_t;
MTYarnell 0:bec3a12e79e7 31 typedef unsigned char uint8_t;
MTYarnell 0:bec3a12e79e7 32 typedef signed long long int int64_t;
MTYarnell 0:bec3a12e79e7 33 typedef unsigned long long int uint64_t;
MTYarnell 0:bec3a12e79e7 34
MTYarnell 0:bec3a12e79e7 35 // LIBRARIES
MTYarnell 0:bec3a12e79e7 36 // Note that pwm_6_tone.h has been modified from the default library header.
MTYarnell 0:bec3a12e79e7 37 #include "mbed.h"
MTYarnell 0:bec3a12e79e7 38 #include <pwm_6_tone.h>
MTYarnell 0:bec3a12e79e7 39 #include "Hexi_KW40Z.h"
MTYarnell 0:bec3a12e79e7 40 #include "FXOS8700.h"
MTYarnell 0:bec3a12e79e7 41 #include "string.h"
MTYarnell 0:bec3a12e79e7 42
MTYarnell 0:bec3a12e79e7 43 // PIN CONNECTIONS
MTYarnell 0:bec3a12e79e7 44 // Define the Buzzer Pinout (PWM Out)
MTYarnell 0:bec3a12e79e7 45 PwmOut Buzzer(PTA10);
MTYarnell 0:bec3a12e79e7 46 // Instantiate the Hexi KW40Z Driver (UART TX, UART RX)
MTYarnell 0:bec3a12e79e7 47 KW40Z kw40z_device(PTE24, PTE25);
MTYarnell 0:bec3a12e79e7 48 // Accelerometer and Magnetometer instantiation
MTYarnell 0:bec3a12e79e7 49 FXOS8700 mag(PTC11, PTC10);
MTYarnell 0:bec3a12e79e7 50 FXOS8700 accel(PTC11, PTC10);
MTYarnell 0:bec3a12e79e7 51 // Initialize Face LED
MTYarnell 0:bec3a12e79e7 52 DigitalOut led1(LED_GREEN);
MTYarnell 0:bec3a12e79e7 53 // Initialize Serial port
MTYarnell 0:bec3a12e79e7 54 //Serial pc(USBTX, USBRX); // Include to debug modified sensor values
MTYarnell 0:bec3a12e79e7 55 // or enter a practice mode.
MTYarnell 0:bec3a12e79e7 56
MTYarnell 0:bec3a12e79e7 57 // VARIABLES
MTYarnell 0:bec3a12e79e7 58 float accel_data[3]; // Storage for the data from the sensor
MTYarnell 0:bec3a12e79e7 59 float mag_data[3]; // Storage for the data from the sensor
MTYarnell 0:bec3a12e79e7 60 float mag_rms=0.0; // RMS value to be computed from sensor input
MTYarnell 0:bec3a12e79e7 61
MTYarnell 0:bec3a12e79e7 62 // From Bubble
MTYarnell 0:bec3a12e79e7 63 int xposg = 0; // The roll position of the unit
MTYarnell 0:bec3a12e79e7 64 int yposg = 0; // The pitch position of the unit
MTYarnell 0:bec3a12e79e7 65
MTYarnell 0:bec3a12e79e7 66 // New Variables
MTYarnell 0:bec3a12e79e7 67 // Note is a floating-point value that bears a number to send to the
MTYarnell 0:bec3a12e79e7 68 // Tune function.
MTYarnell 0:bec3a12e79e7 69 float Note = 0.0;
MTYarnell 0:bec3a12e79e7 70 // This table holds the values determined to play the appropriate notes
MTYarnell 0:bec3a12e79e7 71 // as reverse-engineered from the values in
MTYarnell 0:bec3a12e79e7 72 // "Hexi_Click_Buzzer-v2_Example" to widen range to nearly six octaves.
MTYarnell 0:bec3a12e79e7 73 float C_1 = 1000000/Do1, Cs_1 = 1000000/Do1s, D_1 = 1000000/Re1, Ds_1 = 1000000/Re1s,
MTYarnell 0:bec3a12e79e7 74 E_1 = 1000000/Mi1, F_1 = 1000000/Fa1, Fs_1 = 1000000/Fa1s, G_1 = 1000000/So1,
MTYarnell 0:bec3a12e79e7 75 Gs_1 = 1000000/So1s, A_1 = 1000000/La1, As_1 = 1000000/La1s, B_1 = 1000000/Ti1,
MTYarnell 0:bec3a12e79e7 76
MTYarnell 0:bec3a12e79e7 77 C_2 = 1000000/Do2, Cs_2 = 1000000/Do2s, D_2 = 1000000/Re2, Ds_2 = 1000000/Re2s,
MTYarnell 0:bec3a12e79e7 78 E_2 = 1000000/Mi2, F_2 = 1000000/Fa2, Fs_2 = 1000000/Fa2s, G_2 = 1000000/So2,
MTYarnell 0:bec3a12e79e7 79 Gs_2 = 1000000/So2s, A_2 = 1000000/La2, As_2 = 1000000/La2s, B_2 = 1000000/Ti2,
MTYarnell 0:bec3a12e79e7 80
MTYarnell 0:bec3a12e79e7 81 C_3 = 1000000/Do3, Cs_3 = 1000000/Do3s, D_3 = 1000000/Re3, Ds_3 = 1000000/Re3s,
MTYarnell 0:bec3a12e79e7 82 E_3 = 1000000/Mi3, F_3 = 1000000/Fa3, Fs_3 = 1000000/Fa3s, G_3 = 1000000/So3,
MTYarnell 0:bec3a12e79e7 83 Gs_3 = 1000000/So3s, A_3 = 1000000/La3, As_3 = 1000000/La3s, B_3 = 1000000/Ti3,
MTYarnell 0:bec3a12e79e7 84
MTYarnell 0:bec3a12e79e7 85 C_4 = 1000000/Do4, Cs_4 = 1000000/Do4s, D_4 = 1000000/Re4, Ds_4 = 1000000/Re4s,
MTYarnell 0:bec3a12e79e7 86 E_4 = 1000000/Mi4, F_4 = 1000000/Fa4, Fs_4 = 1000000/Fa4s, G_4 = 1000000/So4,
MTYarnell 0:bec3a12e79e7 87 Gs_4 = 1000000/So4s, A_4 = 1000000/La4, As_4 = 1000000/La4s, B_4 = 1000000/Ti4,
MTYarnell 0:bec3a12e79e7 88
MTYarnell 0:bec3a12e79e7 89 C_5 = 1000000/Do5, Cs_5 = 1000000/Do5s, D_5 = 1000000/Re5, Ds_5 = 1000000/Re5s,
MTYarnell 0:bec3a12e79e7 90 E_5 = 1000000/Mi5, F_5 = 1000000/Fa5, Fs_5 = 1000000/Fa5s, G_5 = 1000000/So5,
MTYarnell 0:bec3a12e79e7 91 Gs_5 = 1000000/So5s, A_5 = 1000000/La5, As_5 = 1000000/La5s, B_5 = 1000000/Ti5,
MTYarnell 0:bec3a12e79e7 92
MTYarnell 0:bec3a12e79e7 93 C_6 = 1000000/Do6, Cs_6 = 1000000/Do6s, D_6 = 1000000/Re6, Ds_6 = 1000000/Re6s,
MTYarnell 0:bec3a12e79e7 94 E_6 = 1000000/Mi6, F_6 = 1000000/Fa6, Fs_6 = 1000000/Fa6s, G_6 = 1000000/So6,
MTYarnell 0:bec3a12e79e7 95 Gs_6 = 1000000/So6s, A_6 = 1000000/La6, As_6 = 1000000/La6s, B_6 = 1000000/Ti6;
MTYarnell 0:bec3a12e79e7 96
MTYarnell 0:bec3a12e79e7 97 //FUNCTIONS
MTYarnell 0:bec3a12e79e7 98 void ButtonLeft(void)
MTYarnell 0:bec3a12e79e7 99 {
MTYarnell 0:bec3a12e79e7 100 // "Beat" 1
MTYarnell 0:bec3a12e79e7 101 Tune(Buzzer, C_5, 1); Tune(Buzzer, E_2, 1);
MTYarnell 0:bec3a12e79e7 102 Tune(Buzzer, C_5, 1); Tune(Buzzer, E_1, 1);
MTYarnell 0:bec3a12e79e7 103 }
MTYarnell 0:bec3a12e79e7 104
MTYarnell 0:bec3a12e79e7 105 void ButtonRight(void)
MTYarnell 0:bec3a12e79e7 106 {
MTYarnell 0:bec3a12e79e7 107 // "Beat" 2
MTYarnell 0:bec3a12e79e7 108 Tune(Buzzer, C_3, 1); Tune(Buzzer, E_2, 1);
MTYarnell 0:bec3a12e79e7 109 Tune(Buzzer, C_1, 1); Tune(Buzzer, E_1, 1);
MTYarnell 0:bec3a12e79e7 110 }
MTYarnell 0:bec3a12e79e7 111
MTYarnell 0:bec3a12e79e7 112 int main()
MTYarnell 0:bec3a12e79e7 113 {
MTYarnell 0:bec3a12e79e7 114 // Instantiate Buttons
MTYarnell 0:bec3a12e79e7 115 kw40z_device.attach_buttonLeft(&ButtonLeft);
MTYarnell 0:bec3a12e79e7 116 kw40z_device.attach_buttonRight(&ButtonRight);
MTYarnell 0:bec3a12e79e7 117
MTYarnell 0:bec3a12e79e7 118 // Configure Accelerometer, Magnetometer FXOS8700
MTYarnell 0:bec3a12e79e7 119 accel.accel_config();
MTYarnell 0:bec3a12e79e7 120 mag.mag_config();
MTYarnell 0:bec3a12e79e7 121
MTYarnell 0:bec3a12e79e7 122 // Startup tune tones
MTYarnell 0:bec3a12e79e7 123 Tune(Buzzer, D_6, 2); wait_ms(5); Tune(Buzzer, D_4, 2); wait_ms(5);
MTYarnell 0:bec3a12e79e7 124 Tune(Buzzer, C_5, 2); wait_ms(5); Tune(Buzzer, D_4, 4); wait_ms(5);
MTYarnell 0:bec3a12e79e7 125 Tune(Buzzer, D_2, 4); wait_ms(5); Tune(Buzzer, Cs_1, 2); wait_ms(10);
MTYarnell 0:bec3a12e79e7 126 Tune(Buzzer, C_1, 16); wait_ms(10); Tune(Buzzer, C_2, 8); wait_ms(25);
MTYarnell 0:bec3a12e79e7 127 Tune(Buzzer, C_3, 4); wait_ms(60); Tune(Buzzer, C_4, 2); wait_ms(40);
MTYarnell 0:bec3a12e79e7 128 Tune(Buzzer, C_5, 4); wait_ms(100);
MTYarnell 0:bec3a12e79e7 129
MTYarnell 0:bec3a12e79e7 130 // This loop, modified from from the Bubble game example, locates the
MTYarnell 0:bec3a12e79e7 131 // x/y accelerometer information (within boundaries) to determine
MTYarnell 0:bec3a12e79e7 132 // the position of the user and thus the note to play.
MTYarnell 0:bec3a12e79e7 133 while(1) {
MTYarnell 0:bec3a12e79e7 134
MTYarnell 0:bec3a12e79e7 135 // Get accelerometer data
MTYarnell 0:bec3a12e79e7 136 accel.acquire_accel_data_g(accel_data);
MTYarnell 0:bec3a12e79e7 137 xposg=(accel_data[1] * (-20.0));
MTYarnell 0:bec3a12e79e7 138 if (xposg > 30) xposg = 30; // Notes: 12 per octave
MTYarnell 0:bec3a12e79e7 139 if (xposg < -30) xposg = -30;
MTYarnell 0:bec3a12e79e7 140 yposg=(accel_data[0] * (40.0));
MTYarnell 0:bec3a12e79e7 141 if (yposg > 30) yposg = 30; // Octaves: 6 available
MTYarnell 0:bec3a12e79e7 142 if (yposg < -30) yposg = -30;
MTYarnell 0:bec3a12e79e7 143
MTYarnell 0:bec3a12e79e7 144 // Find Note
MTYarnell 0:bec3a12e79e7 145 // Program first attempts to find Octave from accelerometer y values.
MTYarnell 0:bec3a12e79e7 146 // Then it further determines the and assigns the value of the note
MTYarnell 0:bec3a12e79e7 147 // from the x value.
MTYarnell 0:bec3a12e79e7 148
MTYarnell 0:bec3a12e79e7 149 if (yposg > 29) { // Octave 1
MTYarnell 0:bec3a12e79e7 150 if (xposg > 20) Note = C_1; // C
MTYarnell 0:bec3a12e79e7 151 if (xposg > 16) Note = Cs_1; // Cs
MTYarnell 0:bec3a12e79e7 152 if (xposg > 12) Note = D_1; // D
MTYarnell 0:bec3a12e79e7 153 if (xposg > 8) Note = Ds_1; // Ds
MTYarnell 0:bec3a12e79e7 154 if (xposg > 4) Note = E_1; // E
MTYarnell 0:bec3a12e79e7 155 if (xposg >= 0) Note = F_1; // F
MTYarnell 0:bec3a12e79e7 156 if (xposg > -4) Note = Fs_1; // Fs
MTYarnell 0:bec3a12e79e7 157 if (xposg > -8) Note = G_1; // G
MTYarnell 0:bec3a12e79e7 158 if (xposg > -12) Note = Gs_1; // Gs
MTYarnell 0:bec3a12e79e7 159 if (xposg > -16) Note = A_1; // A
MTYarnell 0:bec3a12e79e7 160 if (xposg > -20) Note = As_1; // As
MTYarnell 0:bec3a12e79e7 161 else Note = B_1; // B
MTYarnell 0:bec3a12e79e7 162 } else if (yposg > 15) { // Octave 2
MTYarnell 0:bec3a12e79e7 163 if (xposg > 20) Note = C_2; // C
MTYarnell 0:bec3a12e79e7 164 if (xposg > 16) Note = Cs_2; // Cs
MTYarnell 0:bec3a12e79e7 165 if (xposg > 12) Note = D_2; // D
MTYarnell 0:bec3a12e79e7 166 if (xposg > 8) Note = Ds_2; // Ds
MTYarnell 0:bec3a12e79e7 167 if (xposg > 4) Note = E_2; // E
MTYarnell 0:bec3a12e79e7 168 if (xposg >= 0) Note = F_2; // F
MTYarnell 0:bec3a12e79e7 169 if (xposg > -4) Note = Fs_2; // Fs
MTYarnell 0:bec3a12e79e7 170 if (xposg > -8) Note = G_2; // G
MTYarnell 0:bec3a12e79e7 171 if (xposg > -12) Note = Gs_2; // Gs
MTYarnell 0:bec3a12e79e7 172 if (xposg > -16) Note = A_2; // A
MTYarnell 0:bec3a12e79e7 173 if (xposg > -20) Note = As_2; // As
MTYarnell 0:bec3a12e79e7 174 else Note = B_2; // B
MTYarnell 0:bec3a12e79e7 175 } else if (yposg >= 0) { // Octave 3
MTYarnell 0:bec3a12e79e7 176 if (xposg > 20) Note = C_3; // C
MTYarnell 0:bec3a12e79e7 177 if (xposg > 16) Note = Cs_3; // Cs
MTYarnell 0:bec3a12e79e7 178 if (xposg > 12) Note = D_3; // D
MTYarnell 0:bec3a12e79e7 179 if (xposg > 8) Note = Ds_3; // Ds
MTYarnell 0:bec3a12e79e7 180 if (xposg > 4) Note = E_3; // E
MTYarnell 0:bec3a12e79e7 181 if (xposg >= 0) Note = F_3; // F
MTYarnell 0:bec3a12e79e7 182 if (xposg > -4) Note = Fs_3; // Fs
MTYarnell 0:bec3a12e79e7 183 if (xposg > -8) Note = G_3; // G
MTYarnell 0:bec3a12e79e7 184 if (xposg > -12) Note = Gs_3; // Gs
MTYarnell 0:bec3a12e79e7 185 if (xposg > -16) Note = A_3; // A
MTYarnell 0:bec3a12e79e7 186 if (xposg > -20) Note = As_3; // As
MTYarnell 0:bec3a12e79e7 187 else Note = B_3; // B
MTYarnell 0:bec3a12e79e7 188 } else if (yposg > -15) { // Octave 4
MTYarnell 0:bec3a12e79e7 189 if (xposg > 20) Note = C_4; // C
MTYarnell 0:bec3a12e79e7 190 if (xposg > 16) Note = Cs_4; // Cs
MTYarnell 0:bec3a12e79e7 191 if (xposg > 12) Note = D_4; // D
MTYarnell 0:bec3a12e79e7 192 if (xposg > 8) Note = Ds_4; // Ds
MTYarnell 0:bec3a12e79e7 193 if (xposg > 4) Note = E_4; // E
MTYarnell 0:bec3a12e79e7 194 if (xposg >= 0) Note = F_4; // F
MTYarnell 0:bec3a12e79e7 195 if (xposg > -4) Note = Fs_4; // Fs
MTYarnell 0:bec3a12e79e7 196 if (xposg > -8) Note = G_4; // G
MTYarnell 0:bec3a12e79e7 197 if (xposg > -12) Note = Gs_4; // Gs
MTYarnell 0:bec3a12e79e7 198 if (xposg > -16) Note = A_4; // A
MTYarnell 0:bec3a12e79e7 199 if (xposg > -20) Note = As_4; // As
MTYarnell 0:bec3a12e79e7 200 else Note = B_4; // B
MTYarnell 0:bec3a12e79e7 201 } else if (yposg > -29) { // Octave 5
MTYarnell 0:bec3a12e79e7 202 if (xposg > 20) Note = C_5; // C
MTYarnell 0:bec3a12e79e7 203 if (xposg > 16) Note = Cs_5; // Cs
MTYarnell 0:bec3a12e79e7 204 if (xposg > 12) Note = D_5; // D
MTYarnell 0:bec3a12e79e7 205 if (xposg > 8) Note = Ds_5; // Ds
MTYarnell 0:bec3a12e79e7 206 if (xposg > 4) Note = E_5; // E
MTYarnell 0:bec3a12e79e7 207 if (xposg >= 0) Note = F_5; // F
MTYarnell 0:bec3a12e79e7 208 if (xposg > -4) Note = Fs_5; // Fs
MTYarnell 0:bec3a12e79e7 209 if (xposg > -8) Note = G_5; // G
MTYarnell 0:bec3a12e79e7 210 if (xposg > -12) Note = Gs_5; // Gs
MTYarnell 0:bec3a12e79e7 211 if (xposg > -16) Note = A_5; // A
MTYarnell 0:bec3a12e79e7 212 if (xposg > -20) Note = As_5; // As
MTYarnell 0:bec3a12e79e7 213 else Note = B_5; // B
MTYarnell 0:bec3a12e79e7 214 } else { // Octave 6
MTYarnell 0:bec3a12e79e7 215 if (xposg > 20) Note = C_6; // C
MTYarnell 0:bec3a12e79e7 216 if (xposg > 16) Note = Cs_6; // Cs
MTYarnell 0:bec3a12e79e7 217 if (xposg > 12) Note = D_6; // D
MTYarnell 0:bec3a12e79e7 218 if (xposg > 8) Note = Ds_6; // Ds
MTYarnell 0:bec3a12e79e7 219 if (xposg > 4) Note = E_6; // E
MTYarnell 0:bec3a12e79e7 220 if (xposg >= 0) Note = F_6; // F
MTYarnell 0:bec3a12e79e7 221 if (xposg > -4) Note = Fs_6; // Fs
MTYarnell 0:bec3a12e79e7 222 if (xposg > -8) Note = G_6; // G
MTYarnell 0:bec3a12e79e7 223 if (xposg > -12) Note = Gs_6; // Gs
MTYarnell 0:bec3a12e79e7 224 if (xposg > -16) Note = A_6; // A
MTYarnell 0:bec3a12e79e7 225 if (xposg > -20) Note = As_6; // As
MTYarnell 0:bec3a12e79e7 226 else Note = B_6; // B
MTYarnell 0:bec3a12e79e7 227 }
MTYarnell 0:bec3a12e79e7 228
MTYarnell 0:bec3a12e79e7 229 // Get magnetometer data
MTYarnell 0:bec3a12e79e7 230 mag.acquire_mag_data_uT(mag_data);
MTYarnell 0:bec3a12e79e7 231 // Find RMS values of this 3-axis reading
MTYarnell 0:bec3a12e79e7 232 mag_rms = sqrt(((mag_data[0] * mag_data[0]) + (mag_data[1] * mag_data[1]) + (mag_data[2] * mag_data[2])) / 3);
MTYarnell 0:bec3a12e79e7 233
MTYarnell 0:bec3a12e79e7 234 //printf("\tX: %i \tY: %i \tMAGRMS: %i", xposg, yposg, mag_rms);
MTYarnell 0:bec3a12e79e7 235 // Above line displays modified sensor results, useful for practice or
MTYarnell 0:bec3a12e79e7 236 // debugging.
MTYarnell 0:bec3a12e79e7 237
MTYarnell 0:bec3a12e79e7 238 // If the magnetic field is strong enough, play a note.
MTYarnell 0:bec3a12e79e7 239 if (mag_rms > 150) {
MTYarnell 0:bec3a12e79e7 240 Tune(Buzzer, Note, 2); }// Timing is out of 16ths
MTYarnell 0:bec3a12e79e7 241 }
MTYarnell 0:bec3a12e79e7 242 }