SHARE
TWEET

Processing - Net control Arduino via remote text file

w0lfiesmith Dec 11th, 2012 2,759 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import processing.serial.*;
  2. Serial port;
  3. void setup(){
  4.   println("Available serial ports:");
  5.   println(Serial.list());
  6.   port = new Serial(this, Serial.list()[4], 9600);  // Open the port that the Arduino board is connected to, at 9600 baud
  7. }
  8. void draw(){
  9.   String[] colors = new String[3];
  10.   colors = loadStrings("http://jamesbruce.me/lights/LED.txt"); // Insert the location of your .txt file
  11.   /* text file contains 3 lines of numbers for RGB values, eg:
  12.   255
  13.   125
  14.   0
  15.   */
  16.   for(int n=0;n<3;n++){
  17.     println(colors[n]);
  18.     int num;
  19.     num = parseInt(colors[n]); // change string into Int
  20.     port.write((byte)(num)); // write as a byte over serial
  21.   }
  22.   port.write(0xff); //write our marker
  23.   delay(1000);
  24. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top