Hello, I have a problem with a project I'm working on. I have written a c# program that uses voice recognition to send a serial response to an arduino. The arduino then uses an IR Led to send a code to either the TV or cable box. I used the ken shirriff's irdemo to implement this. I had everything working and then when I put everything in a project box I purchased from radio shack it started acting weird. I have the Raw codes stored in an array and some of the codes work and some of them don't I put in a println statement to print the array out to make sure that I was sending the right codes, however on the codes that are not working, it skips the first element of the array. In the beginning of the code where I declare the arrays, if I move an array down to the bottom of the list, that array will then work, however a different will stop working. Also, when I println a string, it prints out complete garbage, for example if I println "off" it prints out:
bô?&?ôb&?ô?&?&?ô?&?&?ôb&?ôb&0&(#0&0&?&0&b&0&0Xf&?&f&?&fXf&?&fXf&?&ö"?&?&bXfXf&?Xb&?Xf&?&?&?&fXfXb&?&?&ö"bôb&bô?&0&bôÊô?&?ô?&?&?ô?&?ôÊôbôÊôö"bôb&?ôb&?ôb&0&?&?ô?&?ôÊô?&?ôÊô?&bôö"b&?&f&?&?ôb&0&?&?&f&?&?ô?&bô?&bôb&0
I have listed part of the code below but i couldn't post all of it because it was too long. I am completely stumped. Is it possible that I have messed up the Arduino when I was putting it in the project box. I have tried it with other components but I don't have another arduino to test it out. Any thoughts are greatly appreciated.
unsigned int rew[35] = {8950 ,4450 ,550 ,2200 ,500 ,4450 ,550 ,4450 ,500 ,4450 ,500 ,4450 ,550 ,2200 ,500 ,2250 ,500 ,2200 ,550 ,2200 ,500 ,2200 ,550 ,2200 ,550 ,2200 ,500 ,4450 ,550 ,2200 ,500 ,2200 ,550 ,2200 ,500};
unsigned int exitbtn[35] = {8950 ,4500 ,500 ,2200 ,550 ,4450 ,500 ,2200 ,550 ,2200 ,500 ,4450 ,550 ,2200 ,500 ,2200 ,550 ,2200 ,550 ,2200 ,500 ,2200 ,550 ,2200 ,550 ,2200 ,500 ,4450 ,550 ,2200 ,500 ,4450 ,550 ,4400 ,550};
unsigned int dvr[35] = {9000, 4400, 550, 4400, 550, 2200, 550, 4400, 550, 4450, 550, 4400, 550, 4400, 600, 2150, 550, 2200, 550, 2150, 550, 2200, 550, 2150, 600, 2150, 550, 2200, 550, 2150, 600, 2150, 550, 2200, 550};
unsigned int info[35] = {8950,4500,550,4500,550,4450,600,2150,600,2150,550,4500,600,4450,550,2200,600,2150,550,2200,550,2200,550,2200,550,2150,600,2150,600,4450,550,2200,550,4500,550};
unsigned int play[35] = {8950 ,4450 ,500 ,4450 ,550 ,4450 ,500 ,2200 ,550 ,4400 ,550 ,4450 ,500 ,2250 ,500 ,2200 ,550 ,2200 ,500 ,2200 ,550 ,2200 ,550 ,2200 ,500 ,2200 ,550 ,2200 ,500 ,2250 ,500 ,4450 ,500 ,2250 ,500};
unsigned int down[35] = {8950,4450,500,4450,550,2200,500,4450,550,2200,500,4450,550,4400,550,2200,550,2200,500,2200,550,2200,500,2250,500,2200,550,2200,500,2250,500,2200,550,4450,500};
unsigned int guide[35] = {8950,4450,550,2200,550,2150,550,2200,550,2200,500,4450,550,4400,550,2200,550,2200,550,2150,550,2200,550,2200,500,2200,550,4450,500,2200,550,4450,500,4450,550};
char c = '0';
void setup()
{
Serial.begin(9600);
}
void loop() {
while (Serial.available() == 0);
c = Serial.read();
if (c == '2') {
for (int i = 0; i < 3; i++) {
irsend.sendSony(0xa90, 12); // Sony TV power code
delay(50);
}
}
if (c == '0') {
for (int i = 0; i < 3; i++) {
irsend.sendSony(0xa90, 12); // Sony TV power code
delay(50);
Serial.println("off");
}
}
if (c == '3'){
for (int i=0; i<3; i++){
irsend.sendSony(0x490, 12);
delay(50);
}
}
if (c == '4'){
for (int i=0; i<3; i++){
irsend.sendSony(0xC90, 12);
delay(50);
}
}
if (c == '5'){
for (int i=0; i<3; i++){
irsend.sendSony(0x290, 12);
delay(50);
}
}
if (c == '8')
irsend.sendRaw(eight, 35, 36);
if (c == '7')
irsend.sendRaw(seven, 35, 36);
if (c == '6')
irsend.sendRaw(six, 35, 36);
if (c == '9')
irsend.sendRaw(nine, 35, 36);
if (c == 'A'){
irsend.sendRaw(five, 35, 36);
Serial.print("five");
}
if (c == 'B')
irsend.sendRaw(four, 35, 36);
if (c == 'C')
irsend.sendRaw(three, 35, 36);
if (c == 'D')
irsend.sendRaw(two, 35, 36);
if (c == 'E')
irsend.sendRaw(one, 35, 36);
if (c == 'F')
irsend.sendRaw(zero, 35, 36);
if (c == 'G')
irsend.sendRaw(select, 35, 36);
if (c == 'H')
irsend.sendRaw(pause, 35, 36);
if (c == 'I')
irsend.sendRaw(play, 35, 36);
if (c == 'J')
irsend.sendRaw(ff, 35, 36);
if (c == 'K')
irsend.sendRaw(rew, 35, 36);
if (c == 'L')
irsend.sendRaw(stopbtn, 35, 36);
if (c == 'M')
irsend.sendRaw(rec, 35, 36);
if (c == '1')
{
Serial.print(c);
irsend.sendRaw(guide, 35, 36);
}
if (c == 'a')
{
Serial.println(c);
for (int i= 0; i<35; i++)
{
Serial.println(info[i]);
}
irsend.sendRaw(info,35, 36);
}
if (c == 'b')
irsend.sendRaw(chup, 35, 36);
if (c == 'c')
irsend.sendRaw(chdown, 35, 36);
if (c == 'd')
irsend.sendRaw(last, 35, 36);
if (c == 'e')
irsend.sendRaw(see, 35, 36);
if (c == 'f')
irsend.sendRaw(b, 35, 36);
if (c == 'g')
irsend.sendRaw(a, 35, 36);
if (c == 'h')
irsend.sendRaw(live, 35, 36);
if (c == 'i')
irsend.sendRaw(demand, 35, 36);
if (c == 'j')
irsend.sendRaw(left, 35, 36);
if (c == 'k')
irsend.sendRaw(right, 35, 36);
if (c == 'l')
irsend.sendRaw(up, 35, 36);
if (c == 'm')
irsend.sendRaw(down, 35, 36);
if (c == 'n')
irsend.sendRaw(pageup, 35, 36);
if (c == 'o')
irsend.sendRaw(pagedown, 35, 36);
if (c == 'p')
{
Serial.println(c);
for (int i= 0; i<35; i++)
{
Serial.println(exitbtn[i]);
}
irsend.sendRaw(exitbtn, 35, 36);
}
if (c == 'q')
{
Serial.println(c);
for (int i= 0; i<35; i++)
{
Serial.println(dvr[i]);
}
irsend.sendRaw(dvr, 35, 36);
}
}