How to get sensor readings to trigger images
in
Integration and Hardware
•
2 years ago
I already have some code that I am using to play with perlin noise over top of an image and reacting to mouseX and mouseY input. What I want to do now is using a photocell and an Arduino have them control the perlin noise. I am just not sure how to do this. Here is the code I already have:
float noiseScale=0.15;
PImage myImage;
float noiseVal; // took this out of the local variable and made it global
void setup()
{
size(600, 650);
smooth();
PImage img;
img = loadImage("rust_1.jpg"); //loads the stored image to the background
myImage = loadImage("rust_1.jpg");
}
void draw()
{
image(myImage, 0, 0);
color cp = get(mouseX, mouseY); //use if I want to grab
stroke(cp, 150);
for(int x=0; x < width; x++)
{
noiseVal = noise((mouseX+x)*noiseScale,
mouseY*noiseScale);
line(x, mouseY+noiseVal*150, x, height);//the higher the value the sharper the spikes
println (cp);
}
}
float noiseScale=0.15;
PImage myImage;
float noiseVal; // took this out of the local variable and made it global
void setup()
{
size(600, 650);
smooth();
PImage img;
img = loadImage("rust_1.jpg"); //loads the stored image to the background
myImage = loadImage("rust_1.jpg");
}
void draw()
{
image(myImage, 0, 0);
color cp = get(mouseX, mouseY); //use if I want to grab
stroke(cp, 150);
for(int x=0; x < width; x++)
{
noiseVal = noise((mouseX+x)*noiseScale,
mouseY*noiseScale);
line(x, mouseY+noiseVal*150, x, height);//the higher the value the sharper the spikes
println (cp);
}
}
2