DataInputFrom Digital PinsUsing an On/OFF button to control an LEDFrom Analog Pins Reading light intensity using a photocell and turning an LED on and.

Slides:



Advertisements
Similar presentations
Wireless Cue Light Project
Advertisements

Book Project Sue Brandt Arduino Project Interactive with LEDS.
ARDUINO CLUB What we’re really doing. BASICS The setup() and loop() functions.
Lab7: Introduction to Arduino
ARDUINO FRAMEWORK.
Anurag Dwivedi & Rudra Pratap Suman.  Open Source electronic prototyping platform based on flexible easy to use hardware and software.
Panasonic EVE-KC2F2024B 24 pulses per revolution 6mm diameter flattened output shaft output type: quadrature (incremental) minimum life: 15,000 rotations.
Digital & Analog Inputs. Review Fundamental parts of an Arduino program are … Setting output types using pinMode. Declaring variables Can write a digital.
Introduction to Arduino Programming January MER-421:Mechatronic System Design.
Intro to Programming and Microcontrollers. Activity Group into pairs and sit back-to-back. Pick one person who is going to draw. The other person will.
Introduction to Sensor Technology Week Four Adam Taylor
Analog and Digital Measurements living with the lab 14 digital input / output pins 6 analog input pins © 2011 LWTL faculty team.
Introduction.
Introduction to Arduino Prepared by R. Lamond.  “Arduino is an open-source electronics prototyping platform based on flexible, easy- to-use hardware.
Basic Circuits – Lab 2 Arduino and Sensors Xmedia Spring 2011.
Parallax 4x20 LCD (part number 27979) with Arduino Duemilanove
ARDUINO PROGRAMMING Working with the Arduino microcontroller.
Working with Arduino: Lesson #1: Getting Acquainted with the Kit EGN1007.
Basic Circuits – Lab 2 Arduino and Sensors
Tele-presence – Connecting Two Processing Platforms via Internet Controlling the Screen based on Distant User Input ServerClient 1.
Microprocessors Tutorial 1: Arduino Basics
ProtoSnap Introduction to Arduino Casey Haskell, Pete Lewis, David Stillman, Jim Lindblom, Pete Dokter, Lindsay Levkoff, Trevor Zylstra.
Code The Arduino Environment.
Robootika lahenduste esitlus Raul Liinev Martin Ligema Siim Suu Martin Tõnne.
Microprocessors Tutorial 1: Arduino Basics
Serial Communication. mouseX from computer to arduino processing sends a single byte of data arduino reads each byte arduino uses value to set light brightness.
Processing TYWu. Where can I download? 2.0b9 Windows 32-bit.
ARDUINO 1. Basics  Comments  /* * Blink * * The basic Arduino example. Turns on an LED on for one second, * then off for one second, and so on... We.
Arduino Circuits and Code. int ledPin = 9; void setup() { pinMode(ledPin, OUTPUT); } void loop() { digitalWrite(ledPin, LOW); delay(1000); digitalWrite(ledPin,
1 - Remove LED from 13 and GND - Bring out your breadboard from HW#4 Arduino Overview:
Basic Circuits – Lab 4 Serial and OSC (maybe some theory too) Xmedia Spring 2011.
Youn-Hee Han, In-Seok Kang {yhhan, Laboratory of Intelligent Networks Advanced Technology Research Center Korea University of Technology.
INTERNET OF EVERYTHING SDU 2016 Week 4. Simple Digital and Analog Inputs  The Arduino’s ability to sense digital and analog inputs allows it to respond.
Photoresistor resistance changes dramatically with light level living with the lab Using Photoresistors with an Arduino © 2011 LWTL faculty team.
Welcome to Processing Who does not have access to digital camera?
Final Term Project Hi-Tek Smoke Detektor By: Rohan Sharma.
Microcontroller basics Embedded systems for mortals.
ME 120: Arduino Programming Arduino Programming Part II ME 120 Mechanical and Materials Engineering Portland State University
Programming in Arduino Materials:Arduino Board Casperelectronics Pre Pres. Notes Photos from workshop?
Arduino + Bluetooth TYWu. Connection Arduino + Bluetooth Module.
Arduino “Getting Started” Instructor : Dr Matthew Miss Khin Yi Kyaw
Hacking on Arduino George Patterson
Assist. Prof. Rassim Suliyev - SDU 2017
Microcontroller basics
Microcontroller basics
Wireless Cue Light Project
Microprocessors Tutorial 1: Arduino Basics
Arduino Programming Part II
Tele-presence – Connecting Two Processing Platforms via Internet
UCD ElecSoc Robotics Club 2017/2018
Arduino Part 1 Topics: Microcontrollers Programming Basics
Control the color and brightness of an RGB LED with a Potentiometer
Arduino Uno and sensors
Analog Input through POT
ARDUINO     What is an Arduino? Features 14 Digital I/O pins 6 Analogue inputs 6 PWM pins USB serial 16MHz Clock speed 32KB Flash memory 2KB SRAM.
Continuing with LED’s and Arduino
IoT Programming the Particle Photon.
Chapter 2 Push button and Potentiometer
1 Code
Working with Arduino: Lesson #1: Getting Acquainted with the Kit
CS4101 Introduction to Embedded Systems Lab 8: Arduino DAC and PWM
Arduino : Introduction & Programming
Programming 2: The Arduino IDE & First Sketches
Arduino Practice: Photoresistors, PWM, Potentiometers, Motors
Arduino Part 4 Let there be more light.
CTY SAR FCPS Shawn Lupoli, Elliot Tan
Arduino Uno circuit basics
Setting up a basic program with Arduino
Arduino程式範例.
Presentation transcript:

DataInputFrom Digital PinsUsing an On/OFF button to control an LEDFrom Analog Pins Reading light intensity using a photocell and turning an LED on and off based on the read data From Processing in real-timeControlling an LED from user manipulation in processingFrom File Turning and LED on and off based on the data that is being read in real-time from a file From Internet Through Processing Turning an LED on and off based on input via tele-presence From SMS Thorough Processing Turning an LED on and off based on user input via text messagingOutputOutput to Digital PinsTurning an LED On and Off Output to Digital Pins with Analog Support Diming the light intensity of an LED higher or lower Output to Processing in real- time Controlling what is happening on the screen in Processing based on what a photocell is reading as light intensity Output to FileWriting the read light intensity from a photocell to a file for later use Output to Internet Through Processing Sending the read light intensity from the photocell to a distant location via processing running an applet to connect to Internet 1

Digital Input – Output to Processing Controlling the Screen with a Button 1. Controlling an LED with Push Button A push ‐ button will open (or close) a circuit when pressed. Its circuit is shown below. The black wire goes to ground, the yellow to the pin (2 for this case), and the 10K resistor connects to 5V. If you connect the 10K resistor to ground and the black wire to 5V you inverse the state of the push button. 2

Digital Input – Output to Processing Controlling the Screen with a Button 1. Controlling an LED with Push Button A push ‐ button will open (or close) a circuit when pressed. Its circuit is shown below. The black wire goes to ground, the yellow to the pin (2 for this case), and the 10K resistor connects to 5V. 3

Digital Input – Output to Processing Controlling the Screen with a Button 1. Controlling an LED with Push Button A push ‐ button will open (or close) a circuit when pressed. Its circuit is shown below. The black wire goes to ground, the yellow to the pin (2 for this case), and the 10K resistor connects to 5V. void setup(){ Serial.begin(9600); //start the serial port in order to write pinMode(2,INPUT); // set the pin 5 as input pinMode(13, OUTPUT); // set the pin 13 as output } void loop(){ int val = digitalRead(2); //read from the pin 5 if(val==LOW) { digitalWrite(13, LOW); // sets the LED off } else { digitalWrite(13, HIGH); // sets the LED on } Serial.println(val); } 4

Digital Input – Output to Processing Controlling the Screen with a Button 2. Controlling Processing with Push Button a. Upload the Arduino Code b. Stop Arduino c. Run Processing d. Check which port is available and what is the index of the available port e. Change the Index in Processing code // This is Processing Code import processing.serial.*; int val = 1; Serial port; void setup(){ size(100,100); // Use the first available port port = new Serial(this, Serial.list()[1], 9600); // if in arduino the first option in your list is the port that you are connecting to, //change the 1 to Zero, if it is the second leave it as 1 println(Serial.list()); background(255); } void draw(){ while (port.available() > 0) serialEvent(port.read()); //look for data if (val==1)background(255); if (val==0)background(0); } void serialEvent(int serial) { val=serial-48;// Change the character ascii code to numeric value println(val); } //This is Arduino Code void setup(){ Serial.begin(9600); //start the serial port in order to write pinMode(2,INPUT); // set the pin 5 as input pinMode(13, OUTPUT); // set the pin 13 as output } void loop(){ int val = digitalRead(2); //read from the pin 5 if(val==LOW) { digitalWrite(13, LOW); // sets the LED off } else { digitalWrite(13, HIGH); // sets the LED on } Serial.println(val); } 5

Analog Input – Output to Processing Controlling the Screen with a Photocell void setup(){ Serial.begin(9600); } void loop(){ int in = analogRead(5); Serial.println(in); } 6

Analog Input – Output to Processing Controlling the Screen with a Photocell 7

Analog Input – Output to Processing Controlling the Screen with a Photocell //This is Arduino Code void setup(){ Serial.begin(9600); } void loop(){ int in = analogRead(5); Serial.println(in); } import processing.serial.*; int val = 1; String buff = ""; int NEWLINE = 10; Serial port; void setup() { size(400,400); // Use the first available port port = new Serial(this, Serial.list()[1], 9600); // if in arduino the first option in your list is the port that you are connecting to, //change the 1 to Zero, if it is the second leave it as 1 println(Serial.list()); background(255); delay(2000); } void draw() { while (port.available() > 0) serialEvent(port.read()); //look for data background(val); } void serialEvent(int serial) { // If the variable "serial" is not equal to the value for // a new line, add the value to the variable "buff". If the // value "serial" is equal to the value for a new line, // save the value of the buffer into the variable "val". if(serial != NEWLINE) { buff += char(serial); } else { if (buff.length()>2) { buff = buff.substring(0, buff.length()-1); //println(buff); //Parse the String into an integer if(millis()>2000) { println("OK"); val = Integer.parseInt(buff); val=int(map(val,0,800,0,255)); } // Clear the value of "buff" buff = ""; } 8

Analog Input – Output to Processing Painting the Screen with a Photocell //This is Arduino Code void setup(){ Serial.begin(9600); } void loop(){ int in = analogRead(5); Serial.println(in); } import processing.serial.*; int val = 1; String buff = ""; int NEWLINE = 10; int count; int dir=1; Serial port; void setup(){ size(400,100); // Use the first available port port = new Serial(this, Serial.list()[1], 9600); // if in arduino the first option in your list is the port that you are connecting to, //change the 1 to Zero, if it is the second leave it as 1 println(Serial.list()); background(255); } void draw(){ while (port.available() > 0) serialEvent(port.read()); //look for data stroke(val);//Set the stroke color based on the sensed data line(count,0,count,100);//Draw a line count=count+dir;//Go one pixel forwards or backwards if ((count>width)||(count<0)) dir=-dir; // The dial gets to the limits of the screen, //change direction } void serialEvent(int serial) { // If the variable "serial" is not equal to the value for // a new line, add the value to the variable "buff". If the // value "serial" is equal to the value for a new line, // save the value of the buffer into the variable "val". if(serial != NEWLINE) { buff += char(serial); } else { if (buff.length()>2) { buff = buff.substring(0, buff.length()-1); //println(buff); //Parse the String into an integer if(millis()>2000) { println("OK"); val = Integer.parseInt(buff); val=int(map(val,0,800,0,255)); } // Clear the value of "buff" buff = ""; } 9

GND V5Analog Pin 4 Analog Pin 5 Analog Input – Output to Processing Painting the Screen with a Two Photocell 10

Analog Input – Output to Processing Controlling the Screen with Two a Photocell 11

Analog Input – Output to Processing Painting the Screen with Two a Photocell 12

Analog Input – Output to Processing Painting the Screen with Two a Photocell //This is Arduino Code void setup(){ Serial.begin(9600); } void loop(){ int inA = analogRead(5); int inB = analogRead(4); inA=1000+inA;// The photocell A sends data in 1000 Range inB=2000+inB;// The photocell B sends data in 2000 Range Serial.println(inA); Serial.println(inB); } //This is Processing Code import processing.serial.*; int val = 1; String buff = ""; int NEWLINE = 10; Serial port; int count=0; Int dir=1; int valA,valB; int light_Min=0; int light_Max=750; void setup(){ size(400,200); // Use the first available port port = new Serial(this, Serial.list()[1], 9600); // if in arduino the first option in your list is the port that you are connecting to, //change the 1 to Zero, if it is the second leave it as 1 println(Serial.list()); background(255); } void draw(){ while (port.available() > 0) serialEvent(port.read()); //look for data stroke(valA);//Set the stroke color based on the sensed data line(count, 0, count, 100);//Draw a line stroke(valB); line(count, 100, count, 200);//Draw a line count=count+dir;//Go one pixel forwards or backwards if ((count>width)||(count<0)) dir=-dir; } void serialEvent(int serial) { // If the variable "serial" is not equal to the value for // a new line, add the value to the variable "buff". If the // value "serial" is equal to the value for a new line, // save the value of the buffer into the variable "val". if(serial != NEWLINE) { buff += char(serial); } else { if (buff.length()>2) { buff = buff.substring(0, buff.length()-1); //println(buff); //Parse the String into an integer if(millis()>2000) { println("OK"); val = Integer.parseInt(buff); if (val<2000) valA=int(map((val-1000),light_Min,light_Max,0,255)); if (val>=2000) valB=int(map((val-2000),light_Min,light_Max,0,255)); println("A="+valA); println("B="+valB); } // Clear the value of "buff" buff = ""; } 13

Input – Output to file via Processing //This is Arduino Code void setup(){ Serial.begin(9600); } void loop(){ int inA = analogRead(5); int inB = analogRead(4); inA=1000+inA;// The photocell A sends data in 1000 Range inB=2000+inB;// The photocell B sends data in 2000 Range Serial.println(inA); Serial.println(inB); } //This is Processing Code import processing.serial.*; PrintWriter output; int val = 1; String buff = ""; int NEWLINE = 10; Serial port; int valA,valB; int light_Min=0; int light_Max=895; void setup(){ size(200,100); // Create a new file in the sketch directory output = createWriter("log.txt"); // Use the first available port port = new Serial(this, Serial.list()[1], 9600); // if in arduino the first option in your list is the port that you are connecting to, //change the 1 to Zero, if it is the second leave it as 1 println(Serial.list()); background(255); } void draw(){ while (port.available() > 0) serialEvent(port.read()); //look for data output.println("A"+valA+","+"B"+valB); // Write the coordinate to the file fill(valA); rect(0,0,100,100); fill(valB); rect(100,0,100,100); } void serialEvent(int serial) { // If the variable "serial" is not equal to the value for // a new line, add the value to the variable "buff". If the // value "serial" is equal to the value for a new line, // save the value of the buffer into the variable "val". if(serial != NEWLINE) { buff += char(serial); } else { if (buff.length()>2) { buff = buff.substring(0, buff.length()-1); //println(buff); //Parse the String into an integer if(millis()>2000) { println("OK"); val = Integer.parseInt(buff); if (val<2000) valA=int(map((val-1000),light_Min,light_Max,0,255)); if (val>=2000) valB=int(map((val-2000),light_Min,light_Max,0,255)); println("A="+valA); println("B="+valB); } // Clear the value of "buff" buff = ""; } void keyPressed() { output.flush(); // Writes the remaining data to the file output.close(); // Finishes the file exit(); // Stops the program } 14

Reading Data from File- Making Graphs String lines[];// Array of all the lines in the file String light_A[];// Array of all the light readings of point A String light_B[];// Array of all the light readings of point B int counter=0;// counter that changes value in each loop int graphScale;// The scale of the graph int xPrevA,xPrevB;//x Value of Previous point on the graph int avrA,avrB; int yPrevA,yPrevB;// y Value of Previouspoint on the graph void setup(){ size(800,600); background(255); yPrevA=height-10;// Starting from the base line yPrevB=height-310;// Starting from the base line lines= loadStrings("log.txt");//loading the data from file to lines array light_A= new String[lines.length];// set the size of the Array of the data read at point A light_B= new String[lines.length];// set the size of the Array of the data read at point B for (int i=0; i < lines.length; i++) {// for each entry in the lines Array String each_Line[]= split(lines[i], ',');// Split the two values on each line at the ',' light_A[i]=each_Line[0].substring(1);// put the first value minus the 'A' to array A light_B[i]=each_Line[1].substring(1);// put the second value minus the 'B' to array B //println(light_A[i]+","+light_B[i]); } graphScale=lines.length/width;// Scale factor scales down the graph to the width of the window line(0,height-10,width,height-10);// Base line of the data grapg of point A line(0,height-310,width,height-310);// Base line of the data grapg of point B stroke(200); for(int i=1;i<10;i++){ line(0,height-10-i*20,width,height-10-i*20);// Grid lines of the data graph of Point A line(0,height-310-i*20,width,height-310-i*20);// Grid lines of the data graph of Point B } void draw(){ if (counter<lines.length-1){// for each entry in array A and B counter=counter+1;// Change the counter stroke(0,0,0);// Frame color of the rectangles fill(int(light_A[counter]));// Change the fill color of the rectangle representing the light intensity at point A rect(0,0,100,100); fill(int(light_B[counter]));// Change the fill color of the rectangle representing the light intensity at point B rect(100,0,100,100); // Scaleing and drawing the Graphs if(counter%graphScale==0){ avrA=avrA/graphScale;// get the avrage of the reads for Point A avrB=avrB/graphScale;// get the avrage of the reads for Point B stroke(255,0,0);// Color of the grapg for Point A line(xPrevA,yPrevA,counter/graphScale,height-10-avrA);// Draw the graph segment for Point A stroke(0,255,0);// Color of the grapg for Point B line(xPrevB,yPrevB,counter/graphScale,height-310-avrB);// Draw the graph segment for Point B xPrevA=counter/graphScale; xPrevB=counter/graphScale; yPrevA=height-10-avrA; yPrevB=height-310-avrB; avrA=0; avrB=0; } else{ avrA=avrA+int(light_A[counter]); avrB=avrB+int(light_B[counter]); } 15

Controlling Processing with Multiple input from Arduino - Making RGB colors on Screen Manipulating Potentiometers 16

Controlling Processing with Multiple input from Arduino - Making RGB colors on Screen Manipulating Potentiometers Ground v5 Analog Pin 4 Analog Pin 3 Analog Pin 5 17

Controlling Processing with Multiple input from Arduino - Making RGB colors on Screen Manipulating Potentiometers //This is Arduino Code void setup(){ Serial.begin(9600); } void loop(){ int inR = analogRead(5); int inG = analogRead(4); int inB = analogRead(3); inR=1000+inR;// The Red ranges from inG=3000+inG;// The Green ranges from inB=5000+inB;// The Blue ranges from Serial.println(inR); Serial.println(inG); Serial.println(inB); } //This is Processing Code import processing.serial.*; int val = 1; String buff = ""; int NEWLINE = 10; Serial port; int r,g,b; void setup(){ size(400,400); // Use the first available port port = new Serial(this, Serial.list()[1], 9600); // if in arduino the first option in your list is the port that you are connecting to, //change the 1 to Zero, if it is the second leave it as 1 println(Serial.list()); background(255); } void draw(){ while (port.available() > 0) serialEvent(port.read()); //look for data color c=color(r,g,b); background(c); } void serialEvent(int serial) { // If the variable "serial" is not equal to the value for // a new line, add the value to the variable "buff". If the // value "serial" is equal to the value for a new line, // save the value of the buffer into the variable "val". if(serial != NEWLINE) { buff += char(serial); } else { if (buff.length()>2) { buff = buff.substring(0, buff.length()-1); //println(buff); //Parse the String into an integer if(millis()>2000) { println("OK"); val = Integer.parseInt(buff); if (val<3000) r=int(map(val,1000,2023,0,255)); if ((val>=3000)&&(val<5000)) g=int(map(val,3000,4023,0,255)); if (val>=5000) b=int(map(val,5000,6023,0,255)); println("R="+r); println("G="+g); println("B="+b); } // Clear the value of "buff" buff = ""; } 18

DataInputFrom Digital PinsUsing an On/OFF button to control an LEDFrom Analog Pins Reading light intensity using a photocell and turning an LED on and off based on the read data From Processing in real-timeControlling an LED from user manipulation in processingFrom File Turning and LED on and off based on the data that is being read in real-time from a file From Internet Through Processing Turning an LED on and off based on input via tele-presence From SMS Thorough Processing Turning an LED on and off based on user input via text messagingOutputOutput to Digital PinsTurning an LED On and Off Output to Digital Pins with Analog Support Diming the light intensity of an LED higher or lower Output to Processing in real- time Controlling what is happening on the screen in Processing based on what a photocell is reading as light intensity Output to FileWriting the read light intensity from a photocell to a file for later use Output to Internet Through Processing Sending the read light intensity from the photocell to a distant location via processing running an applet to connect to Internet 19

User Input from Processing Controlling one Actuator On Arduino 20

User Input from Processing Controlling one Actuator On Arduino // THis is processing Code import processing.serial.*; Serial myPort; color c= color(0,0,0); void setup(){ background(255,255,255); size(100,100); myPort = new Serial(this, Serial.list()[1], 9600); fill(0,0,0); } void draw(){ fill(c); ellipse(50,50,50,50); } void mouseClicked(){ if (((mouseX>25)&&(mouseX 25)&&(mouseY<75))) if (red(c)==0){ c=color(255,0,0); myPort.write(1); } else{ c=color(0,0,0); myPort.write(0); } // This is Arduino Code int ledPin = 13; // LED connected to digital pin 13 int val = 0; void setup() { pinMode(ledPin, OUTPUT); // sets the digital pin as output Serial.begin(9600); } void loop() { val = Serial.read(); if (val==0){digitalWrite(13,LOW);} if (val==1){digitalWrite(13,HIGH);} } 21

User Input from Processing Controlling Multiple Actuator On Arduino 22

User Input from Processing Controlling Multiple Actuator On Arduino // THis is processing Code import processing.serial.*; Serial myPort; color colorA,colorB,colorC= color(0,0,0); void setup(){ background(255,255,255); size(300,100); myPort = new Serial(this, Serial.list()[1], 9600); fill(0,0,0); } void draw(){ fill(colorA); ellipse(50,50,50,50); fill(colorB); ellipse(150,50,50,50); fill(colorC); ellipse(250,50,50,50); } void mouseClicked(){ if (((mouseX>25)&&(mouseX 25)&&(mouseY<75))) if (red(colorA)==0){ colorA=color(255,0,0); myPort.write(11); }else{ colorA=color(0,0,0); myPort.write(10); } if (((mouseX>125)&&(mouseX 25)&&(mouseY<75))) if (red(colorB)==0){ colorB=color(255,0,0); myPort.write(21); }else{ colorB=color(0,0,0); myPort.write(20); } if (((mouseX>225)&&(mouseX 25)&&(mouseY<75))) if (red(colorC)==0){ colorC=color(255,0,0); myPort.write(31); }else{ colorC=color(0,0,0); myPort.write(30); } // This is Arduino Code //LED Connects to pin 13,12,11 int val = 0; void setup() { pinMode(13, OUTPUT); // sets the digital pin as output pinMode(12, OUTPUT); // sets the digital pin as output pinMode(11, OUTPUT); // sets the digital pin as output Serial.begin(9600); } void loop() { val = Serial.read(); if (val==10){digitalWrite(13,LOW);} if (val==11){digitalWrite(13,HIGH);} if (val==20){digitalWrite(12,LOW);} if (val==21){digitalWrite(12,HIGH);} if (val==30){digitalWrite(11,LOW);} if (val==31){digitalWrite(11,HIGH);} } 23

User Input from Processing Sending Multiple Analog Data to Arduino- RGB Colors 24

User Input from Processing Sending Multiple Analog Data to Arduino- RGB Colors 25

User Input from Processing Sending Multiple Analog Data to Arduino- RGB Colors // This is Arduino Code //maximum Amount that you can send to Arduino from Processing is 255 int redPin = 11; // this function works on pins 3, 5, 6, 9, 10, and 11. int greenPin = 10; int bluePin = 9; int val = 0; int valR,valG,valB; void setup() { pinMode(redPin, OUTPUT); // sets the digital pin as output pinMode(greenPin, OUTPUT); pinMode(bluePin, OUTPUT); Serial.begin(9600); } void loop() { val = Serial.read(); if ((val>-1)&&(val<85)) {// recieved data defines the Red value valR=val*3; } else if ((val>84)&&(val<180)) {// recieved data defines the Green value valG=(val-85)*3; } else if (val>179) {// recieved data defines the Blue value valB=(val-180)*3; } analogWrite(redPin, valR); analogWrite(greenPin, valG); analogWrite(bluePin, valB); } 26 // This is Processing Code import processing.serial.*; Serial myPort; int k=255; color c; void setup(){ size(255,255); myPort = new Serial(this, Serial.list()[0], 9600); colorMode(HSB); for(int j=0;j<256;j++) for(int i=0;i<256;i++) { stroke(i,j,k); point(i,255-j); } fill(255); stroke(0); rect(255,0,10,255); line(255,127,265,127); } void draw(){ c= get(mouseX,mouseY); int Red= int(map(red(c),0,255,0,84)); int Green=int(map(green(c),0,255,85,179)); int Blue=int(map(blue(c),0,255,180,255)); myPort.write(Red); myPort.write(Green); myPort.write(Blue); println(Red); println(Green); println(Blue); }

User Input from Processing Sending Multiple Analog Data to Arduino Red=0-84Green= Blue= Sensed Value :Red =0-255Green=0-255 Blue=0-255 Red =0-255Green=0-255 Blue=0-255 Red =Red/3Green=Green/3+85 Blue=Blue/3+180 Red=Red*3Green=(Green-85)*3 Blue=(Blue-160)*3 Change the Sensed Data to Identifiable Ranges The actual values that are passed to Processing Changing the Range of the Value back to The Changed Values that result in Actuation of Space Sent Values : Red=0-84Green= Blue= While Sending Data fromProcessing to Arduino the Sendable data range is