All posts by Namju Lee

Direct communication between Arduino board and Processing

This tutorial describes the process of direct communication between Arduino and Processing.  I wish to learn this process, in order to overcome  possible serial port problems between Arduino and Processing during serial communication. Moreover, direct control of Arduino board through Processing, results in a more clear and straight forward process. When considering the Arduino library in Processing allow us to get the data from the board automatically with no concerning about pins and its certain data array. This process is enabled by a special library called “StandardFirmata”, that allows data to be transferred automatically from Arduino to Processing by simplifying significantly the initialization of pins and data arrays. First of all, upload the library called “StandardFirmata”, which is located in the examples file of the Arduino sketch window. nj_img_01 nj_img_02 Since the library is uploaded correctly, the further steps of the process do not involve the Arduino window. The next step would be to create an example sketch in Processing in order to demonstrate the process. Open a Processing sketch and follow the code with the embedded comments below. Tutorial: Step A: Blink an LED with digitalWrite function

2014-11-04 20.44.01Click on the Processing sketch to blink an LED 2014-11-04 20.44.29 Click on the Processing sketch to blink an LED T_A Tutorial: Step B: Changing LED brightness with analogWrite function based on mouse position

2014-11-04 20.45.26Changing LED brightness with analogWrite fuction based on mouse position, the left of the sketch of Processing, value = 10 2014-11-04 20.45.36 Changing LED brightness with analogWrite function based on mouse position, Processing window middle position, value = 180 2014-11-04 20.45.45 Changing LED brightness with analogWrite function based on mouse position, Prossesing window right side, value = 255 T_B Tutorial: Step C: Changing RGB LED brightness with analogWrite function based on mouse position

bu_01 2014-11-04 20.46.26 Changing RGB LED brightness with analogWrite function based on handle, value = red 2014-11-04 20.46.39Changing RGB LED brightness with analogWrite function based on handle, value = green  2014-11-04 20.46.56Changing RGB LED brightness with analogWrite function based on handle, value = blue 2014-11-04 20.47.13Changing RGB LED brightness with analogWrite fuction based on handle, value R G B combination T_C   Tutorial: Step D: Analogue Read (Photo Resistor) from Arduino and data visualization in Processing

2014-11-08 17.31.29 Background color is affected by the Photo Resistor input from the Arduino board and is around the value of 50 (0, 255) in this example. 2014-11-08 17.31.34 Background color is affected by the Photo Resistor input from the Arduino board and is around the value of 50 (0, 255) in this example. 2014-11-08 17.31.38 Background color is affected by the Photo Resistor input from the Arduino board and is around the value of 50 (0, 255) in this example T_D Documentation of cc.arduino library  (link http://playground.arduino.cc/Interfacing/Processing) Arduino.list(): returns a list of the available serial devices. If your Arduino board is connected to the computer when you call this function, its device will be in the list.
Arduino(parent, name, rate): create an Arduino object. Parent should be “this” (without the quotes); name is the name of the serial device (i.e. one of the names returned by Arduino.list()); rate is the speed of the connection (typically 57600). Note that in the v2 library, the rate parameter is optional.
pinMode(pin, mode): set a digital pin to input, output, or servo mode (Arduino.INPUT, Arduino.OUTPUT, or Arduino.SERVO). digitalRead(pin): returns the value of a digital pin, either Arduino.LOW or Arduino.HIGH (the pin must be set as an input). digitalWrite(pin, value): writes Arduino.LOW or Arduino.HIGH to a digital pin.
analogRead(pin): returns the value of an analog input (from 0 to 1023).
analogWrite(pin, value): writes an analog value (PWM wave) to a digital pin that supports it (pins 3, 5, 6, 9, 10, and 11); value should be from 0 (always off) to 255 (always on).
servoWrite(pin, value): writes a value to a servo motor; value should be from 0 to 180.

Reference
http://playground.arduino.cc/Interfacing/Processing https://processing.org