Friday, July 22, 2016

Filled Under: , ,

Virtual Color Mixer

04.Communication library Virtual Color Mixer
This example demonstrates how to send multiple values from the Arduino board to the computer. The readings from three potentiometers are used to set the red, green, and blue components of the background color of a Processing sketch or Max/MSP patch.

Step 1: What You Need?



Don't have components? Don't worry. Just click the component's name. 


Step 2: Build Your Circuit.



Connect analog sensors to analog input pins 0, 1, and 2.

This circuit uses three voltage divider sub-circuits to generate analog voltages from the force-sensing resistors. A voltage divider has two resistors in series, dividing the voltage proportionally to their values.


Step 3: Upload The Code.



1. Select the Arduino board type: Select Tools >> Board >> Select your correct Arduino board used.


2. Find the port number by accessing device manager on Windows. See the section Port (COM&LPT) and look for an open port named "Arduino Uno (COMxx)". If you are using a different board, you will find a name accordingly. What matters is the xx in COMxx part. In my case, it's COM3. So my port number is 3.


Select the right port: Tools >> Port >> Select the port number.


3. You can find this code in the example of Arduino IDE. 

Select File >> Examples >> 04.Communication >> VirtualColorMixer 

Click press the "upload" button (see the button with right arrow mark).


The sensor values are sent from the Arduino to the computer as ASCII-encoded decimal numbers. This means that each number is sent using the ASCII characters "0" through "9". For the value "234" for example, three bytes are sent: ASCII "2" (binary value 50), ASCII "3" (binary value 51), and ASCII "4" (binary value 52).


Processing Code

Copy the Processing sketch from the code sample above. As you change the value of the analog sensors, the background color will change:

Max Code

The max patch looks like this. Copy the text of it from the code sample above and paste into a new Max window.



Unknown

Author & Editor

My Robot Education Sdn. Bhd. (Robotedu.my) was founded in 2015 as the first robotics education centre in Malaysia to provide Arduino-based robotics courses for youths. Our vision is to be able to provide robotics education to every youth in Malaysia.

0 comments:

Post a Comment

 

  • Copyright © Arduino Tutorial ™ is a registered trademark.
    Designed by Templateism. Hosted on Blogger Templates.