Action - Reaction

The LED Turn On/Off application is an interactive Python project that utilizes an SMD Motor Driver, an add-on LED Module, and a Push Button Module to control the state of an LED. This project is designed to provide a hands-on experience for users interested in combining Python programming with hardware control, offering a simple yet effective demonstration of basic input and output interactions.

Project Media:

Project Key Components:

  1. SMD Motor Driver:

    • The SMD Motor Driver acts as the interface between the Python script and the connected hardware components. It interprets commands from the script and translates them into actions that drive the LED and respond to button input.

  2. LED Module Add-on:

    • An additional LED module is connected to the SMD Motor Driver. This module serves as the output device, displaying the result of the Python script's commands to turn the LED on or off.

  3. Push Button Module:

    • A Push Button Module is integrated into the project to provide a physical interface for user input. Pressing the button triggers an event in the Python script, allowing users to toggle the state of the LED.

  4. Python Script:

    • The Python script is the core of the application. It establishes communication with the SMD Motor Driver, listens for button presses from the Push Button Module, and sends commands to control the LED's on/off state.

Project Key Features:

  1. Toggle Functionality:

    • The application supports a toggle functionality, allowing users to press the button to switch the LED between the on and off states. This provides a straightforward and intuitive user experience.

  2. Feedback through LED Module:

    • The LED module serves as a visual indicator of the current state of the LED. When the LED is turned on, it emits light, and when turned off, it remains unlit.

Project Wiring Diagram:

Getting Started:

  1. Hardware Setup:

    • Connect the SMD Motor Driver to both the LED module and the Push Button Module, following the provided documentation.

    • Ensure secure connections and proper power supply to the hardware components.

  2. Run the Python Script:

    • Execute the Python script on your computer. This will establish communication with the SMD Motor Driver, monitor the state of the Push Button Module, and control the LED accordingly.

  3. Toggle LED State:

    • Press the button on the Push Button Module to toggle the LED state between on and off. Observe the visual feedback on the LED module.

Project Media:

Projcet Codes:

from smd.red import*
import time
port = "COM13"
m = Master(port)
m.attach(Red(0))

print(m.scan_modules(0))
while True:
    button = m.get_button(0, 1)
    print(button)
    if button == 1:
        light = m.set_rgb(0, 1, red = 255, green = 255, blue = 255)
    else:
        light = m.set_rgb(0, 1, red = 0, green = 0, blue = 0)

Last updated

Change request #247: Main structural changes of content table and trees, also text contents