IAT267 Brightness Receiver Example.docx

3 Pages
81 Views
Unlock Document

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

Description
Brightness Receiver Arduino *see multiple sensors code Processing //Read data from the serial port //The data at the serial port represents readings from two sensors: light and slider //This program 'decodes' the string received at the serial port into reading from light sensor (valP_light) and reading from slider sensor (valP_slider) import processing.serial.*; Serial port; // Create object from Serial class int valP_light; // Data received from the serial port - variable to store the light sensor reading PImage img; 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,400); background(0); img = loadImage("basel.png"); noStroke(); frameRate(10); // Run 10 frames per second // Open the port that the board is connected to and use the same speed (9600 bps) println(Serial.list()); port = new Serial(this, Serial.list()[0], 9600); } void draw() { if (port.available()>0) { // If data is available to read, //println("reads from port"); port.readBytesUntil('&', inBuffer); //read in all data until '&' is encountered if (inBuffer != null) { String myString = new String(inBuffer); //println(myString); //for testing only //p is all sensor data (with a's and b's) ('&' is eliminated) /////////////// String[] p = splitTokens(myString, "&"); //println(p.length); if (p.length < 2) return; //exit this function if packet is broken //println(p[0]); //for testing
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