Rev Up the Engine

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 Buzzer Module and the RGB LED Module as rev limiter sound and rev level indicator.

Project Key Components

  1. SMD

    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 Button Module and actuate the BDC motor, the RGB LED Module and the Buzzer Module.

  2. 100 RPM BDC Motor with Encoder

    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. Button Module

    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. SMD Libraries

    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 Button Module and actuate the BDC motor, also the other modules.

Project Key Features

  • Dynamic Engine Revving

    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 Button Module will result in rev increase and releasing it will decrease the rev.

  • 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

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

Project Wiring Diagram

Getting Started

  1. Hardware Setup

  2. Run the Script

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

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

  3. 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.

  4. 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.

Project Codes:

from smd.red import*
import time
port = "COM13"
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


Last updated