Giuseppe Romano
Published © GPL3+

DIY Stream Deck With Arduino & Nextion

Create a DIY Stream Deck with Arduino & Nextion: open apps, execute shortcuts, and enhance your workflow!

IntermediateFull instructions provided5 hours505
DIY Stream Deck With Arduino & Nextion

Things used in this project

Hardware components

Nextion NX3224T028 - Generic 2.8" HMI LCD Touch Display
Itead Nextion NX3224T028 - Generic 2.8" HMI LCD Touch Display
×1
Arduino micro PRO (HID)
×1
USB-to-Serial Converter (FT782 or equivalent)
×1
Standard wires
×1
JST Connectors
×1
JST Connector Crimping Tool
×1
USB C Cable
×1
Mini USB B Cabl
×1
Threaded Inserts, M2 M2.5 M3 M4 M5 M6
×1

Story

Read more

Schematics

nextion_display_programming_diagram_bwVCghsH1c.png

Arduino Micro PRO HID programming diagram

Code

MacroTouchDeck_Eng-2.ino

Arduino
This Arduino sketch transforms a Pro Micro (HID) into a customizable Stream Deck with a Nextion touchscreen interface. It allows you to control your PC efficiently by launching applications, opening websites, executing keyboard shortcuts, and more with just a touch. Perfect for creators and tech enthusiasts looking to simplify their workflow.
Repository: https://drive.google.com/drive/folders/18KDvrZ0ekq5Of2Fsz4jRwHVF6F9EnbtK?usp=sharing
/**
 * Stream Deck - PC Control with Arduino and Nextion Display
 * 
 * This sketch transforms an Arduino Pro Micro (HID) and a Nextion display 
 * into a Stream Deck, a programmable keyboard with a customized graphical interface. 
 * The device is capable of:
 * - Opening websites such as YouTube, Facebook, and Instructables
 * - Launching applications like Filmora, Arduino IDE, Total Commander, PowerPoint, and Word
 * - Opening specific folders like "Download"
 * - Taking screenshots using the Windows + Shift + S shortcut
 * - Simulating key combinations to enhance the user's workflow
 * 
 * This project is perfect for anyone looking to simplify daily PC operations 
 * and create a personalized touch interface.
 * 
 *  Project video: [INSERT VIDEO LINK]
 *  Subscribe to the YouTube channel Electronic & CNC Lab: https://www.youtube.com/@Electronic.CNCLab
 * Video link: https://youtu.be/jhJxBRKb4Ug
 * 
 *  Giuseppe from Electronic & CNC Lab - 2025
 */

#define HID_CUSTOM_LAYOUT
#define LAYOUT_ITALIAN
#include <HID-Project.h>

void setup() {
    Serial.begin(9600);   // Debug on USB
    Serial1.begin(9600);  // Communication with Nextion on Serial1 (RX1/TX1)
    Keyboard.begin();     // Activate HID keyboard emulation

    Serial.println("Macro Touch Deck Started!");
}

void loop() {
    if (Serial1.available()) {
        char cmd = Serial1.read();  // Read a single character
        Serial.print("Command received from Nextion: ");
        Serial.println(cmd);

        executeCommand(cmd);
    }
}

/**
 * Executes the command corresponding to the received character
 */
void executeCommand(char cmd) {
    if (cmd == 'a') { Serial.println("Opening YouTube..."); openURL("https://www.youtube.com"); }
    else if (cmd == 'b') { Serial.println("Opening Facebook..."); openURL("https://www.facebook.com"); }
    else if (cmd == 'c') { Serial.println("Opening Instructables..."); openURL("https://www.instructables.com"); }
    else if (cmd == 'd') { Serial.println("Opening Filmora..."); openProgram("Filmora.exe"); Serial.println("Ensure the correct path to Filmora is set on your system (use double backslashes '\\' in paths)."); }
    else if (cmd == 'e') { Serial.println("Opening Arduino IDE..."); openProgram("Arduino IDE.exe"); Serial.println("Ensure the correct path to Arduino IDE is set on your system (use double backslashes '\\' in paths)."); }
    else if (cmd == 'f') { Serial.println("Opening Total Commander..."); openProgram("C:\\Program Files\\totalcmd\\TOTALCMD64.EXE"); }
    else if (cmd == 'g') { Serial.println("Opening Paint..."); openProgram("mspaint"); }
    else if (cmd == 'h') { Serial.println("Opening Download folder..."); openProgram("Downloads"); Serial.println("Ensure the correct path to your Downloads folder is set on your system (use double backslashes '\\' in paths)."); }
    else if (cmd == 'i') { Serial.println("Taking Screenshot..."); takeScreenshot(); }
    else if (cmd == 'j') { Serial.println("Opening YouTube Channel..."); openURL("https://www.youtube.com/@Electronic.CNCLab"); }
    else if (cmd == 'k') { Serial.println("Opening PowerPoint..."); openProgram("C:\\Program Files\\Microsoft Office\\root\\Office16\\POWERPNT.EXE"); }
    else if (cmd == 'l') { Serial.println("Opening Word..."); openProgram("C:\\Program Files\\Microsoft Office\\root\\Office16\\WINWORD.EXE"); }
    else { Serial.println("Unrecognized command!"); }
}

/**
 * Opens a URL in the browser
 */
void openURL(const char* url) {
    // Open "Run"
    Keyboard.press(KEY_LEFT_GUI); // Windows Key
    Keyboard.press(KEY_R);        // 'R' key
    Keyboard.releaseAll();
    delay(300);

    // Type the URL and press Enter
    Keyboard.print(url);
    Keyboard.write(KEY_RETURN);
}

/**
 * Opens a specific program
 */
void openProgram(const char* path) {
    Serial.print("Opening program: ");
    Serial.println(path);

    // Open "Run" using Win+R
    Keyboard.press(KEY_LEFT_GUI);
    Keyboard.press(KEY_R);
    delay(300); // Wait for the window to open
    Keyboard.releaseAll(); // Release keys

    delay(500);  // Ensure "Run" window is ready

    // Type the path and press Enter
    Keyboard.print(path);  // Use print to avoid additional newline
    delay(300); // Wait for input
    Keyboard.write(KEY_RETURN);
}

/**
 * Opens a folder in File Explorer
 */
void openFolder(const char* path) {
    Serial.print("Opening folder: "); Serial.println(path);

    Keyboard.press(KEY_LEFT_GUI);
    Keyboard.press('R'); // Open "Run" window
    Keyboard.releaseAll();
    delay(600);  // Wait for the window to open

    Keyboard.print(path);  // Type the exact folder path
    delay(300);  // Wait briefly for safety
    Keyboard.write(KEY_RETURN);  // Press Enter to open the folder
}

/**
 * Takes a screenshot (Windows + Shift + S)
 */
void takeScreenshot() {
    Serial.println("Taking Screenshot...");
    Keyboard.press(KEY_LEFT_GUI);
    Keyboard.press(KEY_LEFT_SHIFT);
    Keyboard.press('S');
    delay(100);
    Keyboard.releaseAll();
}

/**
 * Simulates a key combination (e.g., Ctrl+A, Ctrl+C, Ctrl+V)
 */
void pressKeys(uint8_t key1, uint8_t key2) {
    Serial.print("Pressing keys: ");
    Serial.print(key1, HEX);
    Serial.print(" + ");
    Serial.println(key2, HEX);

    Keyboard.press(key1);
    delay(50);
    Keyboard.press(key2);
    delay(100);
    Keyboard.releaseAll();
}

Credits

Giuseppe Romano
1 project • 1 follower
Electronics designer with 20+ years of experience in analog design, microcontrollers (Arduino), 3D printing, and CNC milling.
Contact

Comments

Please log in or sign up to comment.