SlideShare ist ein Scribd-Unternehmen logo
1 von 8
Processing is an open source programming language and
environment for people who want to create images,
animations, and interactions.
Processing can interact with Arduino using serial
communication.
Processing (www.processing.org) is complementary to Arduino,
because the languages and IDEs are so similar.
Processing programs are called sketches
http://www.processing.org and download the
appropriate version for your OS of your choice.
PROCESSING & ARDUINO PAU 2016
Arduino IDE was based on the Processing IDE
PROCESSING & ARDUINO PAU 2016
Structure of a Processing Sketch: example
int timer;
void setup() {
// The next function sets the size of the sketch
size(800,600);
/*
This is a multiline comment, anything written between the two multiline commment
delimiters will be ignored by the compiler.
*/
}
void draw() {
background(255);
ellipse(timer, height/2, 30, 30);
timer = timer + 1;
}
setup() Function
draw() Function
will run as a loop until the program is terminated by the
user.
PROCESSING & ARDUINO PAU 2016
Processing IDE
We are going to draw a circle on
screen that will move to the right
of the screen as time passes.
Background() function i s necessary to clear
the frame with a color at every iteration. If
we comment it out (temporarily remove it
by adding // to the beginning of the line),
we will see that the circles are drawn on
top of the previous ones.
Press the Run button
PROCESSING &
ARDUINO
PAU 2016
The following simple sketch in processing reads the mouse position and
sends data (‘1’ or ‘0’) to the arduino board by serial port. The yellow
LED connected on pin 13 is on or off depending of the position of the
mouse in the rectangle.
void setup() {
Serial.begin(9600);
pinMode(13, OUTPUT);
}
void loop(){
if (Serial.available()>0) {
byte input=Serial.read();
if(input == '1'){
digitalWrite(13, HIGH);
}else{
digitalWrite(13, LOW);
}
}
}
Scketch for Arduino
on_off_LED_da_mouse_ino
import processing.serial.*;
Serial myPort;
void setup()
{
size(255, 255);
//String portName = Serial.list()[0];
myPort = new Serial(this, "com4", 9600);
}
void draw() {
noStroke();
rect(0,0,width/2,height);
if (mouseX>width/2) {
myPort.write('1');
}
else {
myPort.write('0');
}
}
Scketch for processing
on_off_LED_da_mouse
PROCESSING & ARDUINO PAU 2016
ARDUINO_PWM in
processing_Example_libraries_Arduino(firmata)_arduino_pwm
Demonstrates the control of analog output (PWM) pins of an Arduino board
running the StandardFirmata firmware. Moving the mouse horizontally across
the sketch changes the output on pins 9 (value is proportional to the mouse
X coordinate) and 11 (inversely porportional to mouse X).
ARDUINO_OUTPUT in
processing_Example_libraries_Arduino(firmata)_arduino_output
Demonstrates the control of digital pins of an Arduino board running the
StandardFirmata firmware. Clicking the squares toggles the corresponding
digital pin of the Arduino.
Su arduino occorre caricare Standardfirmata da
esempi_firmata_standardfirmata
Using the Arduino software, upload the StandardFirmata example (located
in Examples > Firmata > StandardFirmata) to your Arduino board.
PROCESSING & ARDUINO PAU 2016
1. we import the Serial library and declare a global Serial object
2. Arduino and Processing communicate at the same rate by ”com 4”
3. In our draw() loop, we send whatever we want over the serial port by using the “write method” from the
Processing Serial library.
4. For this sketch, we will send a ‘1’ or a ‘ 0’ whenever we click our mouse in the Processing window
5. nostroke() disabilita il contorno
6. size() create a window
7. List all the available serial port
8. background(0) put up a black background
9. if (myPort.available() > 0) Read the serial port.
10. String PortName…. /* On some computers, Arduino will usually be connected to the first serial
port. If not, change the 0 to the correct one (examine the output of the previous line of code to figure
out which one to use). */
11. rect(0,0, width/2,heigth) 0,0 coordinates, width of the size and heigth of the size
12. Ellipse (x,y, larghezza, altezza) x a partire da sinistra ed y a partire dall’alto
13.strokeWeigth(20) spessore del contorno a 20 pixel

Weitere ähnliche Inhalte

Ähnlich wie Processing - MORE Erasmus+ PAU, 2016 February

Intro to Arduino Programming.pdf
Intro to Arduino Programming.pdfIntro to Arduino Programming.pdf
Intro to Arduino Programming.pdf
HimanshuDon1
 
Embedded L1_notes_unit2_architecture.pptx
Embedded L1_notes_unit2_architecture.pptxEmbedded L1_notes_unit2_architecture.pptx
Embedded L1_notes_unit2_architecture.pptx
aartis110
 
4 IOT 18ISDE712 MODULE 4 IoT Physical Devices and End Point-Aurdino Uno.pdf
4 IOT 18ISDE712  MODULE 4 IoT Physical Devices and End Point-Aurdino  Uno.pdf4 IOT 18ISDE712  MODULE 4 IoT Physical Devices and End Point-Aurdino  Uno.pdf
4 IOT 18ISDE712 MODULE 4 IoT Physical Devices and End Point-Aurdino Uno.pdf
Jayanthi Kannan MK
 

Ähnlich wie Processing - MORE Erasmus+ PAU, 2016 February (20)

Electronz_Chapter_14.pptx
Electronz_Chapter_14.pptxElectronz_Chapter_14.pptx
Electronz_Chapter_14.pptx
 
Physical prototyping lab3-serious_serial
Physical prototyping lab3-serious_serialPhysical prototyping lab3-serious_serial
Physical prototyping lab3-serious_serial
 
arduino
arduinoarduino
arduino
 
Arduino experimenters guide ARDX
Arduino experimenters guide ARDXArduino experimenters guide ARDX
Arduino experimenters guide ARDX
 
Arduino experimenters guide hq
Arduino experimenters guide hqArduino experimenters guide hq
Arduino experimenters guide hq
 
How to use an Arduino
How to use an ArduinoHow to use an Arduino
How to use an Arduino
 
Ardx eg-spar-web-rev10
Ardx eg-spar-web-rev10Ardx eg-spar-web-rev10
Ardx eg-spar-web-rev10
 
Arduino and Circuits.docx
Arduino and Circuits.docxArduino and Circuits.docx
Arduino and Circuits.docx
 
Roberto Gallea: Workshop Arduino, giorno #2 Arduino + Processing
Roberto Gallea: Workshop Arduino, giorno #2 Arduino + ProcessingRoberto Gallea: Workshop Arduino, giorno #2 Arduino + Processing
Roberto Gallea: Workshop Arduino, giorno #2 Arduino + Processing
 
Ardx experimenters-guide-web
Ardx experimenters-guide-webArdx experimenters-guide-web
Ardx experimenters-guide-web
 
Arduino Day 1 Presentation
Arduino Day 1 PresentationArduino Day 1 Presentation
Arduino Day 1 Presentation
 
Arduino Programming Basic
Arduino Programming BasicArduino Programming Basic
Arduino Programming Basic
 
Ch_2_8,9,10.pptx
Ch_2_8,9,10.pptxCh_2_8,9,10.pptx
Ch_2_8,9,10.pptx
 
Project_report_on_Attendance_system
 Project_report_on_Attendance_system Project_report_on_Attendance_system
Project_report_on_Attendance_system
 
Cassiopeia Ltd - standard Arduino workshop
Cassiopeia Ltd - standard Arduino workshopCassiopeia Ltd - standard Arduino workshop
Cassiopeia Ltd - standard Arduino workshop
 
Introduction to Arduino Microcontroller
Introduction to Arduino MicrocontrollerIntroduction to Arduino Microcontroller
Introduction to Arduino Microcontroller
 
Intro to Arduino Programming.pdf
Intro to Arduino Programming.pdfIntro to Arduino Programming.pdf
Intro to Arduino Programming.pdf
 
Embedded L1_notes_unit2_architecture.pptx
Embedded L1_notes_unit2_architecture.pptxEmbedded L1_notes_unit2_architecture.pptx
Embedded L1_notes_unit2_architecture.pptx
 
4 IOT 18ISDE712 MODULE 4 IoT Physical Devices and End Point-Aurdino Uno.pdf
4 IOT 18ISDE712  MODULE 4 IoT Physical Devices and End Point-Aurdino  Uno.pdf4 IOT 18ISDE712  MODULE 4 IoT Physical Devices and End Point-Aurdino  Uno.pdf
4 IOT 18ISDE712 MODULE 4 IoT Physical Devices and End Point-Aurdino Uno.pdf
 
Aurdino presentation
Aurdino presentationAurdino presentation
Aurdino presentation
 

Kürzlich hochgeladen

TECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service providerTECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service provider
mohitmore19
 

Kürzlich hochgeladen (20)

BUS PASS MANGEMENT SYSTEM USING PHP.pptx
BUS PASS MANGEMENT SYSTEM USING PHP.pptxBUS PASS MANGEMENT SYSTEM USING PHP.pptx
BUS PASS MANGEMENT SYSTEM USING PHP.pptx
 
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
 
How To Troubleshoot Collaboration Apps for the Modern Connected Worker
How To Troubleshoot Collaboration Apps for the Modern Connected WorkerHow To Troubleshoot Collaboration Apps for the Modern Connected Worker
How To Troubleshoot Collaboration Apps for the Modern Connected Worker
 
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
 
Microsoft AI Transformation Partner Playbook.pdf
Microsoft AI Transformation Partner Playbook.pdfMicrosoft AI Transformation Partner Playbook.pdf
Microsoft AI Transformation Partner Playbook.pdf
 
%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain
%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain
%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain
 
AI & Machine Learning Presentation Template
AI & Machine Learning Presentation TemplateAI & Machine Learning Presentation Template
AI & Machine Learning Presentation Template
 
%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein
%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein
%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein
 
Unveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time ApplicationsUnveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
 
ManageIQ - Sprint 236 Review - Slide Deck
ManageIQ - Sprint 236 Review - Slide DeckManageIQ - Sprint 236 Review - Slide Deck
ManageIQ - Sprint 236 Review - Slide Deck
 
The Guide to Integrating Generative AI into Unified Continuous Testing Platfo...
The Guide to Integrating Generative AI into Unified Continuous Testing Platfo...The Guide to Integrating Generative AI into Unified Continuous Testing Platfo...
The Guide to Integrating Generative AI into Unified Continuous Testing Platfo...
 
VTU technical seminar 8Th Sem on Scikit-learn
VTU technical seminar 8Th Sem on Scikit-learnVTU technical seminar 8Th Sem on Scikit-learn
VTU technical seminar 8Th Sem on Scikit-learn
 
The Top App Development Trends Shaping the Industry in 2024-25 .pdf
The Top App Development Trends Shaping the Industry in 2024-25 .pdfThe Top App Development Trends Shaping the Industry in 2024-25 .pdf
The Top App Development Trends Shaping the Industry in 2024-25 .pdf
 
TECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service providerTECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service provider
 
Exploring the Best Video Editing App.pdf
Exploring the Best Video Editing App.pdfExploring the Best Video Editing App.pdf
Exploring the Best Video Editing App.pdf
 
%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein
%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein
%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein
 
Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...
Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...
Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...
 
MarTech Trend 2024 Book : Marketing Technology Trends (2024 Edition) How Data...
MarTech Trend 2024 Book : Marketing Technology Trends (2024 Edition) How Data...MarTech Trend 2024 Book : Marketing Technology Trends (2024 Edition) How Data...
MarTech Trend 2024 Book : Marketing Technology Trends (2024 Edition) How Data...
 
LEVEL 5 - SESSION 1 2023 (1).pptx - PDF 123456
LEVEL 5   - SESSION 1 2023 (1).pptx - PDF 123456LEVEL 5   - SESSION 1 2023 (1).pptx - PDF 123456
LEVEL 5 - SESSION 1 2023 (1).pptx - PDF 123456
 
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
 

Processing - MORE Erasmus+ PAU, 2016 February

  • 1. Processing is an open source programming language and environment for people who want to create images, animations, and interactions. Processing can interact with Arduino using serial communication. Processing (www.processing.org) is complementary to Arduino, because the languages and IDEs are so similar. Processing programs are called sketches http://www.processing.org and download the appropriate version for your OS of your choice. PROCESSING & ARDUINO PAU 2016
  • 2. Arduino IDE was based on the Processing IDE PROCESSING & ARDUINO PAU 2016
  • 3. Structure of a Processing Sketch: example int timer; void setup() { // The next function sets the size of the sketch size(800,600); /* This is a multiline comment, anything written between the two multiline commment delimiters will be ignored by the compiler. */ } void draw() { background(255); ellipse(timer, height/2, 30, 30); timer = timer + 1; } setup() Function draw() Function will run as a loop until the program is terminated by the user. PROCESSING & ARDUINO PAU 2016
  • 4. Processing IDE We are going to draw a circle on screen that will move to the right of the screen as time passes. Background() function i s necessary to clear the frame with a color at every iteration. If we comment it out (temporarily remove it by adding // to the beginning of the line), we will see that the circles are drawn on top of the previous ones. Press the Run button PROCESSING & ARDUINO PAU 2016
  • 5. The following simple sketch in processing reads the mouse position and sends data (‘1’ or ‘0’) to the arduino board by serial port. The yellow LED connected on pin 13 is on or off depending of the position of the mouse in the rectangle.
  • 6. void setup() { Serial.begin(9600); pinMode(13, OUTPUT); } void loop(){ if (Serial.available()>0) { byte input=Serial.read(); if(input == '1'){ digitalWrite(13, HIGH); }else{ digitalWrite(13, LOW); } } } Scketch for Arduino on_off_LED_da_mouse_ino import processing.serial.*; Serial myPort; void setup() { size(255, 255); //String portName = Serial.list()[0]; myPort = new Serial(this, "com4", 9600); } void draw() { noStroke(); rect(0,0,width/2,height); if (mouseX>width/2) { myPort.write('1'); } else { myPort.write('0'); } } Scketch for processing on_off_LED_da_mouse PROCESSING & ARDUINO PAU 2016
  • 7. ARDUINO_PWM in processing_Example_libraries_Arduino(firmata)_arduino_pwm Demonstrates the control of analog output (PWM) pins of an Arduino board running the StandardFirmata firmware. Moving the mouse horizontally across the sketch changes the output on pins 9 (value is proportional to the mouse X coordinate) and 11 (inversely porportional to mouse X). ARDUINO_OUTPUT in processing_Example_libraries_Arduino(firmata)_arduino_output Demonstrates the control of digital pins of an Arduino board running the StandardFirmata firmware. Clicking the squares toggles the corresponding digital pin of the Arduino. Su arduino occorre caricare Standardfirmata da esempi_firmata_standardfirmata Using the Arduino software, upload the StandardFirmata example (located in Examples > Firmata > StandardFirmata) to your Arduino board. PROCESSING & ARDUINO PAU 2016
  • 8. 1. we import the Serial library and declare a global Serial object 2. Arduino and Processing communicate at the same rate by ”com 4” 3. In our draw() loop, we send whatever we want over the serial port by using the “write method” from the Processing Serial library. 4. For this sketch, we will send a ‘1’ or a ‘ 0’ whenever we click our mouse in the Processing window 5. nostroke() disabilita il contorno 6. size() create a window 7. List all the available serial port 8. background(0) put up a black background 9. if (myPort.available() > 0) Read the serial port. 10. String PortName…. /* On some computers, Arduino will usually be connected to the first serial port. If not, change the 0 to the correct one (examine the output of the previous line of code to figure out which one to use). */ 11. rect(0,0, width/2,heigth) 0,0 coordinates, width of the size and heigth of the size 12. Ellipse (x,y, larghezza, altezza) x a partire da sinistra ed y a partire dall’alto 13.strokeWeigth(20) spessore del contorno a 20 pixel