Hello,
I am currenlty making a DIY remote control hovercraft. I am using the PS4 library to control the thrust fan and a servo motor for the rudder. The thrust fan is connected using a H-Bridge so the hovercraft can have reverse. Now I am at the point where I would like to connect my lift fan motors to my arduino and be able to turn it off and on using a MOSFET. The PS4 library has been quite straight forward to use but for some reason I can not figure out how to control my MOSFET with the click of a button. For example to control the direction of the thrust fan my code is: NOTE: [boolean thrust = true;]
if(PS4.getButtonClick(DOWN)){
if(fanDirection){
digitalWrite(in1,LOW);
digitalWrite(in2,HIGH);
fanDirection = !fanDirection;
delay(10);
}else if(!fanDirection){
digitalWrite(in1,HIGH);
digitalWrite(in2,LOW);
fanDirection = !fanDirection;
delay(10);
}
Now using a similar idea I thought I would be able to control the MOSFET but it does not seem to work. The first set of code I tried is: NOTE: [boolean lift = true; | int mos = 9;]
if(PS4.getButtonClick(UP)){
if(lift){
digitalWrite(mos,LOW);
}
else{
digitalWrite(mos,HIGH);
}
lift = !lift;
}
Unfortunatly I had no luck with this code so I though maybe I was over simplifying the problem. Therefore, I wrote this segment in hopes of an output:
if(PS4.getButtonClick(UP)){ // to start fan motor (but sadly would not even start)
digitalWrite(mos,HIGH);
}
So all in all I am wondering if any of you guys have any ideas on what I can do to be able to use the MOSFET as a virtual switch. Thanks for all the help!
PS. The circuit I am using works properly as I have tested it manually. It just doesn't seem to move once I try and use the controller as input.