xmas-box: Arduino/ioBridge internet controlled Christmas lights and music show

 by noelportugal

Step 3: Arduino Sketch

DSC_0040.JPG
ArduinoDuemilanove.jpg
You can download the Arduino Sketch from the bottom of this page (xmas_box.pde).
 You will need the following Arduino Libraries:

- AF_Wave and Wave
- String (formerly TextString)

Here is a run down for the pin connections on the Arduino with WAVE shield on top.

Communication
D0(RX) -> ioBridge Serial Board TX
D1(TX )-> ioBridge Serial Board RX

D2-D5 are used by the WAVE shield (they could be changed)
D2 -> LCS
D3 -> CLK
D4 -> DI
D5 -> LAT

xmas-box first 3 channels
D6 -> Channel 1
D7 -> Channel 2
D8 -> Channel 3

FM transmitter ON/OFF
D9 -> 10k resistor -> 2N2222 Base -- Collector and Emitter to FM transmitter switch

WAVE shield
D10 -> CCS

SD card WAVE shield communication (cannot be changed)
D11
D12
D13

Power
Gnd[0] -> Relay daisy chain.
5v pin -> FM transmitter positive
Gnd[1] -> FM transmitter ground
Gnd[2] -> ioBridge Smart Serial Board

Vu Meter
A0 -> R7 1.5K on the WAVE shield to measure output from amplifier. See image.

Analog pins 1-5 are used as digital out for xmas-box channels
A1 = D15 -> Channel 4
A2 = D16 -> Channel 5
A3 = D17 -> Channel 6
A4 = D18 -> Channel 7
A5 = D19 -> Channel 8

Wave shield speaker (mono) to FM transmitter input

 
Remove these adsRemove these ads by Signing Up
phorensyc says: Nov 21, 2010. 9:21 AM
When I try to upload the sketch to my Arduino, I get multiple error messages:

xmas_box.cpp: In function 'void playComplete(char*)':
xmas_box:167: error: 'class String' has no member named 'append'
xmas_box:196: error: 'class String' has no member named 'append'
xmas_box:198: error: 'class String' has no member named 'append'
xmas_box:199: error: 'class String' has no member named 'append'
xmas_box:200: error: cannot convert 'String' to 'char*' in assignment

I'm using arduino-0021 which supposedly has string class incorporated in it. Do I need to modify the code? If so, please tell me how.
noelportugal (author) in reply to phorensycNov 21, 2010. 4:52 PM
I'm using arduino 0017, so maybe that is the issue. For the error you get it is related to the String library. I wonder if there is a new lib?
Let me see if I found something.
phorensyc in reply to noelportugalNov 28, 2010. 10:02 AM
Hi Noel,

I replaced all the "append" references with "concat" in your code, and that seemed to eliminate the errors: "no member named 'append'".

However, I am still getting the following error:

xmas_box.cpp: In function 'void playComplete(char*)':
xmas_box:201: error: cannot convert 'String' to 'char*' in assignment

The line that the compiler stops at is:

track = tmpTrack;

I'm sorry to be posting so many questions, but I really want to get this thing working for my lights this year, and I am clueless as to what this error has to do with the above line of code. Do you have any ideas?

I feel like I might have bitten off more than I can chew with this project, because my understanding of computer code is almost non existent, which is forcing me to try to fix the code by trial and error. I can't figure out why I would be the only one getting errors. From the other posts, I assume other people have more recently built the xmas box and used the Arduino 0021 compiler, but maybe not. I'm not opposed to using 0017, but even with that compiler I get errors because I can't download the same string library you used.

If you wouldn't mind replying just to let me know you are reading my posts I would appreciate it, even if you don't know how to help me yet. I will try picking this project up again at a later date if necessary when I have some programming under my belt. I've already invested in all the materials and partially assembled the instructable though, so I'm determined to complete it eventually, even if I have to wait 'til next year to get to use it.

Thanks in advance.
noelportugal (author) in reply to phorensycNov 28, 2010. 10:29 AM
@phorensyc I think you are almost there...Obviously there is an issue with using Strings or Chars. I havent fired up my code this year... I will upgrade to arduino 0021 and compile it...I will use the x-mas box in my christmas tree this year.
Keep up at it...Try the Arduino forums as well...I will let you know if i run in the same issue and how i solve it.

-Noel
phorensyc in reply to noelportugalDec 3, 2010. 11:30 AM
Hi Noel, I fixed the final error. I posted my solution on your instructable. One other question though:

The instructable says to use pin connection D10 for LCS. It looks like from the picture that D10 should be connected to CCS. Is this correct?
noelportugal (author) in reply to phorensycDec 3, 2010. 12:11 PM
Correct. Its D10 to CCS
phorensyc in reply to noelportugalDec 3, 2010. 9:01 AM
I was able to solve the final error. I did a lot of searching, and don't fully understand all the changes that have taken place with the string libraries since you published this instructable, but the issue seemed to be that the variable track was declared as a char, and tmpTrack is a string, and the new string library can only convert a string to a char with the function toCharArray()

The link for the string library you have in your instructable only takes you to a page that tells you that the TextString library is now obsolete. String libraries are now included natively with the code compiler.

The instructions for the use of toCharArray() on the Arduino site are limited and some say a bit misleading, so I'll just share what I changed to make the program compile and load with the new string library.

Okay, I seem to have fixed it, or at least changed it to where the code compiles and loads on the Arduino. I replaced the following line of code:

track=tmpTrack;

with this:

char tracklngth[tmpTrack.length() + 1];
tmpTrack.toCharArray(tracklngth, tmpTrack.length() + 1);
track = tracklngth;

Sorry if this is an abomination to all seasoned programmers out there, but it's the best I could come up with. I'm sure it could have been done in one or two lines, but I'm in a hurry to get the xmas_box working.
paul90 says: Nov 8, 2010. 7:23 AM
what do u connect the first three channel wires up to?
als_liahona says: Dec 3, 2009. 1:10 PM
Any chance you can upload a schematic so we can get a better feel for how each component interacts?  Thanks.
noelportugal (author) in reply to als_liahonaDec 9, 2009. 7:27 PM
 Yes...As soon as I can figure out Eagle!! Do you have another software recommendation to do schematics?  
als_liahona in reply to noelportugalDec 10, 2009. 7:21 PM
Eagle was a pain to learn, but not too bad.  The tricky part is finding things in the library.

I've heard good things about gEDA (http://www.gpleda.org/) on Linux, but I've not tried it yet myself.

There are also some schematic/PCB editors made by PCB companies that you can possible export an image from after creating the schematic.

I hope that helps.
Pro

Get More Out of Instructables

Already have an Account?

close

PDF Downloads
As a Pro member, you will gain access to download any Instructable in the PDF format. You also have the ability to customize your PDF download.

Upgrade to Pro today!