This was really cute and fun to do, I was a little confused at first on how to set things up but it worked out well in the end I played a little with the code to see how to make the penguin bigger and smaller, It’s interesting to note that when you change the number from a decimal to a whole one the change in size isn’t very dramatic when you move the light.

also realized that this is supposed to be an owl and I’ve been calling it a penguin this entire time…
Processing code
//March 28, 2017
//Earl Mark
//Make an owl Grow according to the light level
//Owl modified after Reas and Fry Intro to Processing Text
//Exercise:
// 1. Make more than one owl
// 2. Have the owl(s) adjust according to sound detector values (tutorial 15 of the arduino 101 tutorials)
// 3. Make the owl(s) eyes blink such as when someone claps their hands
import processing.serial.*;
Serial myPort; // The serial port
String inString; // Input string from serial port
int lf = 10; // ASCII linefeed
String[] photoSensorRead; //for text array for output from arduino
float n; //for raw value from arduino
//int brightness; //for adjusted value from arduino
void setup(){
size(1280, 720);
myPort=new Serial(this, "COM20", 9600);
myPort.bufferUntil(lf);
}
void draw(){
background(150,200,255);
//read photosensor value from serial port
photoSensorRead = split(inString, '='); //subdivide text string at " = "
//println("photoSensorRead " + photoSensorRead);
//parse text value of photosensor value
if (null != photoSensorRead && photoSensorRead.length > 1) {
String num = photoSensorRead[1];
n = float(Integer.parseInt(num.trim()));
}
randomSeed(0);
float scale = map(n, 0.0, 1025, 0.12, random(1.5, 2.75));
owl(width/2.0, height - 10, int(random(50, 120)), scale);
}
void owl(float x, float y, int g, float s) {
pushMatrix();
translate(x, y);
scale(s); // Set the size
stroke(138-g, 138-g, 125-g); // Set the color value
strokeWeight(70);
line(0, -35, 0, -65); // Body
noStroke();
fill(255);
ellipse(-17.5, -65, 35, 35); // Left eye dome
ellipse(17.5, -65, 35, 35); // Right eye dome
arc(0, -65, 70, 70, 0, PI); // Chin
fill(51, 51, 30);
ellipse(-14, -65, 8, 8); // Left eye
ellipse(14, -65, 8, 8); // Right eye
quad(0, -58, 4, -51, 0, -44, -4, -51); // Beak
strokeWeight(1);
popMatrix();
}
void serialEvent(Serial p) {
inString = p.readString();
}
Arduino code
//Earl Mark 3/23/17
int photocellPin0 = A0; // the cell and 10K pulldown are connected to A0
int photocellReading0;
void setup() {
// initialize serial communication:
Serial.begin(9600);
}
void loop(){
photocellReading0 = analogRead(photocellPin0); //read photoresister
Serial.print(" _ Analog reading 0 = "); //output value to serial port
Serial.println(photocellReading0);
}