Thanks. Here is the Python Code, i have a seperate file requirements.txt that simply says flask in it.
None of the bricks create wifi controller of a motor.
Seeing the AppLab and Uno Q are newer it is hard to find specific information..Maybe I just use bluetooth but not sure how to get the code for that. This is my first robotics project. Thanks.
<
from arduino.app_utils import *
import socket
from flask import Flask, render_template_string
from threading import Thread
app = Flask(name)
Get the board's WiFi IP address and print it
def get_ip():
try:
import socket
s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
s.connect(("8.8.8.8", 80))
ip = s.getsockname()[0]
s.close()
return ip
except Exception:
return "unable to detect - use ping/SSH IP"
ip = get_ip()
print("=== MOTOR CONTROL APP STARTED ===")
print(f"WiFi IP Address: {ip}")
print(f"Open http://{ip} in your browser to control the motors!")
print("Web server (Flask) starting on port 80...")
Embedded HTML control page
HTML = """
UNO Q Motor Control
body { text-align: center; font-family: Arial, sans-serif; background: #f0f0f0; padding: 20px; }
h1 { color: #333; }
button { font-size: 24px; padding: 20px; margin: 10px; width: 200px; border: none; border-radius: 10px; cursor: pointer; }
.stop { background: red; color: white; }
.go { background: #4CAF50; color: white; }
Arduino UNO Q
L298N Motor Control
Forward
Backward
Turn Left
Turn Right
STOP
Home
"""
@app.route("/")
def index():
return render_template_string(HTML)
@app.route("/forward")
def forward():
Bridge.call("setMotors", 300, 300)
return "
Going Forward
Back to controls"
@app.route("/backward")
def backward():
Bridge.call("setMotors", -300, -300)
return "
Going Backward
Back to controls"
@app.route("/left")
def left():
Bridge.call("setMotors", -250, 250)
return "
Turning Left
Back to controls"
@app.route("/right")
def right():
Bridge.call("setMotors", 250, -250)
return "
Turning Right
Back to controls"
@app.route("/stop")
def stop():
Bridge.call("setMotors", 0, 0)
return "
Stopped
Back to controls"
Run Flask server in a background thread
def run_server():
app.run(host="0.0.0.0", port=80, debug=False, use_reloader=False)
server_thread = Thread(target=run_server)
server_thread.daemon = True
server_thread.start()
Keep the app running
def user_loop():
pass
App.run(user_loop=user_loop)
/>