In this Arduino lab you will write a program that gets input from the light sensor in the Adafruit Circuit Playground and uses it as an controller so that you can interact with your Virtual Pet from the previous assignment.
Connect the Circuit Playground to your computer with a USB cord. Open Processing. You will need to install a library (you only need to do this once). Choose Sketch | Import Library | Add Library. Type Arduino in the text field labeled Filter. Choose Arduino (Firmata) and click Install.
Copy and paste the following program
import processing.serial.*;
import cc.arduino.*;
Arduino arduino;
public void setup() {
size(500, 500);
arduino = new Arduino(this, Arduino.list()[0], 57600); //change the [0] to a [1] or [2] etc. if your program doesn't work
}
public void draw() {
background(192);
int y = arduino.analogRead(5);
System.out.println(y);
ellipse(250, 2*y, 50, 50);
}Run the program. Pass your hand over the light sensor labeled with a picture of an eye on the Circuit Playground. You should see an ellipse move up and down as the light sensor changes values. Higher values mean more light. The light sensor is circled in the picture below. On some machines, you may need to change the last line in setup() to get the program to work correctly.
Using the sample program as a guide, write your own program that uses the light sensor. Your program doesn't have to work or look like any other. Have fun and be creative!
When you are happy with your program, have a friend make a short video of you interacting with your virtual pet. The video need only show your hand, the arduino and your pet, please don't include anyone's face in the video. See Mr. Simon's example animated gif and the samples of student work below.
Convert the video to an animated gif using a free converter like ezgif.com. Use ezgif's cut video or a similar option to edit your video to under 10 seconds and less than 25MB. Upload your animated gif to your VirtualPet repository. Submit the link to your gif to Google Classroom.
Mr. Simon's virtual pet penguin animated gif
Jonah
Gabriella
Keneth
Johnny
Kaitlyn
Federico
Viva
Chris
Tiffany
Jimmy
Sam
Albert
Michelle
Alison
Nikhita
Eric
Chun Ho
Jocelyn
Zoey
Tyler
Tiffany
Alex
Max
Bruno
Damian
Alvin
Wing
Aiden
Andrew
William
Chris
Kumiko
Karina
Paolo
Breanna
Edward
Jeffrey
Austin
Jason
Haden
Irisa
Matthew
Luke
Hayden
Noella
Eric
Joyce
Vivian
Lexian
Nathan
Rafa
Nicolas