Advertisement
w0lfiesmith

Processing - Net control Arduino via remote text file

Dec 11th, 2012
3,196
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.72 KB | None | 0 0
  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. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement