Show Posts
Pages: 1 2 [3] 4 5 ... 11
31  Community / Exhibition / Gallery / Re: V Visitor Laser Gun Replica Prop with Light and Sound on: November 26, 2012, 02:26:18 pm
New version of the software + a fire module selection option. Regular and Stun laser gun. Everything working at 5V.



Code:
/*
 Sketch to control a V Visitor laser gun prop.
 Created by Diego J. Arevalo, November 26, 2012.
 Released into the public domain.
 */

#include <Wtv020sd16p.h>
#include <Pam8803.h>
#include "LaserGunFactory.h"

const int WTV_RESET_PIN = 2;
const int WTV_CLOCK_PIN = 3;
const int WTV_DATA_PIN = 4;
const int WTV_BUSY_PIN = 5;
const int ANALOG_LED_PIN= 6;
const int TRIGGER_PIN = 7;
const int FIRE_MODE_PIN = 11;
const LaserGunType LASER_GUN_TYPE = VVisitorLaserGun;
const int AMP_VOLUME_DOWN_PIN = 8;
const int AMP_VOLUME_UP_PIN = 9;
const int AMP_RESET_PIN = 10;

static Pam8803 *pam8803 = NULL;
static LaserGun *laserGun = NULL;
static LaserGunFactoryParameters laserGunFactoryParameters;

void setup() {
  pam8803 = new Pam8803(AMP_RESET_PIN, AMP_VOLUME_UP_PIN, AMP_VOLUME_DOWN_PIN);
  pam8803 -> reset();
  pam8803 -> setVolume(50);
  laserGunFactoryParameters.setWtvResetPin(WTV_RESET_PIN);
  laserGunFactoryParameters.setWtvClockPin(WTV_CLOCK_PIN);
  laserGunFactoryParameters.setWtvDataPin(WTV_DATA_PIN);
  laserGunFactoryParameters.setWtvBusyPin(WTV_BUSY_PIN);
  laserGunFactoryParameters.setAnalogLedPin(ANALOG_LED_PIN);
  laserGunFactoryParameters.setTriggerPin(TRIGGER_PIN);
  laserGunFactoryParameters.setFireModePin(FIRE_MODE_PIN);
  laserGunFactoryParameters.setLaserGunType(LASER_GUN_TYPE);
  laserGun = LaserGunFactory::getLaserGun(laserGunFactoryParameters);
}

void loop() {
  laserGun -> senseSwitches();
}

Attached the whole Sketch in this post. Enjoy.
32  Using Arduino / Audio / Re: cheap sound module: what version is this? on: November 26, 2012, 02:12:22 pm
There is a post about the quality of this audio module from a few month ago. Only suitable for voices or fx, no so much for music given the sampling allowed by this ad4 format.
33  Using Arduino / Audio / Re: Arduino library for WTV020-SD-16P audio module on: November 26, 2012, 02:10:50 pm
Well, I don't think any micro sd card works at 5V. So, basically If does not work, It is not weird. If you need your wtv working at 5V, interconnect the diodes 4007 and go back that soldered pin to 3.3v.
34  Using Arduino / Audio / Re: Arduino library for PAM8803 audio amplifier module on: November 20, 2012, 01:45:28 pm
That's why each volume transition requires VUP or VDOWN pin remais active low for 3.5 clock cycles. I did not floating point lib would be included. I will put 105 instead. Thanks for the suggestion.
35  Using Arduino / Audio / Re: Arduino library for PAM8803 audio amplifier module on: November 20, 2012, 01:28:57 pm
Latest lib could be downloaded from the very first post once you are logged in. About the PAM8803 retrolefty found, the price is great but the size is huge. In my laser gun project size and room are quite important. The one I bought, even If the a few bucks expensive, only measures 2cm x 2xm and could be powered from 3.3 up to 6 v.
36  Using Arduino / Audio / Re: Arduino library for PAM8803 audio amplifier module on: November 20, 2012, 10:35:59 am
Updated the library. Now, I will work in improve the volumeUp and Down speed without modify class protocol.
37  Using Arduino / Audio / Re: cheap sound module: what version is this? on: November 19, 2012, 03:15:15 pm
Thanks for taking care of this for me. About delay(30*35), It is cause of the time needed for the pam8803 to process a level up or down active low state. 3.5 clock cycles. Each clock cycle is about 30ms. You can read about it here:

http://www.poweranalog.com/pdf/PAM8803.pdf

There is a way to speed up the volume up/down process. 9.5 times + 2 ms for each level. I am planning to go that way to. But for small increments, 105ms don't sound that bad.

I also would love to continue talking about this here:
http://arduino.cc/forum/index.php/topic,133013.0.html

Don't want to go off-topic here.
38  Using Arduino / Audio / Re: Arduino library for WTV020-SD-16P audio module on: November 19, 2012, 07:59:11 am
You are abs right. Tried that with my two modules and did work. Maybe I tried that in the past with the defective one I had. Good!
39  Using Arduino / Audio / Re: cheap sound module: what version is this? on: November 19, 2012, 07:35:49 am
You are right, your approach seems to be more simpler than mine. I will implement your solution solution ASAP and update my library. Thank you very much. That's why I love to share.
40  Using Arduino / Audio / Re: Arduino library for WTV020-SD-16P audio module on: November 19, 2012, 07:32:13 am
I am running it on 5V supply without changing the jumper , and using 2 diodes.
So, your board is working fine, cause I tried that setup and could not make it work. Functionality was erratically.
41  Using Arduino / Audio / Re: Arduino library for WTV020-SD-16P audio module on: November 18, 2012, 10:34:55 am
Posted a new library here http://arduino.cc/forum/index.php/topic,133013.new.html#new for an audio amplifier that works with this audio module.
42  Using Arduino / Audio / Arduino library for PAM8803 audio amplifier module on: November 18, 2012, 10:34:05 am
 PAM8803 audio amplifier module:



Code:
/*
 Example: Control a PAM8803 amplifier module from an Arduino board.
 Created by Diego J. Arevalo, November 20, 2012.
 Released into the public domain.
 */

#include <Pam8803.h>

int ampVolumeDownPin = 8; // The pin number of the volume down pin.
int ampVolumeUpPin = 9; // The pin number of the volume up pin.
int ampResetPin = 10; // The pin number of the reset pin.

/*
Create an instance of the Pam8803 class.
 1st parameter: Reset pin number.
 2nd parameter: Volume Up pin number.
 3rd parameter: Volume Down pin number.
 */

Pam8803 pam8803(ampResetPin, ampVolumeUpPin, ampVolumeDownPin);

void setup() {
  //Initializes the amplifier module.
  pam8803.reset();
  //Set amplifier volumen in half output power.
  pam8803.setVolume(50);
}

void loop() {
};

Documentation:
http://www.poweranalog.com/pdf/PAM8803.pdf

Unzip Pam8803.zip into your library folder and that's all. There is a .volumeUp, .volumenDown that raise 1 level or decrement in 1 level the volume. You will have a getVolume to get the current level and setVolumen which accepts from 0 to 100 in percentage. Check Pam8803.h for more details or just ask me. Hope this helps.

PD: Thanks robtillaart for your suggestions. They were considered and implemented.
43  Using Arduino / Audio / Re: cheap sound module: what version is this? on: November 18, 2012, 12:26:20 am
Here you have a sample from the PAM8803 library:

Pam8803.h:
Code:
/*
 Pam8803.h - Library to control a PAM8803 amplifier module.
 Created by Diego J. Arevalo, November 18, 2012.
 Released into the public domain.
 */

#ifndef Pam8803_h
#define Pam8803_h

class Pam8803
{
public:
  Pam8803(int resetPin, int volumeUpPin, int volumeDownPin);
  void reset();
  int volumeUp();
  int volumeDown();
  int setVolumeInHalf();
private:
  int _gainSetting;
  int _resetPin;
  int _volumeUpPin;
  int _volumeDownPin;
  void setGainSetting(int volumePin);
};

#endif

Pam8803.cpp:
Code:
/*
 Pam8803.cpp - Library to control a PAM8803 amplifier module.
 Created by Diego J. Arevalo, November 18, 2012.
 Released into the public domain.
 */

#include "Arduino.h"
#include "Pam8803.h"

const int MIN_GAIN_SETTING = 1;
const int POWER_ON_GAIN_SETTING = 13;
const int MAX_GAIN_SETTING = 64;

Pam8803::Pam8803(int resetPin, int volumeUpPin, int volumeDownPin){
  _gainSetting=POWER_ON_GAIN_SETTING;
  _resetPin=resetPin;
  _volumeUpPin=volumeUpPin;
  _volumeDownPin=volumeDownPin;
  pinMode(_resetPin, OUTPUT);
  pinMode(_volumeUpPin, OUTPUT);
  pinMode(_volumeDownPin, OUTPUT);
  digitalWrite(_resetPin, LOW);
  digitalWrite(_volumeUpPin, HIGH);
  digitalWrite(_volumeDownPin, HIGH);
}

void Pam8803::reset(){
  digitalWrite(_resetPin, LOW);
  digitalWrite(_resetPin, HIGH);
}

int Pam8803::volumeUp(){
  if (_gainSetting<MAX_GAIN_SETTING){
    setGainSetting(_volumeUpPin);
    _gainSetting++;
  }
  return _gainSetting;
}

int Pam8803::volumeDown(){
  if (_gainSetting>MIN_GAIN_SETTING){
    setGainSetting(_volumeDownPin);
    _gainSetting--;
  }
  return _gainSetting;
}

int Pam8803::setVolumeInHalf(){
  if (_gainSetting <= MAX_GAIN_SETTING/2) {
    while (_gainSetting <= MAX_GAIN_SETTING/2) {
      volumeUp();
    }
  }
  else{
    while (_gainSetting >= MAX_GAIN_SETTING/2) {
      volumeDown();
    }
  }
  return _gainSetting;
}

void Pam8803::setGainSetting(int volumePin){
  digitalWrite(volumePin, LOW);
  delay(30*3.5);
  digitalWrite(volumePin, HIGH);
};

and It is working. void setVolumeInHalf is quite useful. Actually using my 8,9 and 10 pin for the amp.

Final library posted here:
http://arduino.cc/forum/index.php/topic,133013.new.html#new
44  Using Arduino / Audio / Re: cheap sound module: what version is this? on: November 16, 2012, 06:52:57 am
Hey guys, anyone using it at 5V? Cause I moved the soldered pin from 3.3 to 5 and could not get it to work. Quite erratically. I did not use any diode cause I believe they are soldered in the pcb board. Any idea?
45  Using Arduino / Audio / Re: Arduino library for WTV020-SD-16P audio module on: November 16, 2012, 06:52:29 am
Hey guys, anyone using it at 5V? Cause I moved the soldered pin from 3.3 to 5 and could not get it to work. Quite erratically. I did not use any diode cause I believe they are soldered in the pcb board. Any idea?
Pages: 1 2 [3] 4 5 ... 11