Pages: [1]   Go Down
Author Topic: Reset Transistor: Soldering/Coding advice  (Read 927 times)
0 Members and 1 Guest are viewing this topic.
Reading, Berkshire
Offline Offline
Full Member
***
Karma: 2
Posts: 132
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Hi,
How would you go about soldering this to the reset button on the arduino so that pin 24 can trigger a reset?
« Last Edit: May 16, 2012, 08:53:40 am by stuarthooper » Logged

Seattle, WA USA
Offline Offline
Brattain Member
*****
Karma: 601
Posts: 48556
Seattle, WA USA
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
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?
Logged

Reading, Berkshire
Offline Offline
Full Member
***
Karma: 2
Posts: 132
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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).
Code:
#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
  }
}
Logged

Seattle, WA USA
Offline Offline
Brattain Member
*****
Karma: 601
Posts: 48556
Seattle, WA USA
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
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.
Logged

Reading, Berkshire
Offline Offline
Full Member
***
Karma: 2
Posts: 132
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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

Code:
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
Code:
#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.
Logged

Seattle, WA USA
Offline Offline
Brattain Member
*****
Karma: 601
Posts: 48556
Seattle, WA USA
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Code:
   while(0);   
Why? Since 0 is not true, this does nothing.

Code:
        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?

Code:
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?
Logged

Reading, Berkshire
Offline Offline
Full Member
***
Karma: 2
Posts: 132
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

The PSKey is the play/pause button on the shield.
Code:
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
Code:
Record(); refers to record.h

I have cleaned this up but the reset still doesn't work.
Code:
#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
  }
}
Logged

Seattle, WA USA
Offline Offline
Brattain Member
*****
Karma: 601
Posts: 48556
Seattle, WA USA
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
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.

Quote
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.
Logged

Reading, Berkshire
Offline Offline
Full Member
***
Karma: 2
Posts: 132
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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.

Code:
#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
  }
}
Logged

Reading, Berkshire
Offline Offline
Full Member
***
Karma: 2
Posts: 132
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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

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

https://github.com/n0m1/Sleep_n0m1

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!
Logged

Seattle, WA USA
Offline Offline
Brattain Member
*****
Karma: 601
Posts: 48556
Seattle, WA USA
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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

Quote
I'm going to try.
Whatever.

Code:
SoftwareSerial mySerial(2, 3);
You've got 4 hardware serial ports. Why are you using SoftwareSerial?
Logged

Reading, Berkshire
Offline Offline
Full Member
***
Karma: 2
Posts: 132
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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?

Logged

Seattle, WA USA
Offline Offline
Brattain Member
*****
Karma: 601
Posts: 48556
Seattle, WA USA
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
Have you used this shield before?
No.

Quote
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.
Logged

UK
Offline Offline
Shannon Member
****
Karma: 223
Posts: 12577
-
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

I only provide help via the forum - please do not contact me for private consultancy.

Pages: [1]   Go Up
Jump to: