Skip to content
Snippets Groups Projects
Select Git revision
  • 42057f1b2f179d571c3ea3c58b9acb1158cdad64
  • main default protected
2 results

compile_run_arduino.sh

Blame
  • compile_run_arduino.sh 900 B
    #!/bin/bash
    #source ~/.platformio/penv/bin/activate && pio run -e megaatmega2560 -t upload
    
    #!/bin/bash
    
    # Define the project directory
    PROJECT_DIR="/home/mola/Desktop/hps_mola_mola/New_Structure/Inside_Boat/Mola_Slave/"
    
    # Navigate to the project directory
    cd "$PROJECT_DIR" || { echo "Directory not found!"; exit 1; }
    
    
    source ~/platformio-venv/bin/activate
    
    
    # Initialize the project (optional, can be skipped if already initialized)
    pio project init
    
    
    # Compile the project
    echo "Compiling the project..."
    pio run
    if [ $? -ne 0 ]; then
        echo "Compilation failed!"
        exit 1
    fi
    
    # Upload the compiled firmware to the device
    echo "Uploading the firmware..."
    pio run --target upload
    if [ $? -ne 0 ]; then
        echo "Upload failed!"
        exit 1
    fi
    
    # Monitor the serial output (optional)
    if [ "$1" == "--monitor" ]; then
        echo "Opening serial monitor..."
        pio device monitor
    fi
    
    echo "Done!"