Top Banner
Processing TYWu
14

Processing TYWu. Where can I download? 2.0b9 Windows 32-bit.

Jan 18, 2016

Download

Documents

Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: Processing TYWu. Where can I download?  2.0b9 Windows 32-bit.

Processing

TYWu

Page 2: Processing TYWu. Where can I download?  2.0b9 Windows 32-bit.

Where can I download?

• http://processing.org/download/

2.0b9Windows 32-bit

Page 3: Processing TYWu. Where can I download?  2.0b9 Windows 32-bit.

How to Install

• You'll have a .zip file.

• Double-click it, and drag the folder inside to a location on your hard disk.

• It could be Program Files or simply the desktop, but the important thing is for the processing folder to be pulled out of that .zip file.

• Then double-click processing.exe to start.

Page 4: Processing TYWu. Where can I download?  2.0b9 Windows 32-bit.

Getting Started

• Windows RUN STOP

Page 5: Processing TYWu. Where can I download?  2.0b9 Windows 32-bit.

Getting Started

• Function– ellipse(50, 50, 80, 80);

• This line of code means "draw an ellipse, with the center 50 pixels over from the left and 50 pixels down from the top, with a width and height of 80 pixels." Click the Run button, which looks like this:

Page 6: Processing TYWu. Where can I download?  2.0b9 Windows 32-bit.

Getting Started

• Examplevoid setup() {   

size(480, 120); //Open a Display Window

}

void draw() {   

if (mousePressed) fill(0);

 else fill(255);

ellipse(mouseX, mouseY, 80, 80);

}

Page 7: Processing TYWu. Where can I download?  2.0b9 Windows 32-bit.

Getting Started

• Result

Page 8: Processing TYWu. Where can I download?  2.0b9 Windows 32-bit.

Communication Between Arduino and Processing

• By RS232

Serial.begin(9600);:Char Value;:Serial.write(Value);:

import processing.serial.*;Serial serial; :serial = new Serial(this, "COM20", 9600);sensorValue = serial.read();:

Page 9: Processing TYWu. Where can I download?  2.0b9 Windows 32-bit.

Communication Between Arduino and Processing

• Step 1– Run Arduino

• Step 2– Run Processing

Page 10: Processing TYWu. Where can I download?  2.0b9 Windows 32-bit.

Communication Between Arduino and Processing

• Example of Arduino

int ultraAn = 0;

int val = 0;

char dist = 0;

void setup() {

Serial.begin(9600);

}

void loop() {

val = analogRead(ultraAn);

dist = (val*2.1)/3;

Serial.write(dist); //Unit = 3cm

delay (1000); // delays 1 secconds in between readings

}

Page 11: Processing TYWu. Where can I download?  2.0b9 Windows 32-bit.

Communication Between Arduino and Processing

• Example of Processingimport processing.serial.*;Serial serial; int sensorValue;void setup() {size(700, 200);serial = new Serial(this, "COM20", 9600);}void draw() { if ( serial.available() > 0) { sensorValue = serial.read(); println(sensorValue); background(255); fill(0,255,0); //Green rect(10, 95, sensorValue*3, 10); } }

Page 12: Processing TYWu. Where can I download?  2.0b9 Windows 32-bit.

Communication Between Arduino and Processing

• Result

Page 13: Processing TYWu. Where can I download?  2.0b9 Windows 32-bit.

Function

• rect(a, b, c, d)

• a (float): x-coordinate of the rectangle by default

• b (float): y-coordinate of the rectangle by default

• c (float): width of the rectangle by default

• d (float): height of the rectangle by default