IAT267 Zoom with Sensors Example.docx

3 Pages
155 Views
Unlock Document

Department
Interactive Arts & Tech
Course
IAT 267
Professor
Helmine Serban
Semester
Summer

Description
Zoom with Sensors Arduino // Code to read values from two sensors and write them to the serial port int val_light; int val_slider; int inputPin0 = 0; // Analog pin 0 - for light sensor int inputPin1=1; // Analog pin 1 - for slider sensor void setup() { Serial.begin(9600); // Start serial communication at 9600 bps } void loop() { val_light = analogRead(inputPin0)/4; // Read analog input pin0 (light sensor), put in range 0 to 255 val_slider= analogRead(inputPin1)/4; // Read analog input pin1 (slider sensor), put in range 0 to 255 //'a' packet starts Serial.print("a"); //character 'a' will delimit the reading from the light sensor Serial.print(val_light); Serial.print("a"); Serial.println(); //'a' packet ends //'b' packet starts Serial.print("b"); //character 'b' will delimit the reading from the slider sensor Serial.print(val_slider); Serial.print("b"); Serial.println(); //'b' packet ends //add packets here if you use 3 or more sensors Serial.print("&"); //denotes end of readings from both sensors //print carriage return and newline Serial.println(); delay(100); // Wait 100ms for next reading } Processing //In this code the data read from the rotation sensor is used to set the width of our magnified rectangle. //The height of magnified rectangle is determined by the value of slider sensor. import processing.serial.*; Serial port; int valP_rotation; int valP_slider; PImage img; int len = 10; byte[] inBuffer = new byte[255]; //size of the serial buffer to allow for end of data characters and all chars (see arduino code) void setup() { size(600,
More Less

Related notes for IAT 267

Log In


OR

Join OneClass

Access over 10 million pages of study
documents for 1.3 million courses.

Sign up

Join to view


OR

By registering, I agree to the Terms and Privacy Policies
Already have an account?
Just a few more details

So we can recommend you notes for your school.

Reset Password

Please enter below the email address you registered with and we will send you a link to reset your password.

Add your courses

Get notes from the top students in your class.


Submit