Acrome-SMD Docs
All Acrome ProductsReferencesBlogCase StudiesContact Us
  • ACROME SMD
  • Electronics
    • 🔴SMD Red
      • Coding Guide
      • Robot with Raspberry Pi Setup Guide
      • Robot with Arduino Setup Guide
      • 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
    • 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
      • What You Can Build
    • Education Kit
      • What You Can Build
    • Motion Kit
      • What You Can Build
  • 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
      • Differential Robot Projects
      • Mouse Cursor Tracker Motion Robot
      • Waypoint tracker robot
      • Braitenberg Robot
      • Line-Follower Robot
      • Teleoperation Robot
      • Obstacle Avoidance Robot
      • ESP32 Wireless Controlled Mobile Robot
  • AI
    • Object Tracking Robot
    • Groq Chatbot-Controlled Robot
  • ROS
    • Teleoperation Robot with ROS
  • 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
  • Step 1: Hardware & Software Overview
  • Step 2: Assemble
  • Step 3: Run & Test
  • Codes:
  1. SMD Applications
  2. Interactive

Rev Up the Engine

PreviousJoystick Mouse ControlNextMotor Rotation Based on Turn Input Value

Last updated 3 months ago

The Rev Up the Engine project is a fun project that imitates the revving of an engine through software and hardware. It has both visual and physical interaction modules. There is the Button Module for the user to interact and imitate a gas pedal. There are also the and the as rev limiter sound and rev level indicator.

About Tools and Materials:

()

()

()

()

()

()

()

Step 1: Hardware & Software Overview

Project Key Components

  1. The SMD acts as a bridge between the script and the modules. It is responsible for interpreting the commands sent by the script and translating them into actions that read input from the and actuate the BDC motor, the and the .

  2. The 100 RPM BDC Motor with Encoder is used to imitate an engine running. The speed of the motor can be controlled precisely thanks to the built-in encoder.

  3. The Button Module is used as an physical interaction device for the user. It imitates a gas pedal, revving the engine while it is pressed.

  4. Changes colors based on engine speed, acting as a visual rev limiter indicator.

  5. Produces revving sounds that match engine speed for a realistic experience.

  6. The SMD library is at the heart of the application. It communicates with the SMD using a specific communication protocol, sending commands to read the and actuate the BDC motor, also the other modules.

Project Key Features

  • Dynamic Engine Revving

  • Real-time Speed Control

    The script continuously can store and monitor the current velocity level of the motor. The user can use these values to modify the project.

  • Customizable Speed Profile

Step 2: Assemble

Getting Started

  1. Hardware Setup

    • Make sure that the SMD is powered and all connections are correct.

Project Wiring Diagram

Step 3: Run & Test

  1. Run the Script

    • Execute the script, initiating the Rev Up the Engine project.

  2. Experience the Engine Revving

    • Observe how the motor speed increases gradually while the button is held down.

    • Release the button and notice the motor speed decreasing until it comes to a stop.

  3. Customize and Experiment

    • Experiment with different parameter values in the script to customize the speed profile.

    • Explore additional features, such as the buzzer sound and frequency and RGB LED colors and intensities.

Codes:

from smd.red import*
import time
from serial.tools.list_ports import comports
from platform import system

def USB_Port():
	ports = list(comports())
	usb_names = {
		"Windows": ["USB Serial Port"],
		"Linux": ["/dev/ttyUSB"],
		"Darwin": [
			"/dev/tty.usbserial",
			"/dev/tty.usbmodem",
			"/dev/tty.SLAB_USBtoUART",
			"/dev/tty.wchusbserial",
			"/dev/cu.usbserial",
            		"/dev/cu.usbmodem",
			"/dev/cu.SLAB_USBtoUART",
			"/dev/cu.wchusbserial",
		]
	}
	
	os_name = system()
	if ports:
		for port, desc, hwid in sorted(ports):
			if any(name in port or name in desc for name in usb_names.get(os_name, [])):
				return port
		print("Current ports:")
		for port, desc, hwid in ports:
			print(f"Port: {port}, Description: {desc}, Hardware ID: {hwid}")
	else:
		print("No port found")
	return None
	
port = USB_Port()
m = Master(port)
m.attach(Red(0))

print(m.scan_modules(0))

m.set_operation_mode(0, 0)
m.enable_torque(0, True)

button_prev = 0
pwm = 0

while True:
    time.sleep(0.05)
    button = m.get_button(0, 1)
    print(button)

    if button != None:
            if button == 1:
                if button_prev == 0:  # Button was just pressed
                    for pwm in range(51):
                        m.set_duty_cycle(0, pwm)
                        time.sleep(0.1)
                        red_value = int(pwm * 255 / 50)
                        green_value = int((50 - pwm) * 255 / 50)
                        light = m.set_rgb(0, 1, red=red_value, green=green_value, blue=0)
                        if pwm == 50:
                             m.set_buzzer(0, 1, 1000)  # Activate the buzzer
                    button_prev = 1
            elif button == 0:
                if button_prev == 1:  # Button was just released
                    for pwm in range(50, -1, -1):
                        m.set_duty_cycle(0, pwm)
                        time.sleep(0.1)
                        red_value = int(pwm * 255 / 50)
                        green_value = int((50 - pwm) * 255 / 50)
                        light = m.set_rgb(0, 1, red=red_value, green=green_value, blue=0)
                        if pwm == 0:
                            m.set_buzzer(0, 1, 0)  # Deactivate the buzzer

                    button_prev = 0
#include <Acrome-SMD.h>

#define ID 0
#define BAUDRATE 115200

Red master(ID, Serial, BAUDRATE);

bool button_prev = false;
int pwm = 0;

void setup() {
    master.begin();
    master.scanModules();
    master.setOperationMode(0);
    master.torqueEnable(1);
}

void loop() {
    bool button = master.getButton(5);

    if (button) {
        if (!button_prev) {  
            for (pwm = 0; pwm <= 50; pwm++) {
                master.setpoint(0, pwm);
                delay(100);
                int red_value = pwm * 255 / 50;
                int green_value = (50 - pwm) * 255 / 50;
                master.setRGB(5, red_value, green_value, 0); 
                if (pwm == 50) {
                    master.setBuzzer(5, 1000);
                }
            }
            button_prev = true;
        }
    } else {
        if (button_prev) { 
            for (pwm = 50; pwm >= 0; pwm--) {
                master.setpoint(0, pwm); 
                delay(100);
                int red_value = pwm * 255 / 50;
                int green_value = (50 - pwm) * 255 / 50;
                master.setRGB(5, red_value, green_value, 0); 
                if (pwm == 0) {
                    master.setBuzzer(5, 0);
                }
            }
            button_prev = false;
        }
    }
}

The project allows the user to use the modules to interact and imitate an engine. It is a great project for seeing the results of the physical interaction. Holding the will result in rev increase and releasing it will decrease the rev.

The user can customize the step time or rev increase amount per step. Also, the can be used to emit different light levels and colors.

Connect the SMD to the PC or Arduino board using or .

Connect the 100 RPM BDC Motor with Encoder to the motor ports of the SMD and the , the and the to the SMD using an RJ-45 cable.

Press or hold the to see the engine revving and other visual experiences.

Buzzer Module
RGB LED Module
SMD Red
Purchase Here
SMD USB Gateway
Purchase Here
Arduino Gateway Module
Purchase Here
RGB LED Module
Purchase Here
Button Module
Purchase Here
BDC Motor
Purchase Here
Buzzer Module
Purchase Here
SMD
Button Module
RGB LED Module
Buzzer Module
BDC Motor
Button Module
RGB LED Module
Buzzer Module
SMD Libraries
Button Module
Button Module
RGB LED Module
USB Gateway Module
Arduino Gateway Module
Button Module
RGB LED Module
Buzzer Module
Button Module