Thank you for reading my post. I have been stuck on this for several weeks now! I am trying to turn ON/OFF a DC motor from Arduino IOT Cloud. I have set up the cloud and added the switch. Everything works well with an LED: it lights on and off as needed, but the motor does not turn on or off. Below is the circuit I have set up.
My circuit specs are as follows:
- I'm not using a UNO as the image illustrates, rather I'm using an Arduino MKR WiFi 1010, but the connections of the pins are exactly the same: LED at PIN 3 and Motor at 7.
- The diode I am using is 1N4001.
- The transistor I'm using is TIP120.
- The motor I'm using is 5V DC Motor.
- 270 Ohm resistor on the transistor circuit and 220 Ohm on the LED circuit.
The Arduino code I made is as follows:
#include "thingProperties.h"
#define LED_PIN 3
#define MOTOR_PIN 7
void setup() {
pinMode(LED_PIN, OUTPUT);
pinMode(MOTOR_PIN, OUTPUT);
setDebugMessageLevel(2); // For debugging of cloud integration
Serial.begin(9600);
delay(1500);
initProperties(); // initialize cloud properties
ArduinoCloud.begin(ArduinoIoTPreferredConnection); // Connect to cloud
}
void loop() {
ArduinoCloud.update(); // Update cloud background services
}
void onMotorChange() {
if (motor) {
// Motor & LED ON
digitalWrite(LED_PIN, HIGH);
digitalWrite(MOTOR_PIN, HIGH);
} else {
// Motor & LED OFF
digitalWrite(LED_PIN, LOW);
digitalWrite(MOTOR_PIN, LOW);
}
}
All my setup seems to be be correct, but it just is not working. I have researched a lot but to no avail. I have tested with a different motor just to be sure, but it also does not work. I'm not sure where I have made a mistake.
Please help me. Thank you very much.

