How to open files from a directory, randomly?
in
Programming Questions
•
5 months ago
Hi,
I connected my Processing 1.5.1 with my Arduino Uno. I've plugged in a button into my breadboard, which is connected to the Arduino.
My goal: if you press down the button, processing opens a bitmap file from a directory randomly. — I mean the route leads to a folder, that is filled with bitmap files, the processing picks one out and opens it in fullscreen.
This is how my code looks like now:
- import processing.serial.*;
- import cc.arduino.*;
- Arduino arduino;
- int buttonPin = 2; // the number of the pushbutton pin
- int ledPin = 13; // the number of the LED pin // this is not solved yet.
- int buttonState = 0;
- void setup()
- {
- //println(Arduino.list());
- arduino = new Arduino(this, Arduino.list()[6], 57600);
- arduino.pinMode(ledPin, Arduino.OUTPUT);
- arduino.pinMode(buttonPin, Arduino.INPUT);
- }
- void draw()
- {
- buttonState = arduino.digitalRead(buttonPin);
- if (buttonState == arduino.HIGH) {
- println("2013.pdf");
- open("/Users/rjth/Desktop/2013.pdf");
- }
- else {
- arduino.digitalWrite(ledPin, arduino.LOW); // this is not solved yet.
- }
- }
1