Acrome-SMD Docs
All Acrome ProductsReferencesBlogCase StudiesContact Us
  • ACROME SMD
  • Electronics
    • 🔴SMD Red
      • Troubleshooting Guide
    • 🔵SMD Blue
    • 🟢SMD Green
    • Gateway Modules
      • Arduino Gateway Module
      • USB Gateway Module
    • Electrical Motors
      • Brushed DC Motors (BDC)
      • Stepper DC Motors (SDC)
      • Brushless DC Motor (BLDC)
      • Linear Actuator with Feedback – 75 lbs
    • Add-on Modules
      • Ambient Light Sensor Module
      • Button Module
      • Buzzer Module
      • IMU Module
      • Joystick Module
      • Potentiometer Module
      • Reflectance Sensor Module
      • RGB LED Module
      • Servo Module
      • Ultrasonic Distance Sensor Module
  • SMD Kits
    • Starter Kit
      • Basic Brushed DC motor Applications
    • Education Kit
    • Motion Kit
      • Differential Robot Projects
  • Software
    • Libraries
      • Python Library
      • Arduino Library
      • Java Library
      • Matlab Library
    • SMD UI
    • SMD Blockly
      • Introducing Customized Blockly Blocks
  • SMD Applications
    • Basics
      • Blink
      • Action - Reaction
      • Autonomous Lighting
      • Smart Doorbell
      • Security System
      • Distance Buzzer Warning
      • Distance Auto Stop
      • Smart Light Control
    • Interactive
      • Automatic Trash Bin
      • Radar
      • Chrome Dino Game Player
      • Play Chrome Dino Game With Joystick
      • Snake Game With Joystick
      • Pan-Tilt with Joystick Module
      • Joystick Mouse Control
      • Rev Up the Engine
      • Motor Rotation Based on Turn Input Value
      • Basic Motor Speed Control Application
      • Basic Motor Control Application Using PWM Input
      • Basic Motor Position Control Application
      • Basic Motor Torque Control Application
      • Motor Rotation Based on Joystick Counting
    • Robotics
      • Mouse Cursor Tracker Motion Robot
      • Waypoint tracker robot
      • Braitenberg Robot
      • Line-Follower Robot
      • Object Tracking Robot
      • Teleoperation Robot
      • Obstacle Avoidance Robot
      • ESP32 Wireless Controlled Mobile Robot
  • AI
    • Groq Chatbot-Controlled Robot
  • Mechanics
    • Building Set
      • Plates
        • 2x2 Plate Package
        • 2x3 120° Plate Package
        • 3x3 Plate Package
        • 3x5 Plate Package
        • 3x9 Plate Package
        • 11x19 Plate
        • 9x19 Plate
        • 5x19 Plate
        • 3x19 Plate
        • 9x11 Plate
        • 5x13 Plate
      • Joints
        • 60° Joint Package
        • 90° Joint Package
        • 120° Joint Package
        • Slot Joint M2 Package
        • Slot Joint M3 Package
        • U Joint Package
      • Mounts
        • Add-on Mount Package
        • Motor L Mount Package
        • Pan-Tilt Package
      • Wheels
        • Ball Wheel Package
        • Caster Wheel Package
        • Wheel Package
      • Cables
        • Power Cable 10 cm Package
        • Power Cable 20 cm Package
        • Power Cable 35 cm Package
        • RJ-11 Cable 7.5 cm Package
        • RJ-11 Cable 20 cm Package
        • RJ-11 Cable 35 cm Package
        • RJ-45 Cable 7.5 cm Package
        • RJ-45 Cable 20 cm Package
        • RJ-45 Cable 35 cm Package
      • Fasteners
        • M2x5 Allen Hex Screw Package
        • M3x6 Allen Hex Screw Package
        • M3x8 Allen Hex Screw Package
        • M3 Hex Nut Package
  • Help
    • Manual
    • Shops
    • Reach Us
Powered by GitBook
On this page
  • Define Master Block
  • Smd Red Block
  • Set CPR Block
  • Set RPM Block
  • Define Motor Block
  • Set Control Parameters Block
  • Enable Torque Bloc
  • Set Operation Mode Block
  • Pwm Mode Blocks
  • Position Mode Blocks
  • Velocity Mode Blocks
  • Torque Mode Blocks
  • Get Joystick Block
  • RGB Led Block
  • Button Block
  • Ambient Light Sensor Block
  • Ultrasonic Distance Sensor Block
  • Buzzer Block
  • IMU Block
  • Potentiometer Block
  • Servo Blocks
  • QTR Block
  • Get Position Block
  1. Software
  2. SMD Blockly

Introducing Customized Blockly Blocks

PreviousSMD BlocklyNextBasics

Last updated 4 months ago

Define Master Block

This block enables the configuration of a USB gateway and its initialization with a user-selected baud rate. The baud rate can be conveniently chosen from a drop-down menu, ensuring flexibility and ease of use. The USB gateway serves as a critical communication bridge between the computer and the SMD Red system, facilitating seamless data exchange.

Smd Red Block

This block establishes a connection to an SMD Red device by utilizing a specified Red ID parameter. The user is required to provide a valid Red ID to ensure accurate identification and communication with the target device.

Above is the block structure for connecting to the smd red device with id value 0 and baudrate value 115200.

Set CPR Block

This block is used to configure the CPR (Counts Per Revolution) value for a motor identified by a specified Red ID. The user provides the desired CPR value, which determines the resolution of the motor's encoder, ensuring precise control and measurement.

Set RPM Block

This block is used to configure the RPM (Revolutions Per Minute) value for a motor identified by a specified Red ID. The user provides the desired RPM value, which controls the motor's rotational speed to meet application-specific requirements.

Define Motor Block

This block is used to initialize and start a motor using its default parameters. To activate the motor, the user must provide the Red ID, which identifies the specific motor to be started.

Set Control Parameters Block

This block allows you to configure the PID parameters dynamically for the specific mode you choose and the Red ID you input. By specifying the appropriate mode (Velocity, Position, Torque) and a unique Red ID, you can assign tailored values for the proportional (Kp), integral (Ki), and derivative (Kd) gains. The functionality ensures flexibility and precision for different control scenarios.

Enable Torque Bloc

This block is designed to initiate the torque of an motor dynamically using a specified Red ID. By entering the appropriate Red ID, the system ensures precise activation of the torque mechanism, tailored to the corresponding motor.

Set Operation Mode Block

This block allows the user to set the operating mode for a motor identified by a specified Red ID. The user can select from one of the following modes: PWM, Position, Speed, or Torque, depending on the desired control strategy for the motor.

Pwm Mode Blocks

These two blocks perform the same function, with the distinction that one accepts only numerical values, while the other accepts a joystick variable block as input. This flexibility allows users to choose the appropriate input method based on their specific application requirements.

Position Mode Blocks

These two blocks perform the same function, but with different methods of control: one rotates the motor directly to the specified position (in degrees), while the other uses a joystick input block to control the rotation.

Velocity Mode Blocks

These two blocks perform the same function, but with different methods of speed control: one rotates the motor at a constant speed based on a given value, while the other adjusts the speed dynamically using a joystick input.

Torque Mode Blocks

These two blocks perform the same function, but with different methods for controlling the motor's current: one rotates the motor based on a fixed milliampere value, while the other adjusts the milliampere value dynamically using a joystick input.

Red_id = None
Module_id = None
X = None
Y = None
B = None


from smd.red import *
import math
import os

from serial.tools.list_ports import comports
from platform import system
def USB_Port():
    if system() == 'Windows':
        ports = list(comports())
        if ports:
            for port, desc, hwid in sorted(ports):
                if 'USB Serial Port' in desc:
                    SMD_Port = port
                    return SMD_Port

    elif system() == 'Linux':
        ports = list(serial.tools.list_ports.comports())
        if ports:
            for port, desc, hwid in sorted(ports):
                if '/dev/ttyUSB' in port:
                    SMD_Port = port
                    return SMD_Port

    elif system() == 'Darwin':  # macOS
        ports = list(serial.tools.list_ports.comports())
        if ports:
            for port, desc, hwid in sorted(ports):
                if '/dev/tty.usbserial' in port or '/dev/tty.usbmodem' in port:
                    SMD_Port = port
                    return SMD_Port

    else:
        SMD_Port = None
        return SMD_Port

port=USB_Port()
m = Master(port,baudrate=115200)
Red_id = 0
m.attach(Red(Red_id))

Module_id = 1
while True:
  X, Y, B = m.get_joystick(Red_id, Module_id)
Red_id = None
Module_id = None


from smd.red import *
import math
import os

from serial.tools.list_ports import comports
from platform import system
def USB_Port():
    if system() == 'Windows':
        ports = list(comports())
        if ports:
            for port, desc, hwid in sorted(ports):
                if 'USB Serial Port' in desc:
                    SMD_Port = port
                    return SMD_Port

    elif system() == 'Linux':
        ports = list(serial.tools.list_ports.comports())
        if ports:
            for port, desc, hwid in sorted(ports):
                if '/dev/ttyUSB' in port:
                    SMD_Port = port
                    return SMD_Port

    elif system() == 'Darwin':  # macOS
        ports = list(serial.tools.list_ports.comports())
        if ports:
            for port, desc, hwid in sorted(ports):
                if '/dev/tty.usbserial' in port or '/dev/tty.usbmodem' in port:
                    SMD_Port = port
                    return SMD_Port

    else:
        SMD_Port = None
        return SMD_Port

port=USB_Port()
m = Master(port,baudrate=115200)
Red_id = 0
m.attach(Red(Red_id))

Module_id = 1
m.set_rgb(Red_id, Module_id, 255, 0, 0)
Red_id = None
Module_id = None
B = None


from smd.red import *
import math
import os

from serial.tools.list_ports import comports
from platform import system
def USB_Port():
    if system() == 'Windows':
        ports = list(comports())
        if ports:
            for port, desc, hwid in sorted(ports):
                if 'USB Serial Port' in desc:
                    SMD_Port = port
                    return SMD_Port

    elif system() == 'Linux':
        ports = list(serial.tools.list_ports.comports())
        if ports:
            for port, desc, hwid in sorted(ports):
                if '/dev/ttyUSB' in port:
                    SMD_Port = port
                    return SMD_Port

    elif system() == 'Darwin':  # macOS
        ports = list(serial.tools.list_ports.comports())
        if ports:
            for port, desc, hwid in sorted(ports):
                if '/dev/tty.usbserial' in port or '/dev/tty.usbmodem' in port:
                    SMD_Port = port
                    return SMD_Port

    else:
        SMD_Port = None
        return SMD_Port

port=USB_Port()
m = Master(port,baudrate=115200)
Red_id = 0
m.attach(Red(Red_id))

Module_id = 1
while True:
  B = m.get_button(Red_id, Module_id)

This block retrieves and returns the current ambient light value, allowing the system to adjust or react based on the surrounding light conditions.

Red_id = None
Module_id = None
Light = None


from smd.red import *
import math
import os

from serial.tools.list_ports import comports
from platform import system
def USB_Port():
    if system() == 'Windows':
        ports = list(comports())
        if ports:
            for port, desc, hwid in sorted(ports):
                if 'USB Serial Port' in desc:
                    SMD_Port = port
                    return SMD_Port

    elif system() == 'Linux':
        ports = list(serial.tools.list_ports.comports())
        if ports:
            for port, desc, hwid in sorted(ports):
                if '/dev/ttyUSB' in port:
                    SMD_Port = port
                    return SMD_Port

    elif system() == 'Darwin':  # macOS
        ports = list(serial.tools.list_ports.comports())
        if ports:
            for port, desc, hwid in sorted(ports):
                if '/dev/tty.usbserial' in port or '/dev/tty.usbmodem' in port:
                    SMD_Port = port
                    return SMD_Port

    else:
        SMD_Port = None
        return SMD_Port

port=USB_Port()
m = Master(port,baudrate=115200)
Red_id = 0
m.attach(Red(Red_id))

Module_id = 1
while True:
  Light = m.get_light(Red_id,Module_id)
Red_id = None
Module_id = None
Distance = None


from smd.red import *
import math
import os

from serial.tools.list_ports import comports
from platform import system
def USB_Port():
    if system() == 'Windows':
        ports = list(comports())
        if ports:
            for port, desc, hwid in sorted(ports):
                if 'USB Serial Port' in desc:
                    SMD_Port = port
                    return SMD_Port

    elif system() == 'Linux':
        ports = list(serial.tools.list_ports.comports())
        if ports:
            for port, desc, hwid in sorted(ports):
                if '/dev/ttyUSB' in port:
                    SMD_Port = port
                    return SMD_Port

    elif system() == 'Darwin':  # macOS
        ports = list(serial.tools.list_ports.comports())
        if ports:
            for port, desc, hwid in sorted(ports):
                if '/dev/tty.usbserial' in port or '/dev/tty.usbmodem' in port:
                    SMD_Port = port
                    return SMD_Port

    else:
        SMD_Port = None
        return SMD_Port

port=USB_Port()
m = Master(port,baudrate=115200)
Red_id = 0
m.attach(Red(Red_id))

Module_id = 1
while True:
  Distance = m.get_distance(Red_id,Module_id)
Red_id = None
Module_id = None


from smd.red import *
import math
import os

from serial.tools.list_ports import comports
from platform import system
def USB_Port():
    if system() == 'Windows':
        ports = list(comports())
        if ports:
            for port, desc, hwid in sorted(ports):
                if 'USB Serial Port' in desc:
                    SMD_Port = port
                    return SMD_Port

    elif system() == 'Linux':
        ports = list(serial.tools.list_ports.comports())
        if ports:
            for port, desc, hwid in sorted(ports):
                if '/dev/ttyUSB' in port:
                    SMD_Port = port
                    return SMD_Port

    elif system() == 'Darwin':  # macOS
        ports = list(serial.tools.list_ports.comports())
        if ports:
            for port, desc, hwid in sorted(ports):
                if '/dev/tty.usbserial' in port or '/dev/tty.usbmodem' in port:
                    SMD_Port = port
                    return SMD_Port

    else:
        SMD_Port = None
        return SMD_Port

port=USB_Port()
m = Master(port,baudrate=115200)
Red_id = 0
m.attach(Red(Red_id))

Module_id = 1
m.set_buzzer(Red_id,Module_id,500)
Red_id = None
Module_id = None
Pitch = None
roll = None


from smd.red import *
import math
import os

from serial.tools.list_ports import comports
from platform import system
def USB_Port():
    if system() == 'Windows':
        ports = list(comports())
        if ports:
            for port, desc, hwid in sorted(ports):
                if 'USB Serial Port' in desc:
                    SMD_Port = port
                    return SMD_Port

    elif system() == 'Linux':
        ports = list(serial.tools.list_ports.comports())
        if ports:
            for port, desc, hwid in sorted(ports):
                if '/dev/ttyUSB' in port:
                    SMD_Port = port
                    return SMD_Port

    elif system() == 'Darwin':  # macOS
        ports = list(serial.tools.list_ports.comports())
        if ports:
            for port, desc, hwid in sorted(ports):
                if '/dev/tty.usbserial' in port or '/dev/tty.usbmodem' in port:
                    SMD_Port = port
                    return SMD_Port

    else:
        SMD_Port = None
        return SMD_Port

port=USB_Port()
m = Master(port,baudrate=115200)
Red_id = 0
m.attach(Red(Red_id))

Module_id = 1
roll, Pitch = m.get_imu(Red_id, Module_id)  

Potentiometer Block

Red_id = None
Module_id = None
pot = None


from smd.red import *
import math
import os

from serial.tools.list_ports import comports
from platform import system
def USB_Port():
    if system() == 'Windows':
        ports = list(comports())
        if ports:
            for port, desc, hwid in sorted(ports):
                if 'USB Serial Port' in desc:
                    SMD_Port = port
                    return SMD_Port

    elif system() == 'Linux':
        ports = list(serial.tools.list_ports.comports())
        if ports:
            for port, desc, hwid in sorted(ports):
                if '/dev/ttyUSB' in port:
                    SMD_Port = port
                    return SMD_Port

    elif system() == 'Darwin':  # macOS
        ports = list(serial.tools.list_ports.comports())
        if ports:
            for port, desc, hwid in sorted(ports):
                if '/dev/tty.usbserial' in port or '/dev/tty.usbmodem' in port:
                    SMD_Port = port
                    return SMD_Port

    else:
        SMD_Port = None
        return SMD_Port

port=USB_Port()
m = Master(port,baudrate=115200)
Red_id = 0
m.attach(Red(0))

Module_id = 1
pot = m.get_potentiometer(Red_id, Module_id)

This block is used to set the position of a servo motor by specifying the desired angle. The motor adjusts its position to align with the given angle value.

Red_id = None
Module_id = None


from smd.red import *
import math
import os

from serial.tools.list_ports import comports
from platform import system
def USB_Port():
    if system() == 'Windows':
        ports = list(comports())
        if ports:
            for port, desc, hwid in sorted(ports):
                if 'USB Serial Port' in desc:
                    SMD_Port = port
                    return SMD_Port

    elif system() == 'Linux':
        ports = list(serial.tools.list_ports.comports())
        if ports:
            for port, desc, hwid in sorted(ports):
                if '/dev/ttyUSB' in port:
                    SMD_Port = port
                    return SMD_Port

    elif system() == 'Darwin':  # macOS
        ports = list(serial.tools.list_ports.comports())
        if ports:
            for port, desc, hwid in sorted(ports):
                if '/dev/tty.usbserial' in port or '/dev/tty.usbmodem' in port:
                    SMD_Port = port
                    return SMD_Port

    else:
        SMD_Port = None
        return SMD_Port

port=USB_Port()
m = Master(port,baudrate=115200)
Red_id = 0
m.attach(Red(0))

Module_id = 1
m.set_servo(Red_id, Module_id, 90)
Red_id = None
Module_id = None
left = None
right = None
middle = None


from smd.red import *
import math
import os

from serial.tools.list_ports import comports
from platform import system
def USB_Port():
    if system() == 'Windows':
        ports = list(comports())
        if ports:
            for port, desc, hwid in sorted(ports):
                if 'USB Serial Port' in desc:
                    SMD_Port = port
                    return SMD_Port

    elif system() == 'Linux':
        ports = list(serial.tools.list_ports.comports())
        if ports:
            for port, desc, hwid in sorted(ports):
                if '/dev/ttyUSB' in port:
                    SMD_Port = port
                    return SMD_Port

    elif system() == 'Darwin':  # macOS
        ports = list(serial.tools.list_ports.comports())
        if ports:
            for port, desc, hwid in sorted(ports):
                if '/dev/tty.usbserial' in port or '/dev/tty.usbmodem' in port:
                    SMD_Port = port
                    return SMD_Port

    else:
        SMD_Port = None
        return SMD_Port

port=USB_Port()
m = Master(port,baudrate=115200)
Red_id = 0
m.attach(Red(0))

Module_id = 1
left, middle, right = m.get_qtr(Red_id, Module_id)

Get Position Block

This block retrieves the current position of the motor identified by the specified Red ID. It allows the system to track and monitor the motor's position in real-time.

Red_id = None
position = None


from smd.red import *
import math
import os

from serial.tools.list_ports import comports
from platform import system
def USB_Port():
    if system() == 'Windows':
        ports = list(comports())
        if ports:
            for port, desc, hwid in sorted(ports):
                if 'USB Serial Port' in desc:
                    SMD_Port = port
                    return SMD_Port

    elif system() == 'Linux':
        ports = list(serial.tools.list_ports.comports())
        if ports:
            for port, desc, hwid in sorted(ports):
                if '/dev/ttyUSB' in port:
                    SMD_Port = port
                    return SMD_Port

    elif system() == 'Darwin':  # macOS
        ports = list(serial.tools.list_ports.comports())
        if ports:
            for port, desc, hwid in sorted(ports):
                if '/dev/tty.usbserial' in port or '/dev/tty.usbmodem' in port:
                    SMD_Port = port
                    return SMD_Port

    else:
        SMD_Port = None
        return SMD_Port

port=USB_Port()
m = Master(port,baudrate=115200)
Red_id = 0
m.attach(Red(Red_id))

position = m.get_position(Red_id)

Get Block

This block receives x, y, and button information from the and synchronizes it with the corresponding variable blocks placed on the values within the block. This allows real-time control and interaction based on joystick input.

Block

This block controls the by setting its color according to the RGB values entered. Users can specify the desired red, green, and blue values to customize the LED’s color output.

Block

This block retrieves and returns the current value from the , allowing the system to react based on the button's state (e.g., pressed or released).

Block

Block

This block retrieves and returns the distance value measured by the , providing accurate readings of the proximity or distance to an object..

Block

This block activates the and sets it to emit sound at the frequency value entered by the user.

Block

This block receives and processes data from the , which typically includes information such as orientation.

This block retrieves the ADC (Analog-to-Digital Conversion) value from the e, providing a digital representation of the analog voltage output based on the potentiometer's position.

Blocks

Block

This block retrieves the sensor values from the , typically used for detecting changes in proximity, position, or surface reflection.

Joystick
joystick module
RGB Led
RGB LED module
Button
button module
Ambient Light Sensor
Ultrasonic Distance Sensor
ultrasonic distance sensor
Buzzer
buzzer module
IMU
IMU (Inertial Measurement Unit)
potentiometer modul
Servo
QTR
QTR module