Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import processing.serial.*;
- int Y_res = 48;
- int j = 0;
- PImage img;
- int div;
- int greyval;
- Serial myPort;
- void setup() {
- img = loadImage("10.jpg");
- div = img.height / Y_res;
- img.resize(img.width/div, img.height/div);
- String portName = Serial.list()[5];
- myPort = new Serial(this, portName, 115200);
- }
- void draw() {
- }
- void serialEvent(Serial myPort) {
- int inByte = myPort.read();
- if (j < 25) {
- if (inByte == 'K') {
- for (int i = 0; i < 36 ; i++) {
- myPort.write("S");
- color pix = img.get(j, i);
- greyval = int(brightness(pix));
- myPort.write(greyval);
- println(greyval);
- }
- myPort.write("E");
- j++;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement