We are about to switch to a new forum software. Until then we have removed the registration on this forum.
I'm trying to get a variety of images to appear depending on the range an object is from the proximity sensor. Can you see what's wrong with my code, i can't find it.
import processing.serial.*; import cc.arduino.*; Arduino arduino;
PImage a; PImage img1; PImage img2; PFont myFont;
void setup() { size(900, 550); background(255); myFont = loadFont("CenturyGothic-48.vlw"); img1 = loadImage("1.jpg"); img2 = loadImage("2.jpg"); arduino = new Arduino(this, Arduino.list()[9], 57600);
}
void draw() { background (0); int x = arduino.analogRead(0); println(x);
if (x <= 150){ background (0); }
if (x > 150 & x < 300){ text("Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nulla nec accumsan urna. Sed a metus in tortor vestibulum ultrices. Ut sit amet dolor eu tellus pharetra aliquam pharetra id arcu. Nam venenatis ultrices nisi hendrerit varius. Proin vulputate purus vel sapien vulputate dignissim. Morbi eget nunc a lacus scelerisque accumsan. Curabitur eros ipsum, imperdiet eget ornare ac, pretium eu erat.", 500, 40, 350, 160); a = loadImage("1.jpg"); image(a, 0, 0); }
if (x > 300){ text("Nunc pretium sapien nulla, eget molestie ligula rhoncus scelerisque. Integer accumsan turpis id odio facilisis luctus. Vivamus aliquam lobortis ultricies. Pellentesque euismod, augue et tincidunt sollicitudin, augue turpis mollis justo, vel tincidunt nibh justo vitae felis. In sagittis dui eget tortor varius vulputate. Nunc semper, justo commodo posuere sagittis, orci eros faucibus arcu, nec commodo dolor quam sit amet mi.", 500, 40, 350, 160); a = loadImage("2.jpg"); image(a, 0, 0); } }
Answers
Please format the code it's really difficult to read. You can do that by selecting the code and CTRL+K or the C button in the editing bar above the text area. And as far as i can see you should also use loadImage() in setup.