Week14 | Interface and application programming
Group members
Group assignment
This week's group assignment included:
- Compare as many tool options as possible.
- Document your work on the group work page and reflect on your individual page what you learned.
Arduino and Processing
We started with Arduino and processing by following Gleb's example.
We used an RP2040 microcontroller on a PCB which Omid made during week08, and it had a button connected to P1 and a LED connected to P0. We uploaded lightbulb-toggle.ino.ino on the microcontroller. Both Arduino and Processing code included in the download files.
The Arduino program does two main things. First, it reads the button input and toggles the LED when the button is pressed. It uses debounce logic, which means it ignores very quick, noisy signals and only accepts a press if it stays stable for at least 50 milliseconds. This prevents false triggers. When the LED state changes, the board sends a message like 0,1 to the computer through the serial connection.
Second, it listens for messages coming from the computer. If it receives a command, it updates the LED state accordingly. Both sides communicate using the same simple format, so they stay in sync without sending repeated signals back and forth.
On the computer side, we used a lightbulbToggle.pde sketch to create a graphical interface. Processing is a simple tool for learning and experimenting with code, but it has some limits. For example, resizing windows is awkward, and building responsive interfaces is not very easy.
The program shows a lightbulb in the middle of the window along with a toggle switch. It connects to the microcontroller through a serial port.
When we click the bulb or the toggle, the LED turns on or off, and the change is sent to the board. When we press the physical button on the board, the interface updates. In short, both the hardware and the GUI control the same LED, and they always stay synchronized.