Turn On a DC motor from IoT cloud and a buttom with MKR WiFi

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() {
  buttons.addPin(BUTTON_PIN, LOW);

  // Defined in thingProperties.h
  // Connect to Arduino IoT Cloud

void loop() {

void onPinActivated(int pinNr) {
  // do something according to the _pinNR that is triggered. For instance:
  toggle = !toggle;

void onPinDeactivated(int pinNr) {
  // do something according to the _pinNR that is triggered. For instance:
void onMotorChange() {
  digitalWrite(MOTOR_PIN, toggle || motor);
  Serial.print("The motor is ");
  if (toggle|| motor==HIGH) {

and here is an example of my wiring (I don't have a MKR in the software)

I have alredy 2 month with this project, help me please

`Serial.println("The motor is"); 
// is better ```

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....

Ok, here some photos of real wiring, the part with dispenser screw is the DC motor

Thanks for the arts but please post a real wiring diagram.
Maybe a police detective investigating a murder would find something useful. I don't.

Sis @karenbaedo, try to post the schematic diagram of you project.

Not like this

OK, I hope this can be helpfull :pleading_face:

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

And your code seem to have some errors !

That's the reason why I'm here, I need advices and solutions, I did the change you told me before, but is not a big deal

`Serial.println("The motor is");

What more changes I have to do? I've tried so much things and nothing seem work, heeeeelp :face_with_head_bandage:

This topic was automatically closed 120 days after the last reply. New replies are no longer allowed.