Reset Transistor: Soldering/Coding advice

Hi,
How would you go about soldering this to the reset button on the arduino so that pin 24 can trigger a reset?

How would you go about soldering this to the reset button on the arduino so that pin 24 can trigger a reset?

I wouldn't. Why do you want the Arduino to physically reset itself?

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
  }
}

The seeeduino music shield needs to be reset to activate the record mode.

According to http://seeedstudio.com/wiki/Music_Shield:
D14(A0) - Used for Reset of VS1053.

So, what reset button are you trying to connect the transistor to, and why? All you need to do to reset the VS1053 (it that is what you have) is set D14 HIGH for a period of time.

I have tried adding a reset of pin 54 (on the mega) like this

const int reset = 54;
void setup()
{
  pinMode(reset, OUTPUT);
  digitalWrite(reset, LOW);
}

void loop()
{
   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();
        delay(3000);
        digitalWrite(reset, HIGH);
        delay(5000);
   }
  #endif
  }}

Into here as displayed

#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
const int reset = 54;

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);
  pinMode(reset, OUTPUT);
  digitalWrite(groundpin, LOW); 
  digitalWrite(powerpin, HIGH);
  digitalWrite(reset, LOW);
  
  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();
        delay(3000);
        digitalWrite(reset, HIGH);
        delay(5000);
   }
  #endif
  }
}

but it doesn't seem to do anything.

   while(0);

Why? Since 0 is not true, this does nothing.

        while(0 == PSKey);

I don't know where PSKey is defined, or what it's value is, but if it is 0, this is an infinite loop with no way to exit. Why?

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
const int reset = 54;

The mix of aliases and real pin numbers is confusing. Use a consistent numbering scheme.

What does Record() do? I would expect that that is where you would set the reset pin HIGH for a period of time, then LOW.

The shield has LEDs that indicate it's status. Do the LEDs change color/state when you run that code?

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
  }
}

tells the record function to keep recording until the button is pressed.

No, it does not. It says "Do nothing forever, if PSKey is 0.". Fortunately, for you, PSKey appears not to be 0. If that while loop is to do what you think, there needs to be a digitalRead() statement involved somewhere.

I think Record(); refers to record.h.

But, you are still calling it before activating the shield reset mechanism. You also still have that silly while(0) statement.

I'm not sure how to write it so that it works how I want.

Start in play mode>Play all recordings>Then reset

If tilted> Reset into play mode

Start in record mode> Record until tilted>Reset.

This (I hope) is the barebones code. I need to set up the reset mode but I do not know how.

Sorry if my code is sloppy.

#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

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);
  digitalWrite(groundpin, LOW); 
  digitalWrite(powerpin, HIGH);

  
  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 at boot the Arduino is tilted past 30 degrees on the X or Y axis, Playback. If not then reset shield and enter recording.
   if (analogRead(xpin) > 589 ||analogRead(xpin) < 433||analogRead(ypin) > 589 ||analogRead(ypin) < 433  )
  {
   Play();     
  }
else
  {
    #if defined(__AVR_ATmega2560__)
   {
        Record();
   }
  #endif
  }
}

Found this on another forum topic. Do you think it will work for this project?
I'm going to try.

aleph8nought:
I recently put together a simple sleep library that does exactly what this poster is looking for. You can find it here:

GitHub - n0m1/Sleep_n0m1: A library that sets the Arduino into sleep mode for a specified length of time, or until an interrupt

In this library you can set how long the arduino sleeps for by calling the function sleepDelay(milliseconds of sleep). It works pretty much the same as the delay() function but it sleeps the arduino for that time. It works using the watchdog timer so you can even use it in full power down mode. It includes a few examples to get your started. I hope this helps someone out there! Goodluck!

Found this on another forum topic. Do you think it will work for this project?

No.

I'm going to try.

Whatever.

SoftwareSerial mySerial(2, 3);

You've got 4 hardware serial ports. Why are you using SoftwareSerial?

Because I'm working from the example code 'musicPlayAll' as it had half of what I needed already working. I figured it would be the best starting place as it is recommended on the Music Shield Wiki.

Have you used this shield before?

Can you help with the problem I am asking about instead of picking apart every other aspect of the sketch?

Have you used this shield before?

No.

Can you help with the problem I am asking about instead of picking apart every other aspect of the sketch?

I'm trying, but when I see what look to me like fundamental errors in the sketch, I can't seem to get past them. Sorry.

stuarthooper:
The seeeduino music shield needs to be reset to activate the record mode.

There is a bit of a disconnect between a ten line demo program that decides whether to record after a reset, and the conclusion that the shield has to be reset in order to record.

I'm not convinced that the shield does actually have to be reset, but if it does then the music library gives you a soft reset function which would seem adequate. If that doesn't do the job then there is a reset pin on the shield which would enable you to hard reset the shield without resetting the host Arduino. But so far I don't see anything to suggest that you do actually need to reset anything.

In other words, I think you're going to extraordinary lengths to solve a problem which doesn't exist.