For my final Year project i m making a device which help disabled ppl (who cant speak) to communicate with others. So I m using 2 arduino, RF recceiver transmitter pair,4 push buttons, sd module and speaker. In Arduino which is the transmitter side, i have connected 4 push buttons in it and every button has different character to transmit. Arduino 2 receives the data and plays music through a speaker. Now for RF communication I have used VirtualWire library and For audio i have used Tmrpcm library. The problem is that the receiver side only receives data once. I have seen that when i use "vw_setup(2000)", the music does not play. Can anybody tell me how to solve this..?? Plz help me..
The Code of the receiver side is given below
#include <VirtualWire.h>
#include <SD.h>
#include <TMRpcm.h>
#include <SPI.h>
TMRpcm audio;
#define SD_ChipSelectPin 8
void setup()
{
audio.speakerPin=9;
if (!SD.begin(SD_ChipSelectPin)) {
Serial.println("SD fail");
return;}
else{
Serial.println("SD ok");
}
vw_set_rx_pin(2);
vw_set_ptt_inverted(true); // Required for DR3100
vw_setup(8000); // Bits per sec
vw_rx_start(); // Start the receiver PLL running
}
void loop()
{
uint8_t buf[VW_MAX_MESSAGE_LEN];
uint8_t buflen = VW_MAX_MESSAGE_LEN;
if (vw_get_message(buf, &buflen)) // Non-blocking
{
switch (buf[0]){
case 'H':
audio.play("Hungry.wav");
audio.quality(1);
audio.volume(1);
audio.setVolume(6);
break;
case 'B':
audio.play("Bored.wav");
audio.quality(1);
audio.volume(1);
audio.setVolume(6);
break;
default:
break;
}
}
}