The PSKey is the play/pause button on the shield.
while(0 == PSKey);
tells the record function to keep recording until the button is pressed.
I've taken that code out as I will not use it in my design. Thanks for the pointer.
I think Record(); refers to record.h
I have cleaned this up but the reset still doesn't work.
#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 = 65; // x-axis of the accelerometer
const int ypin = 64; // y-axis od the accelerometer
const int reset = 54;
SoftwareSerial mySerial(2, 3);
void setup()
{
Serial.begin(9600);
/*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);
pinMode(reset, OUTPUT);
digitalWrite(groundpin, LOW);
digitalWrite(powerpin, HIGH);
digitalWrite(reset, LOW);
InitSPI();
InitIOForVs10xx();
InitIOForKeys();
InitIOForLEDs();
InitFileSystem();
Mp3Reset();
}
void loop()
{
/*
Set X&Y axis to light up an LED if the accelerometer tips past 30 degrees in any direction from flat.
|| means 'or'
< and > mean greater or less than
*/
// If the Arduino tilts past 30 degrees on the X or Y axis, Playback. If not, Record.
if (analogRead(xpin) > 589 ||analogRead(xpin) < 433||analogRead(ypin) > 589 ||analogRead(ypin) < 433 )
{
while(0);
Play();
}
else
{
#if defined(__AVR_ATmega2560__)
// If within 30 degrees on X and Y during boot, enter recording.
{
delay(20);
delay(20);
Record();
delay(10000);
digitalWrite(reset, HIGH);
delay(7000);
digitalWrite(reset, LOW);
}
#endif
}
}