Hi, I need help with this project, I'm using an Arduino MKR WiFi 1010 to run and turn off a DC motor but my code or my wiring is wrong (?) 'cause it doesn't work at all, it just functioned once and no more... I tried with a led and it works succesfully but no with the motor.
Here is my code
#include "thingProperties.h"
#include <FTDebouncer.h>
#define MOTOR_PIN 5
#define BUTTON_PIN 2
FTDebouncer buttons;
void setup() {
pinMode(MOTOR_PIN, OUTPUT);
buttons.addPin(BUTTON_PIN, LOW);
buttons.init();
setDebugMessageLevel(2);
Serial.begin(9600);
delay(1500);
// Defined in thingProperties.h
initProperties();
// Connect to Arduino IoT Cloud
ArduinoCloud.begin(ArduinoIoTPreferredConnection);
}
void loop() {
buttons.update();
ArduinoCloud.update();
onMotorChange();
}
void onPinActivated(int pinNr) {
// do something according to the _pinNR that is triggered. For instance:
Serial.println(pinNr);
toggle = !toggle;
}
void onPinDeactivated(int pinNr) {
// do something according to the _pinNR that is triggered. For instance:
Serial.println(pinNr);
}
void onMotorChange() {
digitalWrite(MOTOR_PIN, toggle || motor);
Serial.print("The motor is ");
if (toggle|| motor==HIGH) {
Serial.println("ON");
digitalWrite(MOTOR_PIN,HIGH);
}
else{
Serial.println("OFF");
digitalWrite(MOTOR_PIN,LOW);
}
}
and here is an example of my wiring (I don't have a MKR in the software)
Please post a real wiring diagram. Lots of infirmation lost in Fritzing.
Show the powering of all. Running motor power through a btead board is no, no and tapping that power from the controller is also no, no.
There's no power to the controller....
You said to run a DC motor with a wifi module but there is no wifi module , in the schematic you posted
Is the Switch connected to the wifi module (MKR WIFI 1010) ?
As per schema you [posted there is no need of the wifi module cause you can directly turn off and on the motor with the switch itself
But this seem much similar to what you required
I saw your schema, is a H bridge? I can't recognize it; I tried with a mosfet and a diode before, but the only thing I get was my Arduino get destroyed (without H bridge and 9V, newbie)
No i didn't use a H bridge in my schema cause i did find a separate motor driver in that software , You can carry on with the L298N it will be better .
I was curious where will the wifi module be connected to monitor the Motor
Any way all the best for what you are doing