some times freezing, need help to fix

hi friends find the attachment for ir remote controller program to control home appliances using relay ,

some times got no response (freeze) if i press remote button, after reset it will come normal again

i have few doubt

  1. atmega328 to uln2803 b/w need pullup or pulldown or nothing ?

  2. 0.1mfd connected to Aref pin and gnd ?

  3. TSOP1738 signal(3rd pin) pin pullup need to connect or not ?(i tried with pull-up, less receiving angle if i connect )

please help

#include “IRremote.h”

/-----( Declare Constants )-----/
int receiver = 11; // pin 3 of IR receiver to Arduino digital pin 11

/-----( Declare objects )-----/
IRrecv irrecv(receiver); // create instance of ‘irrecv’
decode_results results; // create instance of ‘decode_results’
/-----( Declare Variables )-----/
int Relay1 = 9; // relay one connect to pin 9
int Relay2 = 8; // relay two connect to pin 8
int Relay3 = 2; // relay three connect to pin 2
int Relay4 = 3; // relay four connect to pin 3
int Relay5 = 4; // relay one connect to pin 4
int Relay6 = 5; // relay two connect to pin 5
int Relay7 = 6; // relay one connect to pin 6
int Relay8 = 7; // relay two connect to pin 7
int cpuled = 13; // CPU Monitoring

void setup() /----( SETUP: RUNS ONCE )----/

// initialize the Relay1 pin as an output:
pinMode(Relay1, OUTPUT);
// initialize the Relay2 pin as an output:
pinMode(Relay2, OUTPUT);
// initialize the Relay3 pin as an output:
pinMode(Relay3, OUTPUT);
// initialize the Relay4 pin as an output:
pinMode(Relay4, OUTPUT);
// initialize the Relay5 pin as an output:
pinMode(Relay5, OUTPUT);
// initialize the Relay6 pin as an output:
pinMode(Relay6, OUTPUT);
// initialize the Relay7 pin as an output:
pinMode(Relay7, OUTPUT);
// initialize the Relay8 pin as an output:
pinMode(Relay8, OUTPUT);
// initialize the CPU pin as an output:
pinMode(cpuled, OUTPUT);
irrecv.enableIRIn(); // Start the receiver
}/–(end setup )—/

int on1= 0;
int on2= 0;
int on3= 0;
int on4= 0;
int on5= 0;
int on6= 0;
int on7= 0;
int on8= 0;

void loop() /----( LOOP: RUNS CONSTANTLY )----/
if (irrecv.decode(&results)) // have we received an IR signal?
irrecv.resume(); // receive the next value
digitalWrite(cpuled, HIGH); // turn the LED on (HIGH is the voltage level)
delay(50); // wait for a second
digitalWrite(cpuled, LOW); // turn the LED off by making the voltage LOW
delay(50); // wait for a second
}/* --(end main loop )-- */

/-----( Declare User-written Functions )-----/
void translateIR() // takes action based on IR code received

// describing TV remote controller IR codes




case 0x584F00FF:
on1 = !on1;
digitalWrite(Relay1, on1 ? HIGH : LOW);

case 0x584F807F:
on2 = !on2;
digitalWrite(Relay2, on2 ? HIGH : LOW);

case 0x584F40BF:
on3 = !on3;
digitalWrite(Relay3, on3 ? HIGH : LOW);

case 0x584FC03F:
on4= !on4;
digitalWrite(Relay4, on4 ? HIGH : LOW);

case 0x584F20DF:
on5= !on5;
digitalWrite(Relay5, on5 ? HIGH : LOW);

case 0x584FA05F:
on6= !on6;
digitalWrite(Relay6, on6 ? HIGH : LOW);

case 0x584F609F:
on7= !on7;
digitalWrite(Relay7, on7 ? HIGH : LOW);

case 0x584FE01F:
on8= !on8;
digitalWrite(Relay8, on8 ? HIGH : LOW);



} //END translateIR

Arduino code.txt (3.4 KB)

  1. for hardware reset can i connect .1MFD to atmega pin 1 and ground ?

It gets wearisome having to constantly say this:-

You really should have read the How to use this forum - please read post at the top of the index page and How to use this forum before posting.

ie Your code and any error messages should always be placed between code tags. Posting it inline as you have done makes it much harder to read or copy and paste for diagnosis.

It's still not too late to edit your post and do this. You'll make potential helpers much happier. :slight_smile:

Your switch case has no default case by the looks of it.

If anything but the defined values are received, the program will freeze.

It's also a duplicate thread.