Skip to main content

Vibration Motor

Digital
output
Small RAM
0.1.1

#Description

Vibration Motors simply vibrate, like the silent ringtone in a phone. They are great to give users a haptic feedback.

Have a look also at Vibration Motor (Dimmable). It has more features than the Vibration Motor but needs to be connected to a pwm pin.

#Units

  • Percent%

#Functions



#JavaScript / Node.js

Base class for digital output components (on/off control, blink, toggle).

#Constructor options

OptionTypeRequiredDescription
invertbooleanoptional
pinnumber | DigitalPinrequired

#Methods

on()this

Turn the component on (no arguments) or register an event listener.

off()this

Turn the component off

toggle()this

Toggle the component state

set(value: 0 | 1)this

Set the value of the component

blink(interval: number = 500)this

Blink the component at a given interval (Arduino-side animation)

stop()this

Stop any running animation (blink, pulse)

get isOnboolean

Check if the component is currently on

get isAnimatingboolean

Check if an animation is running

get valuenumber | undefinedfrom ComponentBase

Get the current value of the component.

#Example

JavaScript
import { Board, DigitalActor } from "@blokdots/components";

const board = new Board("/dev/ttyACM0");
await board.open();

const digitalActor = new DigitalActor({ board, pin: "D5" });

digitalActor.on();
digitalActor.off();
digitalActor.toggle();

See the DigitalActor reference for the full API including all methods and events.



#C++ (Arduino)

#Setup

C++
#include "blokdots.h"

DigitalActor myComponent(5);

#Constructor

DigitalActor(pin, invert, startOn)
ParameterTypeDefault
pinuint8_trequired
invertboolfalse
startOnboolfalse
DigitalActor(bus, pin, evtChange, invert, startOn)

Constructor with EventBus for trigger support

ParameterTypeDefault
busEventBusrequired
pinuint8_trequired
evtChangeuint8_trequired
invertboolfalse
startOnboolfalse

#Methods

on()
off()
toggle()
emittedValue()int

Get the current state value (0 or 1) for triggers

stop()DigitalActor&

Stop any running animation (blink/pulse)

blink(intervalMs, durationMs)DigitalActor&

durationMs=0 => blink forever

ParameterTypeDefault
intervalMsuint16_t500
durationMsuint32_t0
blink(onMs, offMs, durationMs)DigitalActor&

durationMs=0 => blink forever

ParameterTypeDefault
onMsuint16_trequired
offMsuint16_trequired
durationMsuint32_t0
pulse(onForMs)DigitalActor&

One-shot pulse: ON for onForMs then OFF (no repeating)

ParameterTypeDefault
onForMsuint32_trequired

See the DigitalActor reference for the full API.