NodeMCU Issue


Wonder if anyone can help with this as an apparently simple task is driving me mad!

I’m trying to control a Cytron MDDS60 24v motor driver from a Blynk joystick using a NodeMCU, but just cannot get it working.

I have confirmed that the hardware is all good by running the following test sketch on the NodeMCU:

 * This example shows how to control MDDS60 in PWM mode with Arduino.

 * Set MDDS60 input mode to 0b10110100


 * Reference Tutorial:

 * - Let's Arduino Controlling Your SmartDriveDuo-60


 * - SmartDriveDuo-60: 


 * URL:


int DIG1 = 0; // Arduino pin 3 is connected to MDDS60 pin DIG1.

int AN1 = 12; // Arduino pin 6 is connected to MDDS60 pin AN1.

void setup()


  pinMode(DIG1, OUTPUT); // Set Arduino pin 7 (DIG1) as output.

  pinMode(AN1, OUTPUT); // Set Arduino pin 6 (AN1) as output.

  delay(5000); // Delay for 5 seconds.


void loop()


  // Controlling motor 1.

  analogWrite(AN1, 100); // Set motor 1 speed less than half. Max is 255.

  digitalWrite(DIG1, LOW); // Motor 1 start moving for 2s.


  digitalWrite(DIG1, HIGH); // Motor 1 move to another direction for 2s.


  analogWrite(AN1, 0); // Stop motor 1.

  delay(1000); // Delay for 1s

  // Controlling motor 2.


This works, the motor moves forward and backwards, pausing between movements.

However, when I upload the following sketch, nothing happens. Working with a joystick widget on pin V1, I can see output in Serial Monitor so the app is working, the pins are connected correctly as the previous sketch proves, but the motor simply will not move.

#include <ESP8266WiFi.h> 
#include <BlynkSimpleEsp8266.h> 

char auth[] = "Auth Key"; 
// Your WiFi credentials. 
// Set password to "" for open networks. 
char ssid[] = "MY_SSID"; 
char pass[] = "Network Password"; 
int DIG1 = 0; 
int AN1 = 12; 
  int y = param[1].asInt(); 
  if ( y > 700 ){ 
    analogWrite(AN1, 200); 
    digitalWrite(DIG1, LOW); 
  else if ( y < 500 ) { 
    analogWrite(AN1, 200); 
    digitalWrite(DIG1, HIGH); 
  else { 
    analogWrite(AN1, 200); 
void setup() { 
pinMode(DIG1, OUTPUT); 
pinMode(AN1, OUTPUT); 
Blynk.begin(auth, ssid, pass); 
void loop() { 
  // put your main code here, to run repeatedly:; 

@redrabbit please edit your post, using the pencil icon at the bottom, and add triple backticks at the beginning and end of your code so that it displays correctly.
Triple backticks look like this:



Thanks for that, I did wonder why the inverts I used didn’t work, hadn’t spotted that it has to be triple back ticks.

How is your joystick widget set-up in the app?

Have you tried adding some serial print statements to your code to work out where your code is going with your if/else statements and what values you’re getting from the joystick?


Sorry for the delay, been trying to understand this.

Yes I have added serial monitoring and I can see valid values being returned when I move the joystick. Joystick is set to:

V1 [0]0-1024
V1 [1]0-1024

Which I believe is correct?

I’ve been testing pin output with a multimetre and have noticed that D6 is the only pin putting out any readable voltage (as per the sketch), but it just sits at a stead 3.25V and doesn’t shift in either direction when the joystick is moved.

This is driving me nuts! Any tips most gratefully received. :slight_smile:

Two things here…

  1. all of your ‘if’ statements result in a PWM value of 200 being written to pin D6, regardless of what is coming out of the joystick, so I wouldn’t expect any other result.

  2. it depends on how good your multimeter is, and how you are using it. A high frequency PWM signal is in effect an AC signal, fluctuating between LOW and HIGH at the specified duty cycle (200 out of a possible 1023 in the case of your code).
    An oscilloscope is the only reliable way to measure the PWM output.



Thanks for replying again. Unfortunately I am not a developer with much in the way of C skills, so perhaps this is going to prove beyond me right now, but…

  1. Are you referring to AnalogueWrite values? These are the defaults in the Blynk sketch; if they are wrong, do you have any idea what they should be?

  2. I don’t own an oscilloscope, I am relatively new to all of this and only have basic kit.

As little as I know, I can’t help but shake the idea that this should be a trivial task: I simply want to manually control a 24V motor forwards and backwards. I can get Adruino test sketches to run a basic FWD / REV test on the NodeMCU, but cannot find any way of getting this manual control working.

Long shot, but I don’t suppose you know of a better / standard sketch for this? Surely one much exist for such a basic task? Obviously I am now away to google exactly this, but maybe you know off the top of your head?

Edit: Sorry, that sounded cheeky, I am not asking you to write my code, I’m just stuck here banging my head against this and getting nowhere.

Oh dear, I may be about to embarrass myself.

This setup is simple: NodeMCU =>Driver
Four pins: AN1, DG1, V+, GND

OK, so when it comes to modifying a sketch and uploading, it was a pain unplugging the power cables from the driver and connecting the USB to laptop, upload, and then unplug from laptop and reconnect to driver. I had been told to just leave the USB plugged in and not use the driver power.

However, when I was just running a test sketch, it worked when drawing power from the driver, but didn’t work when connected to USB.

Have I been overlooking something really simple here?

Yes. Even though you say you’re not a developer, can’t you see that no matter what value you feed into your ‘if - else’ statement, the effect as far as the AN1 pin is you write a value of 200 to it?

Which sketch is this?

I would expect the value written to AN1 to be either the value that comes from the joystick (‘y’ in your code), or that value adjusted in some way to meet the input requirements of your controller.
Otherwise, the joystick isn’t actually doing anything.

Neither do I, I’m simply pointing out that using a multimeter may not tell you anything constructive. Obviously, until you change your code so that moving your joystick sends a value other than 200 to the digital pin then you won’t be able to check this anyway.



Thank you so much for your time, I’ve learned a bit from this.

The problem was that I was powering the MCU via USB, when I drew the power directly from the driver, Blynk worked immediately. It’s giving me one small problem in that, when the pointer returns to the centre, the motor doesn’t stop, but I will work that out.

Really appreciate your input though, thanks again.

1 Like