Using Arduino to control Sound

Hi,

I am currently using Arduino for an installation that I am creating for my Final Major Project. At the moment, Arduino is used with a relay to control light and vibration pillow activated by a switch. The final part of this is getting that same switch to activate sound from a DVD player. My tutor advised me to use this method to do so but it isn't working for me (code is below)

#include <Chrono.h>
#include <LightChrono.h>
Chrono myChrono;

int LED = 12;
int BUTTON = 4;
int PILLOW = 3;
long lightsDelay = 4 * 60 * 1000L;
long vibrationDelay = 1000L;

boolean toggle = false;

int IRledPin = 13; // LED connected to digital pin 13

void setup()
{
Serial.begin(9200);
pinMode(LED, OUTPUT);
pinMode(BUTTON, INPUT);
pinMode(PILLOW, OUTPUT);
digitalWrite(LED, HIGH);
digitalWrite(PILLOW, HIGH);
myChrono.restart();
myChrono.stop();

// initialize the IR digital pin as an output:
pinMode(IRledPin, OUTPUT);
}

void loop()
{
Serial.println(myChrono.elapsed());

if (myChrono.hasPassed(vibrationDelay + 8000L) && toggle == true) {

digitalWrite(PILLOW, HIGH);

}if (myChrono.hasPassed(vibrationDelay + 55000) && toggle == true) {

digitalWrite(PILLOW, LOW);

}

if (myChrono.hasPassed(vibrationDelay + 63000) && toggle == true) {

digitalWrite (PILLOW, HIGH);

}

if (digitalRead(BUTTON) == HIGH && toggle == false)
{
//Serial.println("pressed");
toggle = true;
digitalWrite(LED, LOW);
SendChannelUpCode();
myChrono.restart();
}
}

void lightsOn() {
//Serial.println("on");
digitalWrite(LED, HIGH);

}

// This procedure sends a 38KHz pulse to the IRledPin
// for a certain # of microseconds. We'll use this whenever we need to send codes
void pulseIR(long microsecs) {
// we'll count down from the number of microseconds we are told to wait

cli(); // this turns off any background interrupts

while (microsecs > 0) {
// 38 kHz is about 13 microseconds high and 13 microseconds low
digitalWrite(IRledPin, HIGH); // this takes about 3 microseconds to happen
delayMicroseconds(10); // hang out for 10 microseconds
digitalWrite(IRledPin, LOW); // this also takes about 3 microseconds
delayMicroseconds(10); // hang out for 10 microseconds

// so 26 microseconds altogether
microsecs -= 26;
}

sei(); // this turns them back on
}

void SendChannelUpCode() {
// This is the code for the CHANNEL + for the TV COMCAST
Serial.println("send");

delayMicroseconds(748); //Time off (LEFT column)
pulseIR(2760); //Time on (RIGHT column) <-------DO NOT MIX THESE UP
delayMicroseconds(900);
pulseIR(460);

}

I am very new to this and any help would be greatly appreciated

Thanks,
Alice

Your DVD player has an infra red remote control unit and you are attempting to operate that DVD player by using an Arduino with IR led to simulate the operation of that infra red remote control ?

I would tend to use on of the examples below which use a standard Arduino library. You are interested only in the send / transmit part of the code.

You will also have to experiment to find the codes for the activities you want to perform on the DVD player such as (a) switching it on (b) switching it off (c) starting a specific track etc. etc.

https://www.pjrc.com/teensy/td_libs_IRremote.html

Thanks for your reply. Yes - I am using a surround sound DVD player - is this possibly the reason that it isn't working? As it is working with ordinary DVD players and televisions proving that the code and component are right.

Thanks!
Alice