09. Embedded programming
Homework: Make an Arduino project
I have installed the Arduino software on my Windows machine and already made a few projects with it. But now, I would like to try two different programming languages with it: Cylon.js, built on JavaScript and Artoo, built on Ruby.
We have made several projects during the week. One of them is using a potentiometer to fade the light of a led.
We shoot 5V to the potentiometer and connect the LED to a digital pin that supports PWM. On the Arduino MEGA 2560 that we are using, all of them do. We will remember to use both analogRead()
and analogWrite()
I fried an LED using it without a resistor, so now we are using a resistor
It can also be simulated on TinkerCAD
Using Cylon.JS
- Install NodeJS by downloading it from the official website
npm install cylon cylon-firmata
- Install Gort from the official website
gort arduino install
gort scan serial
We can see that the Arduino is connected to COM4gort arduino upload firmata COM4
We are now ready to connect and communicate with the Arduino via serial
Work in progress - using Docker
Reminder: we have a few constraints:
- We are running Windows
- I do not want to install any software
- Therefore, everything we do will be happening in a docker
Making Docker GUI-friendly
So far, Docker has only been working in CLI. This has been useful for many of the applications but it seems to me that we are going to need the GUI. In the future, I want to go 100% CLI but let’s make our Docker GUI-compatible for now.
Install VcxSrv choco install vcxsrv
and then follow the following instructions
Now our hosts should have 2 extra lines indicating the $DISPLAY should be connected to our local IP
Let’s test if it works by running GIMP: docker run --rm -it -e DISPLAY=host.docker.internal:0 jamesnetherton/gimp
Now that we have GIMP running, we can create a Dockerfile