Interface
My own things
Python
I tried the PhysicalPixel example that is built into the Arduino IDE and modified it to send commands to the motor.
In the video below I am controlling the motors with Python through two serial ports at the same time. The left motor rotates twice and the right motor rotates once.
Design files
Here is the Python code that I used to control two motors at the same time:
Download SimpleFOCprompt-2motors.py
Browser-based interface
I found a fantastic example of using WebSerial in Py-Script and tried to run it locally. I got the error:
I found that this is because the code can only be run on a server. I tried to set up a local server using web.py but that didn't work and then I tried uploading the example to my website but the MkDocs system dindn't allow me to access the page. Then I found this tutorial on how to deploy a Py-Script app to GitHub Pages. That was easy, it's just a matter of creating a repository, uploading the files and going into settings and enabling deployment:
The repository itself is under the Code tab. Go into the Settings tab, select Pages in the left menu and under Build and Deployment select main
, root
and click Save. As long as the repository has a file called index.html, the site is now live!
Here's a link to the two motor control interface: baks
Here I'm connecting to a COM device and sending it the command T12, which means 'Turn by 12 radians', or just about two rotations:
It works! I couldn't be more excited! I'm getting close to having the full stack of technologies working. And the interface is live on the web!
I made some very rough modifications to the code and managed to connect to two COM ports and control two motors:
Design files
Here are the two files that you need to host on a web server to make my rough baks serial communication portal work:
In both cases, the motor control code is the same as in Motor Control.
I've also found a way to embed the interface into this web page. You can use this to connect to any serial device and send it commands. The buttons only render as text, and there's only one input field, after "Write to another serial port:"
Modular Things
When I had the rgbb board and the stepper board working, I managed to make them interact with the following code (I named the stepper after myself):
Svavar.setCurrentScale(0.3);
Svavar.setVelocity(200);
Svavar.setAccel(40);
var val = 0;
loop(async () => {
val = await led.getButtonState(0);
console.log(val);
led.setRGB(val,val,val);
let pos = 0;
if(val == true){
for (let i = 0; i < 2; i++) {
pos = pos == 0 ? 5 : 0;
await Svavar.absolute(pos);
}
}
}, 50);
The RGBB Modular Thing interacting with spiral 1 of my robot in the Modular Things web interface.
Design files
Download the RGBB-baks Arduino code
The motor control code is the same as in Motor Control.