Pages: [1]   Go Down
Author Topic: bcd in / waveshield out ?  (Read 1181 times)
0 Members and 1 Guest are viewing this topic.
Cape Town South Africa
Offline Offline
Edison Member
*
Karma: 19
Posts: 1217
A newbie with loads of posts, and still so much to learn !
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Hi,
I want to have 9 buttons wirelessly sound 9 different wave files.

I am using the Holtek HT12E chips in each transmit button, and tried testing the HT12E.h library I found on this forum to decode it, but it would not compile, just a load of gibberish where the debug error normally shows up.

I can use the normal HT12D chip to decode the data from the Rx and give me a 4 bit BCD number. one bit to each of 4 inputs of the micro.

I will then need to convert this ( I presume ) into a number to send as a waveshield file identifier.  

Am I thinking right here ? , or is there a better way, or a library that can decode the HT12 codes properly - I might have been doing something stupid of course :-/



Logged

With my mobile phone I can call people and talk to them -  how smart can you get ?

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

Quote
I am using the Holtek HT12E chips in each transmit button, and tried testing the HT12E.h library I found on this forum to decode it, but it would not compile, just a load of gibberish where the debug error normally shows up.
Perhaps that "gibberish" just needs a bit of experience to understand. Post the code, or a link to it, and the "gibberish".
Logged

Cape Town South Africa
Offline Offline
Edison Member
*
Karma: 19
Posts: 1217
A newbie with loads of posts, and still so much to learn !
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

The link to the Holtek code is

http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1213063480/0

I put the ccp and h files in a library HT12E in the main directory that the other libraries run from OK

when I try to run the example I now get something intelligable i.e.

19: error: HT12E.h: No such file or directory In function 'void loop()':
Bad error line: -3
Logged

With my mobile phone I can call people and talk to them -  how smart can you get ?

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

Quote
when I try to run the example I now get something intelligable i.e.

19: error: HT12E.h: No such file or directory In function 'void loop()':
So, you know what to do to fix the problem?
Logged

Cape Town South Africa
Offline Offline
Edison Member
*
Karma: 19
Posts: 1217
A newbie with loads of posts, and still so much to learn !
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

No I dont know the amswer, I think I have read too many tutorials and got confused.
But for now it seems the best bet would be to use a 2 dollar HT12D and take the 4 data outputs ( the BCD number )  to 4 pins, and call up the array
   int  MyPins []={3,4,5,6}

as well as the Valid Transmission from the HT12 to and with the result.

Would I then use  a  byte()  function to change the array to a byte for the track number of the VaveShield ?

or if the array is a string perhaps atoi ?

Just trying to get the basic idea together



« Last Edit: September 12, 2010, 06:42:45 am by John_Smith » Logged

With my mobile phone I can call people and talk to them -  how smart can you get ?

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

The IDE is looking for the header file in some location. It isn't there.

Use the Sketch + Import Library menu item to see a list of libraries that the IDE knows about.

Use your OS's file explorer function to locate one of those libraries. You should find a folder, a .cpp file, and a .h file with the locatable library's name.

The parent of the folder is the library directory. You should create the HT12E folder in the library directory. In the HT12E directory, you should put HT12E.cpp and HT12E.h.

Make sure all names are HT12E, not ht12e.
Logged

Cape Town South Africa
Offline Offline
Edison Member
*
Karma: 19
Posts: 1217
A newbie with loads of posts, and still so much to learn !
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

OK I have got the Holtek decoding working, and I can latch in the wireless push button numbers ( 1-9 ) in a variable called "track"

I hope I haven't taken too much memory, I am using 9 look up lines to convert the 4 digit bcd to a single number.

I also have the momentary valid transmission "valid" whenever a new ( or the same ) transmitter button is pressed.

I now need to play one of 9 messages from the SD card in my mockup of a Waveshield.

I have looked at a few examples, but I want it to queue, i.e. if a second request comes in while its playing the current message ( each about 3 seconds long ) it must finish the current message, then play the next track.

There is a nine message player at
 http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1230434365 but apart from the card checking, its not commented on, and I don't know what bits to omit or change.

Any suggestions?  

I know I should be starting with easier projects, but I have been bragging about the Arduino and its forum, and if I can get this working its going to be a real feather in Arduinos cap   8-)
Logged

With my mobile phone I can call people and talk to them -  how smart can you get ?

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

Create an array of message names, with all 9 names in it.

When you want to play a message file, use the value in track (minus 1) as an index into the message name array, to get the name of the file to play.

Then, call playfile() with that name.

If you want to queue up messages, you'll need to create a queue class with methods to add a value to the queue and to remove a value from the queue. Add values to the queue whenever they come in.

On each pass through loop, see if wave.isplaying() returns false. If so, and there is anything in the queue, dequeue the first value, and play the corresponding file.
Logged

Cape Town South Africa
Offline Offline
Edison Member
*
Karma: 19
Posts: 1217
A newbie with loads of posts, and still so much to learn !
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Thanks PaulS,
I will try that array, I have got the waveshield running with one of the waveHC examples with 6 switches.

While it doesn't queue, it doesn't interrupt the current message which will do for now, till I work on your suggestion.

While the message is playing, is the whole sketch loop running? or does it go into some loop of its own?

I have 640 bytes of ram over so hopefully I can add my bcd converter to the top without trouble.

So now I must play with the triggering and add the other files.

Thanks
Logged

With my mobile phone I can call people and talk to them -  how smart can you get ?

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

Quote
While the message is playing, is the whole sketch loop running?
Yes. That's why there is the isplaying method. It's there so you can check whether a file is still playing, so you don't start another one until the previous one ends, but playing is not blocking.
Logged

Cape Town South Africa
Offline Offline
Edison Member
*
Karma: 19
Posts: 1217
A newbie with loads of posts, and still so much to learn !
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

I am struggling with the char array a bit, but the example I have been borrowing from for testing the waveshield uses switch/break statements, would this work for my example with 9 tracks ( I have already established the track number requested   "track" )

 switch (track()) {
    case 1:
      playcomplete("tillnum1.wav");
      break;
    case 2:
      playcomplete("tillnum2.wav");
      break;
    case 3:
      playcomplete("tillnum3.wav");
      break;
    case 4:
      playcomplete("tillnum4.wav");
      break;
    case 5:
      playcomplete("tillnum5.wav");
      break;
    case 6:
      playcomplete("tillnum6.wav");
     case 7:
      playcomplete("tillnum7.wav");
      break;
    case 8:
      playcomplete("tillnum8.wav");
      break;
    case 9:
      playcomplete("tillnum9.wav");
Logged

With my mobile phone I can call people and talk to them -  how smart can you get ?

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

As long as you add a break to the last case, and a curly brace to close the statement, that will work.

You could create the array like this:

Code:
char *songs[] = {"tillnum1.wav",
  "tillnum2.wav",
  "whatever.wav",
  "somethingelse.wav",
  "anotherFile.wav"};
Add as many initializes as you have tracks. Then, you just need:
Code:
playcomplete(songs[track()-1]);
Logged

Cape Town South Africa
Offline Offline
Edison Member
*
Karma: 19
Posts: 1217
A newbie with loads of posts, and still so much to learn !
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Thanks

I will try that over the weekend,  at the moment it is all running fine with

  if (track==1) {playcomplete("tillnum1.wav");}
else;
   if (track==2) {playcomplete("tillnum2.wav");}
else;

and so on,  but I will try the others so I can get used to the options.

Logged

With my mobile phone I can call people and talk to them -  how smart can you get ?

Pages: [1]   Go Up
Jump to: