wave shield and analog pins
Moderators: adafruit_support_bill, adafruit

wave shield and analog pins

by ashapiro on Thu Mar 28, 2013 9:11 pm

My project uses all six of the analog pins to control the lighting of LEDs. I would like to use the Wave Shield to add audio while the LEDs are flashing. In my previous request I was assured that that is possible. But I now find that the Wave Shield uses pins 13, 12, 11, and 10 for the SD and pins 3 and 5 are used for the DAC. Is there a conflict? Is there a way to use the analog pins for both purposes?

Arthur
ashapiro
 
Posts: 25
Joined: Tue Oct 23, 2012 2:25 pm

Re: wave shield and analog pins

by adafruit_support_bill on Fri Mar 29, 2013 5:55 am

the Wave Shield uses pins 13, 12, 11, and 10 for the SD and pins 3 and 5 are used for the DAC. Is there a conflict?

Those are all digital pins. There is no conflict with the analog pins.
User avatar
adafruit_support_bill
 
Posts: 29028
Joined: Sat Feb 07, 2009 9:11 am

Re: wave shield and analog pins

by ashapiro on Fri Mar 29, 2013 10:13 am

I guess I'm confused. I thought that pins 3,5,6,9,10,11 can be used as analog pins for the purpose of PWM and the control of LEDs. My current sketch uses all of them to control the flashing of 1, 2, or 3 banks of LEDs and there are a total of 6 banks each connected to one of the analog pins. Am I under a mistaken impression that there is a difference between the six pins I listed that can be used as analog pins and the six analog input pins A0,...,A5? If not, how can pin 11, for example, be digital for the Wave Shield and analog for the PWM application? Can it be both at the same time?

Arthur
ashapiro
 
Posts: 25
Joined: Tue Oct 23, 2012 2:25 pm

Re: wave shield and analog pins

by adafruit_support_bill on Fri Mar 29, 2013 10:29 am

We have a bit of confusion with the terminology:

"Analog Pins" are the 6 pins labeled A0-A5. They can be used for reading analog signals. They can also be used as digital pins (as they are in all the WaveShield 6-button examples).

Pins labeled 0-13 are known as the "Digital Pins". Pins 3,5,6,9,19 & 11 are also called "PWM pins". You control the PWM pins via "analogWrite", but they are not generally referred to as "analog pins".

So you do have a conflict with the PWM pins. But there are other options for PWM control of LEDs. :)

The 16 channel PWM breakout is controlled with just 2 pins (A4 & A5). http://www.adafruit.com/products/815
We also have RGB LED strands that can be controlled by any 2 pins. http://www.adafruit.com/index.php?main_ ... +%2Bstrand
And you can control a whole chain of Flora pixels with a single pin: http://www.adafruit.com/products/1260
User avatar
adafruit_support_bill
 
Posts: 29028
Joined: Sat Feb 07, 2009 9:11 am

Re: wave shield and analog pins

by ashapiro on Fri Mar 29, 2013 4:54 pm

Your response looks like really bad news. The second and third of your suggestions are out of the question. The problem with the first one is that I spent a couple of weeks completing the fairly complicated sketch for the LED part of the project (a sort of a "show") and now going the PWMServo route looks as though the entire programming for the LED part of the project would have to be redone. Can you think of another way to have the audio and the LED "show" play simultaneously?

Arthur
ashapiro
 
Posts: 25
Joined: Tue Oct 23, 2012 2:25 pm

Re: wave shield and analog pins

by ashapiro on Fri Mar 29, 2013 4:57 pm

PS--Would it make any sense to use a second Arduino Uno for the audio via the Wave Shield as a slave to the first one (connected by I2C)?

Arthur
ashapiro
 
Posts: 25
Joined: Tue Oct 23, 2012 2:25 pm

Re: wave shield and analog pins

by ashapiro on Fri Mar 29, 2013 5:22 pm

PPS--Would it help if the audio is in MP3 or some other format?
Arthur
ashapiro
 
Posts: 25
Joined: Tue Oct 23, 2012 2:25 pm

Re: wave shield and analog pins

by pburgess on Fri Mar 29, 2013 8:33 pm

Hi Arthur,

Using a second Arduino as an I2C slave is one possibility. Serial may be easier, though you'll have to separate the two when uploading code (apparently it takes some extra hoops to do I2C slave on an Arduino -- never done it myself -- Google around, there seem to be some tutorials, I just haven't reviewed them in depth).

This is just one of those cases that highlights the Arduino can do any one thing really well, but walking and chewing gum at the same time is often problematic. The Wave Shield uses a majority of the Arduino's RAM and, as you've seen, is reliant on a few specific pins. You could reclaim some of the pins by tweaking WavePinDefs.h and rewiring the DAC lines on the shield, but not all six -- a couple are shared by the chip's SPI hardware, no way around it.
User avatar
pburgess
 
Posts: 2525
Joined: Sun Oct 26, 2008 1:29 am

Re: wave shield and analog pins

by adafruit_support_bill on Sat Mar 30, 2013 5:34 am

There is also a "SoftPWM" library out there that is supposed to do PWM on any pin. It uses Timer2, so I don't think it will have any timer conflicts with the Wave Shield.

https://code.google.com/p/rogue-code/wi ... umentation
User avatar
adafruit_support_bill
 
Posts: 29028
Joined: Sat Feb 07, 2009 9:11 am

Re: wave shield and analog pins

by ashapiro on Sat Mar 30, 2013 7:42 pm

PBurgess
Thanks for the information on using 2 Arduinos. I'm sure I'll get this running one way or another.
Arthur
ashapiro
 
Posts: 25
Joined: Tue Oct 23, 2012 2:25 pm

Re: wave shield and analog pins

by ashapiro on Sat Mar 30, 2013 7:43 pm

Thanks for the link to SoftPWM. It may very well do the trick.
Arthur
ashapiro
 
Posts: 25
Joined: Tue Oct 23, 2012 2:25 pm