Guides · 9 min read

Processing Arduino Serial: Live Graphs, Gauges and Buttons

Processing Arduino serial tutorial: read sensor data, draw a live temperature graph and gauge, send LED commands, fix port errors, radar screen and ESP32.

Using Processing with Arduino turns the numbers your board sends over the serial port into live graphs, needle gauges and clickable buttons on your computer screen. Processing is a free, Java-based programming environment made for artists and students; the clean interface and setup() structure of the Arduino IDE were inspired by it in the first place. So if you can write Arduino code, you will have no trouble reading Processing code. The Arduino sends data with Serial.println(), and Processing reads those lines with its built-in Serial library and redraws the window 60 times per second.

In this guide you'll first see how the two programs talk over USB and which data format and baud rate to pick. Then we'll take the values from an Arduino Uno with a potentiometer, an LDR and an LM35 and show them in a single Processing window as a temperature graph, a gauge and an LED button. After that we'll draw a radar screen, fix port selection problems on Windows, macOS and Linux, and repeat the same workflow with an ESP32.

Arduino Uno board sending serial data to Processing
The Arduino Uno uses the same serial port over its USB cable both for uploading code and for sending data to Processing.

What is Processing and how does it talk to an Arduino?

A Processing program (sketch) has two main functions: setup(), which runs once, and draw(), which repeats about 60 times per second. draw() is the counterpart of Arduino's loop(), except that it redraws the screen on every pass. On the communication side, the Arduino's USB-serial converter creates a virtual serial port on your computer (COM3 on Windows, /dev/cu.usbmodem… on macOS, /dev/ttyACM0 on Linux and so on). Processing's processing.serial library opens that port, buffers the incoming bytes and calls serialEvent() when a newline arrives. Both sides therefore follow the same rules: the same baud rate, the same separator and a newline at the end of every message.

TaskArduino sideProcessing side
One-time setupsetup()setup() (size() on the first line)
Repeating looploop()draw() (~60 frames per second)
Open the portSerial.begin(9600)new Serial(this, portName, 9600)
Send dataSerial.println(value)port.write("LED:1\n")
Read dataSerial.available() + Serial.read()bufferUntil('\n') + serialEvent()
Scale a valuemap(x, 0, 1023, 0, 100) (integer)map(x, 0, 100, 0, 300) (float)

Setup: Processing and the Serial library

  1. Download Processing 4 for your operating system from the official Processing website and open it; no extra driver or setting is needed.
  2. The Serial library ships with Processing. You don't need to install anything; just put import processing.serial.*; at the top of your sketch.
  3. Connect the Arduino over USB and note which port it shows up on in the Arduino IDE (Tools > Port).
  4. Run printArray(Serial.list()); in Processing; the console prints a port list numbered [0], [1] and so on. Use the number at which your Arduino's port appears.
  5. Close the Serial Monitor and Serial Plotter in the Arduino IDE, then start the Processing sketch with the Run button.
Only one program can open a serial port at a time. If the Arduino IDE Serial Monitor is open, Processing throws a Port busy error; the other way round, uploading to the Arduino fails while Processing is running. Stop the Processing sketch before uploading code.

How to choose the data format and baud rate

A serial port only carries a stream of bytes; you decide where one message ends and the next begins. For beginners the most robust approach is to send each round of readings as a single line of text with the values separated by commas, such as 42,63,23.5. Processing receives the line with readStringUntil('\n'), strips the trailing \r with trim() and splits it with split(). If the number of parts is not what you expect, you simply skip the line, so a half line arriving while the port opens can't crash the program. Binary transfer is faster, but byte order and synchronisation bugs are hard to debug; below a few hundred readings per second, plain text is all you need.

FormatExample lineAdvantageDrawback
Single value512Simplest; also works with the Serial PlotterCarries only one sensor
CSV (comma-separated)42,63,23.5Few bytes, easy split()If the order gets mixed up, values swap places
Labelledpot:42;light:63Readable, order doesn't matterLonger lines, more parsing code
Binary0x2A 0x3F …Fastest, fixed lengthHard to synchronise and debug

The baud rate is the number of bits per second. Because the serial protocol sends 10 bits per byte including the start and stop bits, you get roughly baud / 10 bytes per second. The line 42,63,23.5 takes 12 bytes with its line-ending characters, so at 9600 baud at most about 80 lines per second get through. Since Processing draws 60 frames per second anyway, 9600 is enough for most graphing projects; pick 115200 for fast accelerometer data or many channels. Whatever rate you choose, Serial.begin() on the Arduino and new Serial() in Processing must use the same value.

BaudApprox. bytes/s12-byte lines/sWhen to use
9600960~80Slowly changing values such as temperature, light, potentiometer
576005,760~480A few sensors, 50–100 readings per second
11520011,520~960ESP32 default, accelerometers and fast graphs
25000025,000~2,080Error-free on the Uno (divides 16 MHz exactly), high-speed logging

Wiring: potentiometer, LDR, LM35 and LED

PartArduino UnoESP32Note
Potentiometer wiperA0GPIO 34Outer legs to 5 V (3V3 on the ESP32) and GND
LDR + 10 kΩ voltage dividerA1GPIO 35LDR between supply and pin, 10 kΩ between pin and GND
LM35 output (middle leg)A2GPIO 32The LM35 needs at least 4 V; on the ESP32 power it from VIN (5 V), the output stays below 1.5 V
LED (with 220 Ω resistor)D9 (PWM)GPIO 2Long leg to the resistor, short leg to GND
GNDGNDGNDAll parts share a common ground

Wired this way, the LDR's resistance drops as the room gets brighter, the voltage on A1 rises and the reading goes up. You can work out the divider with the voltage divider tool and check the LED resistor in the LED resistor calculation guide. The LM35 outputs 10 mV per degree Celsius; with the Uno's 5 V reference one ADC step is about 4.9 mV, or 0.49 °C. For finer resolution you can switch to the 1.1 V reference with analogReference(INTERNAL) and change the formula to 110.0 / 1023.0; the range is then limited to 110 °C, but the step drops to 0.1 °C.

Arduino code: send CSV, receive commands

The code below converts the potentiometer and the LDR to percentages every 100 milliseconds, calculates the temperature from the LM35 and sends the three values on one line. At the same time it collects incoming characters in a 16-byte buffer and executes the command when a newline arrives. Because it doesn't use delay(), commands are applied without lag. After uploading, open the Serial Monitor at 9600 baud and make sure you see lines like 42,63,23.5, then close the Serial Monitor. From Processing, LED:1 turns the LED on, LED:0 turns it off and commands from PWM:0 to PWM:255 set the brightness; unknown lines are ignored, so the program never locks up.

C++ (Arduino IDE)
1// Arduino Uno -> Processing: pot, ışık, sıcaklık CSV + LED komutları / CSV data + LED commands
2const int POT_PIN  = A0;   // potansiyometre orta bacak / potentiometer wiper
3const int LDR_PIN  = A1;   // LDR + 10 kΩ gerilim bölücü / LDR + 10 kΩ divider
4const int LM35_PIN = A2;   // LM35 çıkışı / LM35 output
5const int LED_PIN  = 9;    // PWM destekli pin / PWM capable pin
6
7const unsigned long SEND_MS = 100;   // 10 satır/sn / 10 lines per second
8unsigned long lastSend = 0;
9char cmd[16];                        // gelen komut tamponu / incoming command buffer
10byte cmdLen = 0;
11
12void setup() {
13  Serial.begin(9600);                // Processing'deki BAUD ile aynı / same as BAUD in Processing
14  pinMode(LED_PIN, OUTPUT);
15}
16
17void handleCommand(const char* c) {
18  if (strcmp(c, "LED:1") == 0) analogWrite(LED_PIN, 255);        // LED tam açık / LED fully on
19  else if (strcmp(c, "LED:0") == 0) analogWrite(LED_PIN, 0);     // LED kapalı / LED off
20  else if (strncmp(c, "PWM:", 4) == 0) {                         // parlaklık 0-255 / brightness 0-255
21    analogWrite(LED_PIN, constrain(atoi(c + 4), 0, 255));
22  }
23}
24
25void readCommands() {
26  while (Serial.available() > 0) {
27    char ch = Serial.read();
28    if (ch == '\r') continue;                // CR karakterini yok say / ignore CR
29    if (ch == '\n') {                        // satır bitti / line complete
30      cmd[cmdLen] = '\0';
31      handleCommand(cmd);
32      cmdLen = 0;
33    } else if (cmdLen < sizeof(cmd) - 1) {
34      cmd[cmdLen++] = ch;                    // tampona ekle / append to buffer
35    }
36  }
37}
38
39void loop() {
40  readCommands();
41  if (millis() - lastSend >= SEND_MS) {
42    lastSend = millis();
43    int pot   = map(analogRead(POT_PIN), 0, 1023, 0, 100);    // yüzde / percent
44    int light = map(analogRead(LDR_PIN), 0, 1023, 0, 100);    // yüzde / percent
45    float tempC = analogRead(LM35_PIN) * (500.0 / 1023.0);    // 10 mV/°C, 5 V referans / reference
46    Serial.print(pot);   Serial.print(',');
47    Serial.print(light); Serial.print(',');
48    Serial.println(tempC, 1);                                  // örnek / example: 42,63,23.5
49  }
50}
51

Processing code: live temperature graph, gauge and button

The Processing side has three parts: the line graph on the left shows the last 300 temperature readings (30 seconds at 10 Hz) and prints the minimum and maximum; the half-circle gauge on the right shows the potentiometer percentage with a needle; the button below it sends LED:1 or LED:0 to the Arduino each time you click it. Press the keys 0–9 and the LED brightness changes in ten steps via the PWM command. Paste the code into Processing, set PORT_INDEX according to the list in the console and run it.

Code
1// Processing 4: Arduino -> canlı sıcaklık grafiği + gösterge + LED butonu / live temperature graph + gauge + LED button
2import processing.serial.*;
3
4Serial port;                                  // seri port nesnesi / serial port object
5final int PORT_INDEX = 0;                     // printArray(Serial.list()) sırası / index in the port list
6final int BAUD = 9600;                        // Arduino ile aynı (ESP32: 115200) / same as the board
7
8volatile float pot = 0, light = 0, temp = 0;  // son ölçümler / latest readings
9volatile boolean newData = false;             // yeni satır geldi mi / did a new line arrive?
10float[] history = new float[300];             // son 300 sıcaklık / last 300 temperatures
11int filled = 0;                               // dolu eleman sayısı / samples stored
12float minT = 999, maxT = -999;
13boolean ledOn = false;
14
15void setup() {
16  size(900, 500);
17  printArray(Serial.list());                  // portları konsola yaz / print available ports
18  if (Serial.list().length <= PORT_INDEX) {
19    println("Port bulunamadi / serial port not found");
20    exit();
21    return;
22  }
23  port = new Serial(this, Serial.list()[PORT_INDEX], BAUD);
24  port.clear();                               // eski baytları at / drop stale bytes
25  port.bufferUntil('\n');                     // her satırda serialEvent / serialEvent once per line
26}
27
28void serialEvent(Serial p) {
29  String line = p.readStringUntil('\n');
30  if (line == null) return;
31  String[] parts = split(trim(line), ',');    // "42,63,23.5" -> 3 parça / 3 parts
32  if (parts.length != 3) return;              // yarım satırı atla / skip partial lines
33  float a = parseFloat(parts[0]);
34  float b = parseFloat(parts[1]);
35  float c = parseFloat(parts[2]);
36  if (Float.isNaN(a) || Float.isNaN(b) || Float.isNaN(c)) return;
37  pot = a;
38  light = b;
39  temp = c;
40  newData = true;                             // çizimi draw() yapar / draw() does the drawing
41}
42
43void draw() {
44  background(18, 24, 32);
45  if (newData) {
46    addSample(temp);
47    newData = false;
48  }
49  drawGraph(60, 40, 520, 320);
50  drawGauge(740, 230, 130, pot);
51  drawButton();
52  fill(230);
53  textSize(16);
54  textAlign(LEFT);
55  text("Sicaklik / Temp: " + nf(temp, 0, 1) + " C", 60, 400);
56  text("Isik / Light: " + nf(light, 0, 0) + " %", 60, 425);
57  if (filled > 0) text("Min " + nf(minT, 0, 1) + " C   Max " + nf(maxT, 0, 1) + " C", 60, 450);
58}
59
60void addSample(float v) {
61  for (int i = 0; i < history.length - 1; i++) history[i] = history[i + 1];  // sola kaydır / shift left
62  history[history.length - 1] = v;
63  if (filled < history.length) filled++;
64  minT = min(minT, v);
65  maxT = max(maxT, v);
66}
67
68void drawGraph(float x, float y, float w, float h) {
69  strokeWeight(1);
70  textSize(12);
71  textAlign(RIGHT);
72  for (int t = 0; t <= 50; t += 10) {         // 0-50 C ızgara / grid
73    float gy = map(t, 0, 50, y + h, y);
74    stroke(60, 70, 85);
75    line(x, gy, x + w, gy);
76    fill(150);
77    text(t + " C", x - 6, gy + 4);
78  }
79  noFill();
80  stroke(255, 140, 60);
81  strokeWeight(2);
82  beginShape();
83  for (int i = history.length - filled; i < history.length; i++) {
84    float px = map(i, 0, history.length - 1, x, x + w);
85    float py = map(constrain(history[i], 0, 50), 0, 50, y + h, y);
86    vertex(px, py);
87  }
88  endShape();
89}
90
91void drawGauge(float cx, float cy, float r, float value) {
92  noFill();
93  strokeWeight(14);
94  stroke(60, 70, 85);
95  arc(cx, cy, r * 2, r * 2, PI, TWO_PI);                        // yarım daire / half circle
96  float a = map(constrain(value, 0, 100), 0, 100, PI, TWO_PI);  // yüzde -> açı / percent -> angle
97  stroke(80, 200, 255);
98  arc(cx, cy, r * 2, r * 2, PI, a);                             // dolu kısım / filled part
99  strokeWeight(4);
100  stroke(240);
101  line(cx, cy, cx + cos(a) * r * 0.8, cy + sin(a) * r * 0.8);   // ibre / needle
102  noStroke();
103  fill(240);
104  textAlign(CENTER);
105  textSize(28);
106  text(nf(value, 0, 0) + " %", cx, cy + 40);
107}
108
109void drawButton() {
110  noStroke();
111  if (ledOn) fill(60, 190, 110);
112  else fill(90, 95, 110);
113  rect(660, 380, 160, 50, 10);
114  fill(255);
115  textAlign(CENTER);
116  textSize(18);
117  text(ledOn ? "LED ON" : "LED OFF", 740, 411);
118}
119
120void mousePressed() {
121  if (port == null) return;
122  if (mouseX > 660 && mouseX < 820 && mouseY > 380 && mouseY < 430) {
123    ledOn = !ledOn;
124    port.write(ledOn ? "LED:1\n" : "LED:0\n");  // satır sonu şart / newline is required
125  }
126}
127
128void keyPressed() {
129  if (port == null) return;
130  if (key >= '0' && key <= '9') {
131    int pwm = (key - '0') * 255 / 9;            // 0-9 tuşu -> 0-255 / key 0-9 -> 0-255
132    port.write("PWM:" + pwm + "\n");
133  }
134}
135

One important detail: serialEvent() runs on a separate thread, so you don't draw inside it. The function only stores the incoming values in variables and raises the newData flag; when draw() sees the flag, it adds the reading to the graph. For the graph, map() converts the temperature from the 0–50 °C range to a pixel height, and for the gauge the same function turns the 0–100 percentage into an angle between PI and TWO_PI. In Processing's screen coordinates the y axis grows downwards, so high values correspond to small y; that's why the target range of map() runs from y + h to y.

To save the graph, bind saveFrame("graph-####.png") to a key, and write the readings to a CSV file with createWriter(). To analyse the data as a table, see the Arduino to Excel data export guide, and to do the same job in Python, read the Arduino Python serial communication article.

Port selection problems and fixes

SystemPort name exampleCommon problemFix
WindowsCOM3, COM4The list order can change every time you plug inWrite the port name directly as "COM3" or check Device Manager
macOS/dev/cu.usbmodem14101, /dev/cu.usbserial-110Each port appears twice, as tty and cuPick the one starting with cu; install the CH340 driver for clone boards
Linux/dev/ttyACM0, /dev/ttyUSB0Permission denied errorAdd your user to the dialout group, then log out and back in
All-Serial.list() is empty, ArrayIndexOutOfBounds errorBoard not connected, charge-only cable or missing driver
All-Port busyThe Serial Monitor, Serial Plotter or another sketch holds the port; close it

Selecting the port by name is more reliable than trusting the list order: search Serial.list() for an entry containing usbmodem, usbserial or COM and open that one. Then there's the auto-reset: when Processing opens the port, the DTR line toggles and the Arduino Uno restarts. The bootloader waits about 1–2 seconds, no data arrives during that time and the first line may be incomplete; that's exactly why the code checks the number of parts. If the port doesn't show up at all on a clone board, the driver is the likely culprit; the CH340 driver installation guide walks you through it.

Radar screen example: servo and HC-SR04

One of the most popular Processing examples is the sonar radar screen. An SG90 servo sweeps an HC-SR04 sensor through a half circle, and the Arduino sends a line in the form angle,distance at every step (e.g. 90,34). The Arduino code, the wiring (servo D9, Trig D10, Echo D11) and the assembly are ready in the Arduino radar project article; the screen there leaves a fading trail. The version below instead stores the last distance for each angle, so as the sweep goes on, a rough map of the room appears as red dots; the c key clears the map.

Code
1// Processing 4: oda haritası çizen radar ekranı / radar screen that keeps a map of the room
2// Arduino tarafı "açı,mesafe" satırı gönderir / the Arduino sends "angle,distance" lines
3import processing.serial.*;
4
5Serial port;
6final int BAUD = 9600;
7final float MAX_CM = 60;                      // ekranın kapsadığı mesafe / range shown on screen
8volatile int angle = 0;                       // son açı / last angle
9volatile int distance = 0;                    // son mesafe (cm) / last distance (cm)
10int[] hits = new int[181];                    // her açı için son mesafe / last distance per angle
11
12void setup() {
13  size(1000, 560);
14  String[] ports = Serial.list();
15  if (ports.length == 0) {
16    println("Port bulunamadi / serial port not found");
17    exit();
18    return;
19  }
20  port = new Serial(this, ports[0], BAUD);    // gerekirse [1] ya da "COM4" / use [1] or "COM4" if needed
21  port.bufferUntil('\n');
22}
23
24void serialEvent(Serial p) {
25  String line = p.readStringUntil('\n');
26  if (line == null) return;
27  String[] parts = split(trim(line), ',');
28  if (parts.length != 2) return;
29  int a = parseInt(parts[0], -1);             // sayı değilse -1 / -1 if not a number
30  int d = parseInt(parts[1], -1);
31  if (a < 0 || a > 180 || d < 0) return;
32  hits[a] = d;                                // 0 = yankı yok / 0 = no echo
33  angle = a;
34  distance = d;
35}
36
37void draw() {
38  background(0, 20, 0);
39  translate(width / 2, height - 50);          // merkez alt ortada / origin at the bottom centre
40  float r = width * 0.45;                     // radar yarıçapı (piksel) / radar radius (pixels)
41  noFill();
42  strokeWeight(1.5);
43  stroke(40, 200, 80);
44  for (int i = 1; i <= 4; i++) arc(0, 0, r * i / 2, r * i / 2, PI, TWO_PI);   // mesafe yayları / range arcs
45  for (int a = 30; a <= 150; a += 30) line(0, 0, r * cos(radians(a)), -r * sin(radians(a)));
46  noStroke();
47  fill(255, 70, 70);
48  for (int a = 0; a <= 180; a++) {            // kayıtlı engeller / stored obstacles
49    if (hits[a] > 0 && hits[a] <= MAX_CM) {
50      float d = map(hits[a], 0, MAX_CM, 0, r);
51      ellipse(d * cos(radians(a)), -d * sin(radians(a)), 8, 8);
52    }
53  }
54  strokeWeight(3);
55  stroke(90, 255, 130);
56  line(0, 0, r * cos(radians(angle)), -r * sin(radians(angle)));  // tarama çizgisi / sweep line
57  fill(200, 255, 200);
58  textSize(18);
59  text("Angle: " + angle + "   Distance: " + distance + " cm", -r, 35);
60}
61
62void keyPressed() {
63  if (key == 'c') hits = new int[181];        // c tuşu haritayı siler / c clears the map
64}
65

In the radar code, translate() moves the origin to the bottom centre of the window. The position of a point comes from simple trigonometry: x = distance × cos(angle), y = −distance × sin(angle). The minus sign again comes from the screen's y axis growing downwards. MAX_CM is the range covered by the screen; although the HC-SR04 measures up to about 4 metres, a value between 60 cm and 2 m gives a more readable picture indoors. For more about the sensor, see the HC-SR04 distance sensor guide.

The same workflow with an ESP32

On the Processing side, the only thing that changes for an ESP32 is the baud rate: set BAUD to 115200. On the board side there are three differences. First, the ESP32's ADC is 12-bit, so analogRead() returns 0–4095 and the map() range changes accordingly. Second, the pins are 3.3 V; power the potentiometer and the LDR divider from 3V3, because 5 V can damage the pin. Third, the ADC2 pins don't work while Wi-Fi is on; the ADC1 pins GPIO 32–39 are the safe choice. For the LM35, analogReadMilliVolts() returns a calibrated millivolt value, and dividing by 10 gives °C directly. Since we still send percentages and °C, the rest of the Processing code stays untouched. If you want it wireless, Processing's processing.net library can connect to a TCP server the ESP32 opens over Wi-Fi; as long as the line format stays the same, the parsing code doesn't change.

C++ (Arduino IDE)
1// ESP32 -> Processing: aynı CSV formatı, 115200 baud / same CSV format, 115200 baud
2const int POT_PIN  = 34;   // ADC1, yalnız giriş / input only
3const int LDR_PIN  = 35;   // ADC1, yalnız giriş / input only
4const int LM35_PIN = 32;   // ADC1 (Wi-Fi açıkken de çalışır / works with Wi-Fi on)
5const int LED_PIN  = 2;    // çoğu kartta dahili LED / onboard LED on most boards
6
7const unsigned long SEND_MS = 100;
8unsigned long lastSend = 0;
9String cmd;                // gelen komut / incoming command
10
11void setup() {
12  Serial.begin(115200);    // Processing'de BAUD = 115200 yap / set BAUD = 115200 in Processing
13  pinMode(LED_PIN, OUTPUT);
14  analogReadResolution(12);  // 0-4095
15}
16
17void handleCommand(const String& c) {
18  if (c == "LED:1") analogWrite(LED_PIN, 255);
19  else if (c == "LED:0") analogWrite(LED_PIN, 0);
20  else if (c.startsWith("PWM:")) analogWrite(LED_PIN, constrain(c.substring(4).toInt(), 0, 255));
21}
22
23void loop() {
24  while (Serial.available() > 0) {
25    char ch = Serial.read();
26    if (ch == '\n') {                  // satır bitti / line complete
27      cmd.trim();                      // \r ve boşlukları sil / strip \r and spaces
28      handleCommand(cmd);
29      cmd = "";
30    } else if (cmd.length() < 16) {
31      cmd += ch;
32    }
33  }
34  if (millis() - lastSend >= SEND_MS) {
35    lastSend = millis();
36    int pot   = map(analogRead(POT_PIN), 0, 4095, 0, 100);   // 12 bit -> yüzde / percent
37    int light = map(analogRead(LDR_PIN), 0, 4095, 0, 100);
38    float tempC = analogReadMilliVolts(LM35_PIN) / 10.0;     // kalibre mV, 10 mV/°C / calibrated mV
39    Serial.print(pot);   Serial.print(',');
40    Serial.print(light); Serial.print(',');
41    Serial.println(tempC, 1);
42  }
43}
44

Processing and Arduino project ideas

  • Distance display: turn the HC-SR04 reading into a big bar graph with a colour-changing warning.
  • 3D cube: show the MPU6050 angles as a rotating box in Processing's P3D mode.
  • Joystick game: steer a ball on screen with the X and Y values of a joystick module.
  • Light logger: plot the light level over the day with an LDR and save it to a CSV file.
  • Multi-room temperature panel: follow each room as a line in its own colour with DS18B20 sensors.

Common mistakes and fixes

SymptomLikely causeFix
The window opens but the graph doesn't moveWrong port selectedCheck the printArray(Serial.list()) output and fix PORT_INDEX
Garbage characters in the consoleBaud rates don't matchSerial.begin() and new Serial() must use the same number
Values are NaN or never arriveTrailing \r or a half lineUse trim() and check the number of parts
The button clicks but the LED stays offThe command has no newlineAdd \n to the end of the text you send with write()
Values arrive later and laterThe Arduino sends too often, the buffer fills upUse a 50–100 ms send interval or raise the baud rate
The Arduino restarts when Processing startsAuto-reset via DTRThat's normal; wait 2 seconds and skip half lines

If you want to test the sensors one by one before connecting Processing, the BlueGrays app has projects such as reading light intensity with an LDR, measuring distance with an HC-SR04 and controlling a servo with a potentiometer, each with a circuit diagram and ready-made code; once the serial values look right, opening the Processing window takes just a few minutes.

Frequently asked questions

Is Processing free?

Yes. Processing is open source and completely free, with versions for Windows, macOS and Linux. You can download it from the official website and have it running in a few minutes. The Serial library comes with the program.

What is the difference between Processing and the Arduino IDE?

The Arduino IDE compiles code and uploads it to the microcontroller, while Processing is for writing programs that run on your computer and draw on the screen. Because the Arduino IDE's interface and setup() structure derive from Processing, the two look very similar. In a typical project the Arduino measures and sends, and Processing reads and visualises.

Why can't Processing find my Arduino port?

The most common reason is that the Arduino IDE Serial Monitor is holding the port open. If the board isn't plugged in, the cable is charge-only or the CH340 driver of a clone board is missing, Serial.list() returns an empty list. Print the list with printArray(Serial.list()) and use the right index or port name.

How do I send data from Processing to Arduino?

With the write() function of the Serial object. For example, port.write("LED:1\n") sends the text plus a newline; on the Arduino you collect the characters with Serial.read() and run the command when the newline arrives. For single-character commands, port.write('1') is enough.

Can I use the Arduino Serial Plotter instead of Processing?

For a simple line graph, yes; the Serial Plotter automatically plots numbers separated by commas or spaces. For custom interfaces such as gauges, buttons, a radar screen or logging to a file you need a program like Processing. The two can't use the same port at the same time.

Does Processing work with an ESP32?

Yes. The ESP32 also shows up as a serial port over USB, so the same Serial library works; usually you only need to set the baud rate to 115200. You can also open a TCP connection over Wi-Fi with the processing.net library.

See all projects
Measuring Light Intensity with an LDR
AR-11Beginner

Measuring Light Intensity with an LDR

Want to see how bright your room is as a number? The LDR, a small part that reacts to light, measures the light around it, and the Arduino writes the value to your computer screen every half second.

4.5(86)
154
HC-SR04 Distance Measurement (Serial Display)
AR-27Beginner

HC-SR04 Distance Measurement (Serial Display)

The HC-SR04 sensor works just like a bat finding its way in the dark: it sends out a sound you cannot hear, listens for the echo and measures how far away the object in front of it is.

4.6(52)
94
Temperature and Humidity with DHT11
AR-55Intermediate

Temperature and Humidity with DHT11

How warm is your room, and is the air humid or dry? The DHT11 sensor measures temperature and humidity, and the Arduino writes the values on a two-line LCD screen, refreshing every couple of seconds.

4.7(47)
96
Reading Light Intensity with the ESP32 LDR Module
ES-11Beginner

Reading Light Intensity with the ESP32 LDR Module

Real-time monitoring of the LDR module's raw ADC value and relative light percentage calculated from dark and light reference values in the Serial Monitor. This percentage is not a lux measurement. Teaches the module’s calibration logic. It is ideal to complete this before Project 10, as it is used to determine the threshold value.

4.6(36)
56
Servo Motor Operation with Potentiometer
AR-36Beginner
Premium

Servo Motor Operation with Potentiometer

As you turn the potentiometer knob, the servo motor's arm turns right along with it: one end of the knob means zero degrees, the other end means half a turn.

4.6(37)
54
ESP32 HC-SR04 Ultrasonic Distance Sensor
ES-14Intermediate

ESP32 HC-SR04 Ultrasonic Distance Sensor

The HC-SR04 ultrasonic sensor measures distance by timing how long its sound pulse takes to bounce off an object and return (time of flight). In this project the ESP32 sends a 10-microsecond pulse to the TRIG pin and reads the echo time from the ECHO pin with pulseIn(). The distance is shown in cm on a 16x2 I2C LCD. The HC-SR04 runs on 5V, so the ECHO pin needs a voltage divider, or the ESP32's 3.3V GPIO gets damaged.

4.9(29)
51
ESP32 LED Brightness Control with a Potentiometer (Analog → PWM)
ES-13Intermediate
Premium

ESP32 LED Brightness Control with a Potentiometer (Analog → PWM)

In this project, we control the brightness of an LED analogically using a potentiometer. The ESP32's ADC pin reads the 0-3.3V voltage from the potentiometer, and this value is then converted into a PWM (Pulse Width Modulation) signal and sent to the LED. As a result, as you turn the potentiometer, the LED gradually brightens and dims. With Arduino Core 3.0+, analogWrite() can be used directly; on the ESP32-S2/S3, the ADC resolution is fixed at 12-bit.

4.4(20)
32
Temperature Measurement with NTC and 2x16 Lcd Display
AR-44Beginner
Premium

Temperature Measurement with NTC and 2x16 Lcd Display

Measure the temperature around you with a sensor that looks like a tiny bead. This part, called an NTC, lets electricity through more easily as it warms up; the Arduino reads that change, turns it…

4.5(33)
44