-
Notifications
You must be signed in to change notification settings - Fork 0
Installation.md
Ready to unleash the power of Bang and turn your Arduino into a host-dominating beast? This guide walks you through setting up the Bang library, getting your Arduino and host (PC, Mac, or Linux) ready to fire off shell commands (!), custom macros (@), and self-reprogramming sketches (&). You’ll be sending BANG("echo Hello") or BANG("&blink\n") in no time, all while keeping it lean for Arduino’s tight memory limits. Let’s dive in and make your microcontroller a command-line legend!
Before you start, gather these essentials:
- Arduino Board: Any Arduino with Serial-USB (e.g., Uno, Nano). No extra hardware needed, but an FTDI module is optional for dual streams.
- Host Machine: PC, Mac, or Linux with a USB port and Python 3 installed.
- USB Cable: To connect the Arduino to the host.
-
Software:
- Arduino IDE (or
arduino-clifor dynamic uploads). - Python 3 and
pyserialfor the host agent. - Git (optional, for cloning the repo).
- Arduino IDE (or
-
Admin Privileges: For commands or macros requiring
sudo(e.g.,BANG("reboot"),BANG("@reboot")).
-
Clone or Download the Repository
-
Option 1: Clone with Git:
git clone https://github.com/ripred/Bang.git
-
Option 2: Download ZIP:
- Grab the ZIP from GitHub and extract it to a folder.
- The repo includes
Bang.h,Bang.cpp,arduino_exec.py, andexamples/(e.g.,upload.ino,music.ino).
-
Option 1: Clone with Git:
-
Install the Arduino IDE
- Download from https://www.arduino.cc/en/software and install for your OS (Windows, macOS, Linux).
- Skip if you’re using
arduino-clifor uploads (see step 6).
-
Add the Bang Library to Arduino
- Copy the
Bangfolder (containingBang.handBang.cpp) to your Arduino libraries folder:- Windows:
Documents/Arduino/libraries/ - macOS/Linux:
~/Documents/Arduino/libraries/
- Windows:
- Alternatively, in the Arduino IDE:
- Go to Sketch > Include Library > Add .ZIP Library, select the
Bangfolder or ZIP.
- Go to Sketch > Include Library > Add .ZIP Library, select the
- Verify the library is recognized: Sketch > Include Library should list “Bang”.
- Copy the
-
Install Python and
pyserialon the Host- Ensure Python 3 is installed (check with
python3 --version). - Install
pyserial:pip3 install pyserial
- This powers
arduino_exec.pyto handle Serial communication.
- Ensure Python 3 is installed (check with
-
Set Up
arduino-clifor Dynamic Uploads (Optional)- For
BANG("&blink\n")to work, installarduino-cli:- Download from https://arduino.github.io/arduino-cli.
- Follow setup instructions for your OS (e.g.,
brew install arduino-clion macOS).
- Configure
arduino-cli:arduino-cli config init arduino-cli core update-index arduino-cli core install arduino:avr
- Needed for
arduino_exec.pyto compile/upload sketches (e.g.,blink.ino).
- For
-
Prepare the Python Agent
- Copy
arduino_exec.pyfrom the repo to a folder on your host (e.g.,~/Bang/). - Identify your Arduino’s serial port:
- Windows: Check Device Manager (e.g.,
COM3). - macOS/Linux: Run
ls /dev/cu.*orls /dev/tty.*(e.g.,/dev/cu.usbserial-00100).
- Windows: Check Device Manager (e.g.,
- Run
arduino_exec.pywithsudofor privileged commands (e.g.,!reboot,@reboot):sudo python3 arduino_exec.py -p /dev/cu.usbserial-00100 -b 38400
-
-p: Serial port (replace with your port). -
-b: Baud rate (default 38400, adjustable).
-
- Keep
arduino_exec.pyrunning to process!,&, and@commands.
- Copy
-
Configure User-Defined Macros (Optional)
- To use
@macro_name(e.g.,BANG("@play")), editarduino_exec.pyto map macros to actions:- Open
arduino_exec.pyin a text editor. - Add logic to handle
@commands, e.g.:if line.startswith('@play'): subprocess.run(['osascript', '-e', 'tell application "Music" to play']) elif line.startswith('@reboot'): subprocess.run(['reboot'])
- Save and restart
arduino_exec.pywithsudofor privileged macros.
- Open
- See Python Agent for detailed macro setup.
- To use
-
Upload an Example Sketch
- Open the Arduino IDE and load an example from the
examples/folder (e.g.,examples/blink/blink.ino). - Connect your Arduino via USB.
- In the IDE:
- Select your board: Tools > Board (e.g., Arduino Uno).
- Select the port: Tools > Port (e.g.,
/dev/cu.usbserial-00100).
- Click Upload to flash the sketch.
- Open the Serial Monitor (Tools > Serial Monitor, baud rate 38400) to see output (e.g.,
Hello WorldfromBANG("echo Hello World")).
- Open the Arduino IDE and load an example from the
-
Test the Setup
- With
arduino_exec.pyrunning and a sketch likeblink.inouploaded:- Check the Serial Monitor for output (e.g.,
Blink ExamplefromBANG("echo Blink Example")). - Try
upload.inoto testBANG("&blink\n"), which should uploadblink.ino. - Test a macro if configured (e.g.,
BANG("@play")to start music).
- Check the Serial Monitor for output (e.g.,
- See Usage for command examples.
- With
-
Serial Monitor Blank: Ensure baud rate is 38400, the correct port is selected, and
arduino_exec.pyis running. -
Upload Fails: Verify
arduino-cliis installed and configured, and the sketch file (e.g.,blink.ino) is accessible toarduino_exec.py. -
Macro Not Working: Check
@macro_namedefinitions inarduino_exec.py(see Python Agent). -
Permission Errors: Run
arduino_exec.pywithsudofor!rebootor@reboot. - See Troubleshooting for more fixes.
- Jump to Usage to start firing
BANG("echo Hello"),BANG("@play"), orBANG("&blink\n"). - Explore Python Agent for advanced
@macrosetup. - Check Dynamic Uploading to master self-reprogramming.