Back to home

Week 11

This week, I explored interface programming.

Web serial

I wanted to integrate a scoreboard on my computer for my final project. Leo made a very simple web serial example which I downloaded and opened in VS code to edit. I am unfamiliar with JavaScript, so I did not know how to store my goal counting variable on the website side. Instead, the code running on my D21 chip stored a count variable and printed it to serial monitor using print("count: ") then println(count). The JavaScript then parsed this by "count: " and identified what the goal count was.

Setting up port

In order to communicate between the serial port and web, I first connected my D21 breakout board and programmed it with the goal counting sketch. Then, I opened the "index.html" file in my browser and selected the correct port. Leo warned me that once the port is being used for one thing, it cannot be used for anything else. So, if I wanted to go back and re-upload to my board, I would have to disconnect from the website first.

I made a few tweaks to the example in order to make it display the goal count variable. Given more time, I could make this nicer with some css. I would also like to store the variable on the web side so that I can add a reset button that will set it back to 0.

This was a quick and simple way to display the score.

Tips for the week