Hey there!
I've been trying to create a code for a project, but i have an extremely big issue. My project requires to control an AC motor, i need to use 2 sensors and a starting button. When I try the code alone it seems to work but as soon as i connec the Variable frequency drive thar i need to use it stops working, I am using a relay module in order t ocontrol the Variable frequency drive. Does anyone have an idea of what is going on? this is the code i am using:
int BUTTON_PIN1=8;
int BUTTON_PIN2=9;
int BUTTON_PIN3=10;
int buttonState1=0;
int buttonState2=0;
int buttonState3=0;
const int Forward = 2;
const int Backward = 5;
int counter=0;
int start=0;
void setup() {
pinMode(BUTTON_PIN1, INPUT);
pinMode(BUTTON_PIN2, INPUT);
pinMode(BUTTON_PIN3, INPUT);
Serial.begin(9600);
pinMode(Forward , OUTPUT);
pinMode(Backward , OUTPUT);
}
void loop() {
buttonState1=digitalRead(BUTTON_PIN1);
buttonState2=digitalRead(BUTTON_PIN2);
buttonState3=digitalRead(BUTTON_PIN3);
if (buttonState3==1)
{
(start=1);
delay(50);
}
if (buttonState1==1)
{
if (start==1)
{
(counter=1);
delay(50);
}
if (counter==0)
{
digitalWrite(Backward , HIGH);
delay(50);
digitalWrite(Forward , HIGH);
delay(50);
}
}
if (counter==1)
{
digitalWrite(Forward , LOW);
delay(50);
digitalWrite(Backward , HIGH);
delay(50);
if (buttonState2==1)
{
(counter=2);
delay(5);
(start=0);
delay(50);
}
}
if (counter==2)
{
digitalWrite(Backward , LOW);
delay(5);
digitalWrite(Forward , HIGH);
delay(5);
}
if (buttonState1==1);
(counter=0);
Serial.println(counter);
}