Industrial manufacturing
Industrial Internet of Things | Industrial materials | Equipment Maintenance and Repair | Industrial programming |
home  MfgRobots >> Industrial manufacturing >  >> Manufacturing Technology >> Manufacturing process

Arduino Tutorial 06: Connecting Arduino to Processing via Serial Communication

Welcome to the sixth Arduino Tutorial from our Arduino Tutorial Series. In this tutorial we will learn how to connect Arduino to Processing and how are they communicatng using the Serial Port. Also we will make an example where we will use the Processing IDE to send commands to the Arduino Board and vice-verse.

This is a Step by Step Video Tutorial which is easy to be followed. Also, below the video you can find what Parts do we need for this tutorial and the Source Codes of the Examples in the video.

Components needed for this Arduino Tutorial


You can get the components from any of the sites below:

  • Arduino Board ……………………………
  • Breadboard and Jump Wires ……… 
  • LED ……………………………………………
  • 220 Ohm Resistor ……………………..
  • Push Button ………………………………

Circuit Schematic


Arduino Tutorial 06: Connecting Arduino to Processing via Serial Communication

Arduino Source Code


int led = 13;
int button = 12;

void setup() {
pinMode(led, OUTPUT);
pinMode(button, INPUT);
Serial.begin(9600);
}

void loop(){
if(Serial.available() > 0) {
char ledState = Serial.read();
if(ledState == '1'){
digitalWrite(led, HIGH);
}
if(ledState == '0'){
digitalWrite(led, LOW);
}
}
int buttonState = digitalRead(button);
if ( buttonState == HIGH){
Serial.println("Button is pressed");
delay(500);
}
}Code language: Arduino (arduino)

Processing Source Code


import processing.serial.*;

Serial myPort;
String myText="";

void setup(){
size(300, 300);
myPort = new Serial(this, "COM4", 9600);
myPort.bufferUntil('n');
}
void serialEvent (Serial myPort){
myText = myPort.readStringUntil('n');
}

void draw(){
background(0,0,0);
text(myText, 120, 120);
myText="";

if(mousePressed && (mouseButton == LEFT)){
myPort.write('1');
}
if (mousePressed && (mouseButton == RIGHT)){
myPort.write('0');
}
}Code language: Arduino (arduino)

Manufacturing process

  1. Create a Secure Arduino RFID Lock – Step‑by‑Step Guide
  2. Arduino Nano Fingerprint Sensor Project – Step‑by‑Step Tutorial
  3. Build a Mini Piano with Arduino UNO – Step-by-Step Tutorial
  4. Master Arduino Multithreading with Protothreading: A Step‑by‑Step Tutorial
  5. Master Arduino Control with MATLAB GUI: Step-by-Step Tutorial
  6. Master Arduino & MATLAB Integration: Step‑by‑Step Serial Communication Tutorial
  7. Master Serial Communication with Arduino – Step-by-Step Video Guide
  8. Mastering Arduino Analog Inputs: A Step‑by‑Step Video Guide
  9. Master DC & Servo Motor Control with Arduino – Step-by-Step Tutorial
  10. Arduino Beginner Tutorial 01: Get Started with Your First Project