Dear Friends,
I am facing specific problem with the Atmega328P, I am trying to run 2HP Water Pump with Atmega328P + 40 AM single channel Relay. The controller starts the relay, but when it stops the relay the processor gets into hung stage. I am powering Atmega329P and relay with 2 separate inputs.
Kindly suggest
Code:
int MotorCtrlPin1 = 9; // Borewell Motor
int MotorCtrlPin1S = 11; // Borewell Motor Starter
// Function to reset the device
void(* resetFunc) (void) = 0; //declare reset function @ address 0
void setup() {
// put your setup code here, to run once:
Serial.begin(9600);
delay(50);
Serial.println("");
Serial.println("Iniatilizing.....");
pinMode(LED_BUILTIN, OUTPUT);
pinMode(MotorCtrlPin1, OUTPUT);
pinMode(MotorCtrlPin1S, OUTPUT);
}
int testcycle =1;
void loop() {
Serial.println(testcycle);
digitalWrite(LED_BUILTIN, HIGH);
delay(10000);
if (testcycle < 2)
{
// Stop Button
digitalWrite(MotorCtrlPin1, HIGH);
delay(500);
digitalWrite(MotorCtrlPin1, LOW);
delay(500);
// Start Button
digitalWrite(MotorCtrlPin1S, HIGH);
delay(2000);
digitalWrite(MotorCtrlPin1S, LOW);
delay(500);
// Stop Button
digitalWrite(MotorCtrlPin1, HIGH);
delay(3000);
digitalWrite(MotorCtrlPin1, LOW);
delay(500);
resetFunc();
}
testcycle=5;
delay(1000);
digitalWrite(LED_BUILTIN, LOW);
delay(1000);
}
Below is my schematic and code:
I am facing specific problem with the Atmega328P, I am trying to run 2HP Water Pump with Atmega328P + 40 AM single channel Relay. The controller starts the relay, but when it stops the relay the processor gets into hung stage. I am powering Atmega329P and relay with 2 separate inputs.
Kindly suggest
Code:
int MotorCtrlPin1 = 9; // Borewell Motor
int MotorCtrlPin1S = 11; // Borewell Motor Starter
// Function to reset the device
void(* resetFunc) (void) = 0; //declare reset function @ address 0
void setup() {
// put your setup code here, to run once:
Serial.begin(9600);
delay(50);
Serial.println("");
Serial.println("Iniatilizing.....");
pinMode(LED_BUILTIN, OUTPUT);
pinMode(MotorCtrlPin1, OUTPUT);
pinMode(MotorCtrlPin1S, OUTPUT);
}
int testcycle =1;
void loop() {
Serial.println(testcycle);
digitalWrite(LED_BUILTIN, HIGH);
delay(10000);
if (testcycle < 2)
{
// Stop Button
digitalWrite(MotorCtrlPin1, HIGH);
delay(500);
digitalWrite(MotorCtrlPin1, LOW);
delay(500);
// Start Button
digitalWrite(MotorCtrlPin1S, HIGH);
delay(2000);
digitalWrite(MotorCtrlPin1S, LOW);
delay(500);
// Stop Button
digitalWrite(MotorCtrlPin1, HIGH);
delay(3000);
digitalWrite(MotorCtrlPin1, LOW);
delay(500);
resetFunc();
}
testcycle=5;
delay(1000);
digitalWrite(LED_BUILTIN, LOW);
delay(1000);
}
Below is my schematic and code: