The seeeduino music shield needs to be reset to activate the record mode.
I want to set it so that it records, resets after 10 seconds and if it's tilted over 30 degrees it plays back the recording.
I have almost all of the code working but it still needs to be reset physically which is an impossibility for this project (it's going to be sealed inside a bottle).
#include <avr/io.h>
#include "config.h"
#include "filesys.h"
#include "player.h"
#include "vs10xx.h"
#include "record.h"
#include <SoftwareSerial.h>
const int groundpin = 66; // analog input pin 4 -- ground
const int powerpin = 67; // analog input pin 5 -- voltage
const int xpin = A11; // x-axis of the accelerometer
const int ypin = A10; // y-axis od the accelerometer
SoftwareSerial mySerial(2, 3);//pin2-Rx,pin3-Tx(note: pin3 is actually later used as volume down input(not needed))
void setup()
{
Serial.begin(9600);
//Serial.println("Hello test!");
// Provide ground and power by using the analog inputs as normal
// digital pins. This makes it possible to directly connect the
// breakout board to the Arduino.
pinMode(groundpin, OUTPUT);
pinMode(powerpin, OUTPUT);
digitalWrite(groundpin, LOW);
digitalWrite(powerpin, HIGH);
InitSPI();
InitIOForVs10xx();
InitIOForKeys();
InitIOForLEDs();
InitFileSystem();
//VsSineTest();
Mp3Reset();
}
void loop()
{
// print the sensor values:
Serial.print(analogRead(xpin));
// print a tab between values:
Serial.print("\t");
Serial.print(analogRead(ypin));
// print a tab between values:
Serial.print("\t");
Serial.println();
/*
Set X&Y axis to light up an LED if the accelerometer tips past 30 degrees in any direction from flat.
|| means 'as well as'
< and > mean greater or less than
*/
// If the bottle tips past 30 degrees on the X or Y axis, record. If not, Playback.
if (analogRead(xpin) > 589 ||analogRead(xpin) < 433||analogRead(ypin) > 589 ||analogRead(ypin) < 433 )
{
Play();
while(0);
}
else
{
#if defined(__AVR_ATmega1280__)|| defined(__AVR_ATmega2560__)
// If play/stop button is pressed during boot, enter recording.
{
delay(20);
while(0 == PSKey);
delay(20);
Record();
}
#endif
}
}