Transmitting Circles
Transmitting Circles
What I wanted to learn, and why it interested me: I wanted to learn how to transmit data and information across Arduinos so that they could communicate with each other. This interested me because it reminded me of the internet, the same way two separate devices with their own internal processes and data can still communicate data to each other.
Final outcome: The final build was a "controller" with two buttons, whose values were read by the transmitting Arduino, which transmitted into the receiver Arduino, which would output a circle of varying radius to the 8x8 display.
Images of final creative/exploratory output
The final product - from left to right: a controller with two buttons, that gets read by the transmitting Arduino, which is transmitted into the receiver Arduino, which then outputs a circle to the 8x8 display.
A video of the final product working
Process images from development towards creative/exploratory output
While trying to get the Arduino's to communicate with each other, a middle step from the training sequence to the final project was transmitting the potentiometer value from one Arduino to control the LED of the other Arduino.
One of the issues I faced when creating the final product was trying to adjust the length of a button press so that it wouldn't immediate increase the circle to the maximum size/minimum size with what felt like one button press. If I didn't seemingly record this video on the nearest toaster, you would be able to tell from the Serial Monitor that each button press was registering as more than just +-1.
Process and reflection:
After completing the training sequence, my next step was the previously seen potentiometer to LED circuit. After that was finished, I focused on figuring out how to get the 8x8 LED display to work with one singular Arduino and creating patterns that I found interesting. From there, I attached it to the other Arduino with the "controller" attached to the transmitter and the display attached to the receiver. The most interesting part of the process was encoding the button presses through bit manipulation, where each button was represented by a single bit (on or off) and this 2 bit integer was sent to and understood by the receiver Arduino. From there, besides the max/min size problem displayed above, it was smooth sailing.
Overall I'm happy with how it came out. With more time I think I could've added more, maybe a moving circle or two Arduino's communicating back and forth with each other instead, but being able to use what I've learned in school with the bit manipulation was interesting enough for me.
Technical details
Note: the 5V and ground of each Uno is conncected
/*
60-223 Intro to Physical Computing, fall 2025
Domain-specific Skill Building exercise: Transmitting Circles
A sketch for transmitting the individual button presses of two buttons to another Arduino through the serial
Pin mapping:
Arduino pin | role | details
------------------------------
8 input button
7 input button
Released to the public domain by the author, Sept 2025
Helios Gayibor
*/
const int BUTTON1PIN = 8;
const int BUTTON2PIN = 7;
void setup() {
Serial.begin(9600);
pinMode(BUTTON1PIN, INPUT_PULLUP);
pinMode(BUTTON2PIN, INPUT_PULLUP);
}
/*The prevButtons are to help make sure only one button press is registered by saving
the previous button state*/
bool prevButton1 = false;
bool prevButton2 = true;
void loop() {
/*Get the button reads*/
bool button1 = !digitalRead(BUTTON1PIN);
bool button2 = !digitalRead(BUTTON2PIN);
delay(20);
/*If the prevButton was off and the new one is on, send a new message the to recieving
arduino*/
if ((!prevButton1 && button1) || (!prevButton2 && button2)) {
/*This is weird, but we're encoding the values of button1 and button2 as a 2 bit integer
for the receiver to unpack later:
0 -> b1 off, b2 off
1 -> b1 off, b2 on
10 (2) -> b1 on, b2 off
11 (3) -> b1 on, b2 on*/
Serial.println(((button1 << 1) | (button2)));
prevButton1 = button1;
prevButton2 = button2;
} else if (prevButton1 || prevButton2) {
prevButton1 = false;
prevButton2 = false;
}
}
/*
60-223 Intro to Physical Computing, fall 2025
Domain-specific Skill Building exercise: Transmitting Circles
A sketch for receiving the individual button presses of two buttons and increasing/decreasing the size of a displayed circle accordingly.
Pin mapping:
Arduino pin | role | details
------------------------------
SCL output 8x8 display
SDA output 8x8 display
Released to the public domain by the author, Sept 2025
Helios Gayibor
*/
/*Libraries for the display*/
/*Credit for some of the display code to: https://www.hackster.io/wrightmac/arduino-uno-and-a-8x8-led-matrix-ht16k33-backpack-43e052 */
#include <Adafruit_LEDBackpack.h>
#include "Adafruit_GFX.h"
Adafruit_8x8matrix matrix = Adafruit_8x8matrix();
int r = 1; //Initial radius
void setup() {
Serial.begin(9600);
matrix.begin(0x70); //initalizing matrix
}
void loop() {
// when there is serial data waiting to be read
while (Serial.available()) {
//This is us decoding the buttons from the original encoding we made
bool button1 = bool (Serial.parseInt() >> 1);
bool button2 = bool (Serial.parseInt() & 0x1);
//basic matrix set up
matrix.setTextSize(1);
matrix.setTextColor(LED_ON);
matrix.clear();
matrix.setCursor(0,0);
// text to print
if (button1) {
//decrease the radius if the button is pressed (up to 0)
r = max(0, r-1);
} else if (button2) {
//increase the radius if the button is pressed (up to 4)
r = min(r+1, 4);
}
Serial.println(r); //for testing
//draw the circle in the center with the new radius
matrix.drawCircle(4, 4, r, LED_ON);
// write the data out to the matrix
matrix.writeDisplay();
}
}