You are on page 1of 1

WHAT'S NEW?

 HOW TO CONTROL WS2812B INDIVIDUALLY ADDRESSABLE LEDS USING ARDUINO FOLLOW ME ON:   

Home  Tutorials  Arduino Tutorials

Arduino Tutorial 06: Processing


 Dejan Nedelkovski  Arduino Tutorials  12

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 nd
what Parts do we need for this tutorial and the Source Codes of the Examples in the video.

Arduino Tutorial 06: Processing

Components needed for this Arduino Tutorial

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

Arduino Board……………………… Amazon / Banggood / ICStation

Push Button  ……………………….. Amazon / Banggood / ICStation

LED………………………………………. Amazon / Banggood / ICStation

220 Ohm Resistor………………… Amazon / Banggood / ICStation

Breadboard and Jump Wires… Amazon / Banggood / ICStation

Circuit Schematic

Arduino Source Code

1. int led = 13;


2. int button = 12;
3.
4. void setup() {
5. pinMode(led, OUTPUT);
6. pinMode(button, INPUT);
7. Serial.begin(9600);
8. }
9.
10. void loop(){
11. if(Serial.available() > 0) {
12. char ledState = Serial.read();
13. if(ledState == '1'){
14. digitalWrite(led, HIGH);
15. }
16. if(ledState == '0'){
17. digitalWrite(led, LOW);
18. }
19. } HOME ARDUINO PROJECTS TUTORIALS  HOW IT WORKS  PROJECTS MISCELLANEOUS  
20. int buttonState = digitalRead(button);
21. if ( buttonState == HIGH){
22. Serial.println("Button is pressed");
23. delay(500);
24. }
25. }

Processing Source Code


5
Shares

1. import processing.serial.*;
2.
1 3. Serial myPort;
4. String myText="";
5.
1
6. void setup(){
7. size(300, 300);
8. myPort = new Serial(this, "COM4", 9600);
9. myPort.bufferUntil('n'); L AT E S T
10. }
11. void serialEvent (Serial myPort){
12. myText = myPort.readStringUntil('n');
13. }
14.
15. void draw(){
16. background(0,0,0);
17. text(myText, 120, 120);

 
18. myText="";
19.
20. if(mousePressed && (mouseButton == LEFT)){ 555 TIMER IC – WORKING PRINCIPLE, BLOCK
21. myPort.write('1');
22. }
DIAGRAM, CIRCUIT SCHEMATICS
23. if (mousePressed && (mouseButton == RIGHT)){  Dejan Nedelkovski
24. myPort.write('0');
25. }
26. }


JLCPCB - Prototype PCBs for $2 + Free Shipping on First Order
POPULAR
China's Largest PCB Prototype Manufacturer, 290,000+ Customers & 8,000+ Online Orders Per Day

10 PCBs Price: $2 for 2-layer, $15 for 4-layer, $74 for 6-layer
Arduino Radar Project
 Dejan Nedelkovski  333
Arduino Processing IDE Serial Communication Тutorial

Ultrasonic Sensor HC-SR04 and


Arduino Tutorial
 Dejan Nedelkovski  90
SHARE ON: Save
Tweet
Stum
How To Control a Stepper Motor with
A4988 Driver and Arduino
ARDUINO DC MOTOR CONTROL TUTORIAL – L298N | PWM CONTROL HIGH VOLTAGE DEVICES – ARDUINO RELAY  Dejan Nedelkovski  90
R E L A T E D P O S T S | H-BRIDGE TUTORIAL
CONTROL ANY ELECTRONICS WITH A TV REMOTE | Arduino TFT LCD Touch Screen
 Dejan Nedelkovski  19  Dejan Nedelkovski
ARDUINO TUTORIAL 07: MATLAB ARDUINO IR TUTORIAL Tutorial

 Dejan Nedelkovski  3  Dejan Nedelkovski  Dejan Nedelkovski  144

How I2C Communication Works and


How To Use It with Arduino

12 RESPONSES  Dejan Nedelkovski

saif alabri December 6, 2015


F O L LO W M E !
What is my port in Mac?

REPLY

Dejan Nedelkovski December 7, 2015

It should be something like /dev/cu.usbserial-1B1 for a USB board.


How To Mechatronics

REPLY

martin February 21, 2016

when i press run nothing happens ,i am running processing 3.0.2 on a windows 64 bit D I Y P R O J E C T BY C R E AT I V I T Y H E R O
machine.
all code looks okay,please help

REPLY

Dejan Nedelkovski February 22, 2016

Do you get any error message?

Arduino Based DIY Interactive LED Co ee Table


REPLY

harry March 2, 2016

The Circuit Schematic picture is not right ground from components is not t to the
ground line!

REPLY

Dejan Nedelkovski March 3, 2016

Yea it has a little error, but it’s intuitive because the lines for the
ground are black, so you can’t miss them.

REPLY

Alexandros - Athens March 6, 2016

Good Work
its very helpful to me
Thank You

Alexandros

REPLY

Dejan Nedelkovski March 7, 2016

Thanks! Nice to hear that!

REPLY

Anggi April 29, 2016

can i use it with arduino uno ?

REPLY

Dejan Nedelkovski May 2, 2016

Sure you can.

REPLY

Estelle G October 12, 2016

I’m trying to get the wiring correct. I’m following the picture you have up here, and the
coding works. There’s no errors, but nothing happens to the LED when I click or press the
button. In your video you have two resistors? but in the picture there’s only one
resistors. I I can’t see the video to clearly with wiring at an angle. Can you help me?
Maybe put another picture of wiring.

REPLY

Dejan Nedelkovski October 14, 2016

One of the resistors is for the button and the second one is for the
LED (the one missing on the circuit schematics). Please doubly check
your connections. Also check whether you are getting any data on the
Arduino serial monitor before sending it to Processing (whether the
button is working).

REPLY

L E A V E A R E P LY

Your email address will not be published.

Comment

Name* Email*

Website

S U B MIT

H O W T O M E C H AT R O N I C S F O L L O W H O W T O M E C H AT R O N I C S O N DISCLOSURE

SOCIAL MEDIA
HowToMechatronics is an education website in the HowToMechatronics is a participant in the Amazon
area of Mechanical, Electrical and Computer Services LLC Associates Program, an a liate
Engineering. Tutorials, Tips, Tricks, How It Works, advertising program designed to provide a means
Projects, Examples, Source Codes, Download les for sites to earn advertising fees by advertising and
and much more can be found here. linking to Amazon.com

Copyright © 2018 HowToMechatronics.com. All rights


reserved. Terms and Conditions

You might also like