Suikiyip

Menu

Skip to content
  • Home
  • EXERCISE
    • EX.2 – Processing
    • EX.3 – Audrino Workshop
    • EX.4 – Serial Communication
  • LITTER HACK PROJECT
    • Background
    • Form Development
    • Making Process
    • Program
    • Scenario
    • Work Demo
    • Artifact
  • IMITATE PROJECT

EX.4 – Serial Communication

ARDUINO + PROCESSING


Going through the basics of Arduino + Processing

1. Running a circuit by connecting Arduino and Processing   


 //  Running a circuit by connecting Arduino and Processing
Demo Video :
Programme :
//Arduino (library -> StandardFirmata)
//Processing (library -> arduino_input)

import processing.serial.*;

import cc.arduino.*;

Arduino arduino;

color off = color(4, 79, 111);
color on = color(84, 145, 158);

void setup() {
size(470, 280);

// Prints out the available serial ports.
println(Arduino.list());

// Modify this line, by changing the “0” to the index of the serial
// port corresponding to your Arduino board (as it appears in the list
// printed by the line above).

// Having list [0]-[4] need to change according to your computer 
arduino = new Arduino(this, Arduino.list()[1], 57600);

// Alternatively, use the name of the serial port corresponding to your
// Arduino (in double-quotes), as in the following line.
//arduino = new Arduino(this, “/dev/tty.usbmodem621”, 57600);

// Set the Arduino digital pins as inputs.
for (int i = 0; i <= 13; i++)
arduino.pinMode(i, Arduino.INPUT);
}

void draw() {
background(off);
stroke(on);

// Draw a filled box for each digital pin that’s HIGH (5 volts).
for (int i = 0; i <= 13; i++) {
if (arduino.digitalRead(i) == Arduino.HIGH)
fill(on);
else
fill(off);

rect(420 – i * 30, 30, 20, 20);
}

// Draw a circle whose size corresponds to the value of an analog input.
noFill();
for (int i = 0; i <= 5; i++) {
ellipse(280 + i * 30, 240, arduino.analogRead(i) / 16, arduino.analogRead(i) / 16);
}
}

 

 

 

Create a free website or blog at WordPress.com.
Privacy & Cookies: This site uses cookies. By continuing to use this website, you agree to their use.
To find out more, including how to control cookies, see here: Cookie Policy
    • Suikiyip
    • Sign up
    • Log in
    • Copy shortlink
    • Report this content
    • Manage subscriptions
Design a site like this with WordPress.com
Get started