Hey guys, this is my first post, so be gentle :o
As of right now i cant paste my code; but anyway I have a simple Arduino UNO setup, with an IR Sensor (came with kit) and a RS232 shield attached.
My loop code basically listens for IR hex codes; and has several "case" arguments for sending a different ASCII string for each of the different IR codes from my remote.
It WORKS, BUT;
- Just as i have uploaded my code to the Arduino, the LED's indicate that every single command is recieved, and the TX led of my RS232 board signals sending. All perfect.
But when i just power my arduino with a USB A-B cable and a wall outlet, it only seems to listen to IR/ send these commands every now and then.
Could someone please write me an example code that should work? (Ex ACSII string that i send is "[DEVIALET>POWER=1]")
Bless, and best wishes from Norway.
I will post my code later today 
Hi,
What RS232 shield?
Can you post links to specs/data.
Without code or circuit we cannot really offer any solutions.
Tom... 
kristianskauge:
But when i just power my arduino with a USB A-B cable and a wall outlet, it only seems to listen to IR/ send these commands every now and then.
Smells like you forgot a Gnd connection somewhere.
Here is the Code im using.
Im not good at this at all.. so. Can anyone spot anything that will cause this to work only sporadically?
Thanks!
*/
// Include IR Remote Library by Ken Shirriff
#include <IRremote.h>
#include <SoftwareSerial.h>
// Define myserial RX & TX
// SoftwareSerial mySerial(10, 11); // RX, TX
// Define TX pin
const int tx = 1;
// Define RX pin
const int rx = 0;
// Define sensor pin
const int RECV_PIN = 4;
// Define LED pin constants
const int redPin = 8;
// Define integer to remember toggle state
int togglestate = 0;
// Define IR Receiver and Results Objects
IRrecv irrecv(RECV_PIN);
decode_results results;
// Lagrer forrige IR-kode mottatt
// unsigned long lastCode;
void setup(){
// Enable the IR Receiver
irrecv.enableIRIn();
// Set LED pins as Outputs
// pinMode(redPin, OUTPUT);
//start the serial communication
Serial.begin(115200);
// mySerial.begin(115200);
}
void loop(){
if (irrecv.decode(&results)){
// if(results.value == 0xFFFFFFFF) // if repeat command (button held down)
// {
// results.value = lastCode; // replace FFFF with last good code
// }
switch(results.value){
case 0xFD00FF: //POWER KNAPP
// lastCode = results.value; // registrer koden for gjentakelse
// mySerial.print("[DEVIALET>POWER=1]");
Serial.println("[DEVIALET>POWER=1]");
break;
case 0xFD40BF: //FUNC/STOP KNAPP
// lastCode = results.value; // registrer koden for gjentakelse
// mySerial.print("[DEVIALET>POWER=0]");
Serial.println("[DEVIALET>POWER=0]");
break;
case 0xFD807F: //VOL+ KNAPP
// lastCode = results.value; // registrer koden for gjentakelse
// mySerial.print("[DEVIALET>VOLUME=++]");
Serial.println("[DEVIALET>VOLUME=++]");
break;
case 0xFD906F: //VOL- KNAPP
// lastCode = results.value; // registrer koden for gjentakelse
// mySerial.print("[DEVIALET>VOLUME=--]");
Serial.println("[DEVIALET>VOLUME=--]");
break;
case 0xFD20DF: //PREV-KNAPP
// lastCode = results.value; // registrer koden for gjentakelse
// mySerial.print("[DEVIALET>SOURCE=--]");
Serial.println("[DEVIALET>SOURCE=--]");
break;
case 0xFD609F: //NEXT-KNAPP
// lastCode = results.value; // registrer koden for gjentakelse
// mySerial.print("[DEVIALET>SOURCE=++]");
Serial.println("[DEVIALET>SOURCE=++]");
break;
case 0xFDA05F: //PLAY/PAUSE
// lastCode = results.value; // registrer koden for gjentakelse
// mySerial.print("[DEVIALET>MUTE=!]");
Serial.println("[DEVIALET>MUTE=!]");
delay(200);
break;
case 0xFD30CF: //0-knapp
// lastCode = results.value; // registrer koden for gjentakelse
// mySerial.print("[DEVIALET>SOURCE=USB]");
Serial.println("[DEVIALET>SOURCE=USB]");
break;
case 0xFD08F7: //1-knapp
// lastCode = results.value; // registrer koden for gjentakelse
// mySerial.print("[DEVIALET>SOURCE=Optical1]");
Serial.println("[DEVIALET>SOURCE=Opt 1]");
delay(200);
Serial.println("[DEVIALET>SOURCE=Optical1]");
break;
case 0xFD8877: //2-knapp
// lastCode = results.value; // registrer koden for gjentakelse
// mySerial.print("[DEVIALET>SOURCE=Opt 2]");
Serial.println("[DEVIALET>SOURCE=Optical 2]");
break;
case 0xFD48B7: //3-knapp
// lastCode = results.value; // registrer koden for gjentakelse
// mySerial.print("[DEVIALET>SOURCE=Line 1]");
Serial.println("[DEVIALET>SOURCE=Line 1]");
break;
case 0xFD28D7: //4-knapp
// lastCode = results.value; // registrer koden for gjentakelse
// mySerial.print("[DEVIALET>SOURCE=Line 2]");
Serial.println("[DEVIALET>SOURCE=Line 2]");
break;
case 0xFD50AF: //OPP-knapp
// lastCode = results.value; // registrer koden for gjentakelse
// mySerial.print("[DEVIALET>SAM=1]");
Serial.println("[DEVIALET>SAM=1]");
break;
case 0xFD10EF: //NED-knapp
// lastCode = results.value; // registrer koden for gjentakelse
// Turn on LED for 20Ms
// digitalWrite(redPin, LOW);
// delay(200);
// digitalWrite(redPin, HIGH);
// mySerial.print("[DEVIALET>SAM=0]");
Serial.println("[DEVIALET>SAM=0]");
break;
}
irrecv.resume();
}
}
1 Like
DrDiettrich:
Smells like you forgot a Gnd connection somewhere.
Hmm..
Im pretty sure both the IR reciever and the TX/RX/GND part of the RS232 board is connected properly. Would it work otherwise?..
Kriss
Hi,
Please read the first post in any forum entitled how to use this forum.
http://forum.arduino.cc/index.php/topic,148850.0.html then look down to item #7 about how to post your code.
It will be formatted in a scrolling window that makes it easier to read.
Can you please post a copy of your circuit, in CAD or a picture of a hand drawn circuit in jpg, png?
Thanks.. Tom... 
I only can see Serial.print() in your code. So is the RS232 board connected to RX/TX? And also to Gnd?
What if you reduce the baudrate, to make the LED blink longer on a transmission?
TomGeorge:
Hi,
Please read the first post in any forum entitled how to use this forum.
http://forum.arduino.cc/index.php/topic,148850.0.html then look down to item #7 about how to post your code.
It will be formatted in a scrolling window that makes it easier to read.
Can you please post a copy of your circuit, in CAD or a picture of a hand drawn circuit in jpg, png?
Thanks.. Tom... 
Thanks. Fixed the code entry in my post now 
Here are some pictures of my setup. I connect RX - TX - and GND Pins to the product Im controlling
DrDiettrich:
I only can see Serial.print() in your code. So is the RS232 board connected to RX/TX? And also to Gnd?
What if you reduce the baudrate, to make the LED blink longer on a transmission?
RS232 Board connect to default rx-tx pins, yes, and ground i presume. I can try to lower the baudrate. However the product im controlling has baud-rate selection, and is set to the same as in the code
PS: My RS232 board has a switch for enabling/disabling the board, to not stop uploading the code to the Arduino UNO
I suggested the reduced baud rate only for visual inspection of the LED.
What happens if you disconnect the external device, and only switch the power source?
DrDiettrich:
I suggested the reduced baud rate only for visual inspection of the LED.
What happens if you disconnect the external device, and only switch the power source?
You mean powering it with my powersource, but not connecting the TX-RX-GND to the end product?
Thanks for helping
<3
Hi,
This is possibly the schematic of your shield.
Tom.. 
TomGeorge:
Hi,
This is possibly the schematic of your shield.
Tom.. 
Thanks! (As if I'm good at reading these schematics :D)
Could my trouble be GND related, in as some error in not having common ground between the powersource/Arduino/IR Reciever/End product that i control w 232?
I really have no clue what to do to fix this. It's what i got the Arduino for