Commander-API  V2.1.0
Simple Command Parser
Loading...
Searching...
No Matches
Premade Commands

There are some premade commands already to make your development easier. Please read the documentation carefully, some commands are platform dependent.

Note
Please check Commander_simple_stream_pipe or Commander_Shellminator_Advanced_WebSocket_ESP32 example.

System Commands

reboot Command

  • Syntax: reboot
  • Arguments: none

This command reboots the device.

neofetch Command

  • Syntax: neofetch
  • Arguments: none

This command is inspired by the original neofetch bash script. It is a visually pleasing system information tool.

neofetch Output

Timing Commands

micros Command

  • Syntax: micros
  • Arguments: none

This command returns the number of microseconds passed since the program started.

millis Command

  • Syntax: millis
  • Arguments: none

This command returns the number of milliseconds passed since the program started.


Digital I/O Commands

pinMode Command

  • Syntax: pinMode
  • Arguments:
    • Pin Number
    • State
  • Example:
    • pinMode 2 1 -> Set pin 2 to output.
    • pinMode 3 0 -> Set pin 3 to input.

This command sets the direction of any pin on the microcontroller.

digitalWrite Command

  • Syntax: digitalWrite
  • Arguments:
    • Pin Number
    • State
  • Example:
    • digitalWrite 2 1 -> Set pin 2 output state to high.
    • digitalWrite 3 0 -> Set pin 3 output state to low.

This command sets the state of any output pin.

Note
To make it work, the specified pin has to be configured to be an output. Check pinMode comand.

digitalRead Command

  • Syntax: digitalRead
  • Arguments:
    • Pin Number
  • Example:
    • digitalRead 2 -> Read the state of pin 2.
    • digitalRead 3 -> Read the state of pin 3.

This command reads the state of any input or output pin.


Analog I/O Commands

analogRead Command

  • Syntax: analogRead
  • Arguments:
    • Pin Number
  • Example:
    • analogRead 0 -> Create an ADC measurement on analog pin 0
    • analogRead 5 -> Create an ADC measurement on analog pin 5

This command creates an ADC measurement on any ADC pin.

Note
On Arduino boards the ADC pins usually marked as A0, A1... etc. To select A0, you have to pass 0 as argument, to select A3, you have to pass 3 as argument and so on.

WiFi Specific Commands

Note
These commands are made for ESP8266 and ESP32. They do not work on any other platforms!

ipconfig Command

  • Syntax: ipconfig
  • Arguments: none

Displays current TCP/IP network configuration.

ipconfig Output

wifiStat Command

  • Syntax: wifiStat
  • Arguments: none

Displays WiFi mode, signal strength and MAC address.

wifiStat Output

wifiScan Command

  • Syntax: wifiScan
  • Arguments: none

Scans for the nearby WiFi networks and print them as a list.

wifiScan Output

Math Commands

sin Command

  • Syntax: sin
  • Arguments:
    • rad -> Input number in radians.
  • Example:
    • sin 0 -> Returns 0.000000
    • sin 1.570796 -> Returns 1.000000

Calculates the sine of an angle which is given in radians.

Note
The output precision is 6 digit after the decimal point.

cos Command

  • Syntax: cos
  • Arguments:
    • rad -> Input number in radians.
  • Example:
    • cos 0 -> Returns 1.000000
    • cos 1.570796 -> Returns 0.000000

Calculates the cosine of an angle which is given in radians.

Note
The output precision is 6 digit after the decimal point.

abs Command

  • Syntax: abs
  • Arguments:
    • num -> Input float umber.
  • Example:
    • abs 10.5 -> Returns 10.500000
    • abs -6.3 -> Returns 6.300000

Calculates the absolute value of an input number.

Note
The output precision is 6 digit after the decimal point.

random Command

  • Syntax: random
  • Arguments:
    • min -> Lower integer bound
    • max -> Upper integer bound
  • Example:
    • random 1 5 -> Returns a random integer between 1 and 5( 5 is the upper limit, so actually 4 will be the largest number )

Generates a random number between the given bounds.

not Command

  • Syntax: not
  • Arguments:
    • state -> Input logical state
  • Example:
    • not 0 -> Returns 1
    • not 1 -> Returns 0
    • not 2 -> Returns 0

Generates a logical NOT from the input. It follows the C-like true-false logic, so 0 is false, everything else is true.