Step Widget Question

i searched and in the mire of all the stepper motor questions, this is as close as i got to an answer…

i have a log counter in my code, and trying to use the stepper, but it just adds logs, cant take them away?

is the step widget supposed to send a value as an int? so if you hit plus it sends 1 and if you hit minus it sends -1?

BLYNK_WRITE(V11)
{ // sml log stepper
  addSmlLog = param.asInt();
  if (addSmlLog > 0)
  {
    totalSmlLogs = (totalSmlLogs + 1);
    totalLogs = (totalLogs + 0.5);
    Blynk.virtualWrite(V12, totalSmlLogs);
    Blynk.virtualWrite(V20, totalLogs);  //
    logAdded = 1;
    startLogTime = millis();
    newLogTimer();
  }
  else if (addSmlLog < 0)
  {
    totalSmlLogs = (totalSmlLogs - 1);
    totalLogs = (totalLogs - 0.5);
    Blynk.virtualWrite(V12, totalSmlLogs);  //
    Blynk.virtualWrite(V20, totalLogs);  //
  }
}

widget =

what am i missing?

Wow, it has been a year already since that idea? … anyhow, I moved your question into a proper help topic.

:stuck_out_tongue: I can relate… I was finding the opposite when looking for Stepper Motor topics…

The Step Widget has two primary modes. This first with SEND STEP (OFF) is much like the slider or button, you set a range and move through that range… only you can now set the step of movement…

image

For example this setting (above) will give you a range of these numbers -200, -150, -100, -50, 0, 50, 100, 150, 200

However, by toggling SEND STEP (ON)…

image

…you should only get either a -50 or a 50, depending on the STEP you set and the direction you press, and thus can use it as a simple ‘directional’ or incremental/decremental control.

Unfortunately a bug that has remained since inception (despite being mentioned multiple times :frowning: )…

image

… is that the little value numbers, shown on the widget itself, still count the set ranges, thus it can get a bit confusing as to what the widget is actually outputting… the ranged steps or the simple -STEP/STEP steps.

Depends on the param.as???() that you use… param.asInt() will give you an integer of either the -+STEP or the STEPed value out of the MIN-MAX range you set, depending on that little toggle.

so why does it NOT work on one project? (using 5.1 lib)

but DOES works on another project? (using library between 4.0 and 4.8)

EDIT - opps, may have a virtual pin conflict… rewriting now…

no matter how i configure it in the app:

send step,don’t send step,

step is 1 step is 50,

all it sends on any press is 1

not negative 1 only positive 1.

so is it a bug? in 5.1 library??

but it WORKS on my other device?

Well, before blaming the library… test with some simpler code to compare expected results

BLYNK_WRITE(V55) {
Blynk.virtualWrite(V56, param.asInt());
}

image

image

image

image

Note that with above settings I get the expected result out of the three available options in a range of -1, 0, 1 (can’t forget the zero :wink: perhaps that is messing you up?)

PS, with SEND STEP (YES), you don’t need a -1 in your MIN range… the only variable that matters in this setting is the STEP value… so this would be more appropriate, but still totally unrelated to the results

image

seems to work,

but looking at these two bits:

BLYNK_WRITE(V37) {
  X = param.asInt();
  Blynk.virtualWrite(V38, X);
}

vs

BLYNK_WRITE(V55) {
Blynk.virtualWrite(V56, param.asInt());
}

why does your one work and the other not?

Assuming you have int x; in your pre-setup…

I tried and it works the same for me with this…

BLYNK_WRITE(V55) {
  int x = param.asInt();
  Blynk.virtualWrite(V56, x);
}

BTW, Running Android and Lib v0.5.1

i’m on local server 0.34.0-SNAPSHOT

heres the video: https://vimeo.com/262333278

the left is:

BLYNK_WRITE(V55)
{
  Blynk.virtualWrite(V56, param.asInt());
} 

the right is:

BLYNK_WRITE(V37)
{
  addBigLog = param.asInt();
  Blynk.virtualWrite(V38, addBigLog);
}

fkn addBigLog is a bool

i am sooo dumb!!:tired_face::tired_face::tired_face:

let us never speak of this again.

but for interest how would i insert addBigLog variable into here:

BLYNK_WRITE(V55)
{
  Blynk.virtualWrite(V56, param.asInt());
}

I am unsure what data you are trying to get from your Step widget… if you want a boolean response (0 or 1) then just use 0 and 1 for MIN MAX and set SEND STEP (OFF)

i want “up” or “down” or -1 or 1

it was two buttons widgets before, so there was one button for up and one button for down. so if one button was sent, it would decrease the value if the other button sent, it would increase, it did not have a sign.

but changing the two buttons to one step widget - i failed to check the variable type.

silly silly stuff! my bad.

1 Like