[/code] (and I did try turning off the Arduino Serial. Still the weird non-correspondance....)"> [/code] (and I did try turning off the Arduino Serial. Still the weird non-correspondance....)"> [/code] (and I did try turning off the Arduino Serial. Still the weird non-correspondance....)">
[code]int photoRPin = 0;
int minLight;
int maxLight;
int lightLevel;
int adjustedLightLevel;
void setup() {
Serial.begin(9600);
//Setup the starting light level limits
lightLevel=analogRead(photoRPin);
minLight=lightLevel-20;
maxLight=lightLevel;
}
void loop(){
//auto-adjust the minimum and maximum limits in real time
lightLevel=analogRead(photoRPin);
if(minLight>lightLevel){
minLight=lightLevel;
}
if(maxLight<lightLevel){
maxLight=lightLevel;
}
//Adjust the light level to produce a result between 0 and 100.
adjustedLightLevel = map(lightLevel, minLight, maxLight, 0, 100);
Serial.println(adjustedLightLevel);
delay(450);
}[/code]
Processing Code (……so far)[code]import processing.serial.*;
Serial myPort; // Create object from Serial class
PImage bear;
int rand;
int xPos;
int yPos;
int state;
void setup() {
size(displayWidth, displayHeight);
myPort = new Serial(this, "/dev/tty.usbmodemfa131", 9600);
rand = int(random(0,9));
takerandomimage("bear_" + nf(rand, 3) + ".jpg");
}
void takerandomimage(String fn) {
bear = loadImage(fn);
}
void draw() {
/*if (mousePressed) {
xPos = int(random(100,800));
yPos = int(random(100,600));
image(bear,xPos,yPos);
mousePressed = false;
}*/
while (myPort.available() > 0) {
state = myPort.read();
println(state);
}
if (state >=0 && state <= 70){
xPos = int(random(100,800));
yPos = int(random(100,600));
image(bear,xPos,yPos);
} else if (state >=71 && state <= 100) {
image(bear,0,0);
}
}[/code]
(and I did try turning off the Arduino Serial. Still the weird non-correspondance....)
JLCPCB – Prototype 10 PCBs for $2 (For Any Color)
China’s Largest PCB Prototype Enterprise, 600,000+ Customers & 10,000+ Online Orders Daily
How to Get PCB Cash Coupon from JLCPCB: https://bit.ly/2GMCH9w