Skip to content

Latest commit

 

History

History
397 lines (381 loc) · 35.5 KB

README.md

File metadata and controls

397 lines (381 loc) · 35.5 KB

Use the light sensor in an Adafruit Circuit Playground as an input device in a Processing program

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.

Step 1: Plug in the Adafruit Circuit Playground and start Processing

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.

Step 2: Run this sample program

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.

Step 3: Write your own program

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!

Step 4: Make a short video (under 10 seconds and smaller than 25MB)

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 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 in Google Classroom.

Samples of Student Work

Sean
Curtis
Kenny
Cameron
Pansy
Nash
Koey
Leah
Mikey
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
Christina
Joanne
Caitlyn
Ye
Van
Joshua
Justin
Eric
Dylan
Mira
Ivana
Gary
Emily
Akemi
William
Stephen
Daniel
Lilia
Andrew
Luke
Liam
Hayden
Jacob
Noella
Eric
Joyce
Vivian
Lexian
Rafael
Nathaniel
Nicolas
Brian
Justin
Stella
Wendy
Joseph
Joshua
Brianna
Justin
Qiao Yan
Caden
Tommy
David
Darren
Hui Shan
Brennan
Jennifer
Deion
Aaron
Jackie
Christina
Joselino
Nathan
Munkhtushie
Kyle
Noelle
Andy
Audrey
William
Jenna
Ryan
Nathan
Ivy
Gabriel
Joyce
Mika
Sophia
Ethan
Emeley
Nate
Eric
Koen
Annie
Brayden
Jason
Ivan
Tobias
Willa
James
Kathleen
Juan
Toby
Ryan
Ryan
Evangeline
Miriam
Loren
Sally
Tennyson
Annynaraizel
Alvin
Sonia
AndreiRock
Maxwell
Humphrey
Hannah
Fiona
Isaac
Karla
Saw
Aiden
Theo
Gage
Tara
Maya
Dylan
Nicholas
Samson
Patrick
Diego
Luca
Cuiyin
Laura
Noel
Yiyuan
Artiom
Marina
Kevin
Samantha
Charlotte
Dylan
Joanna
Andy
Victor
Ivan
Kaijun
Michelle
Kyle
Douglas
Jerry
Gage
Angela
Ivona
Sandy
Johnathan
Robin
Kayla
Justin
Leanna
Philix
Lixin
Audrey
Emily
Haoheng
Gabriel
Alejandro
Angela
Kelvin
Lily
Aaron
Terrance
Jessica
Grace
Daniil
Matthew
Leanna
Andre
Felicia
Andrew
Calvin
Aaron
Justin
Kyla
Calvin
Alessandra
James
Yuxi
Aaron
Hao
Katie
Benjamin
Etienne
Matthew
Wanyan
Kaitlyn
Lilah
Finely
Jason
Ethan
Sebastian
Myles
Oliver
Jaden
Austin
Alyssa
Zachary
Jamie
Jacky
Stephanie
Jeffery
Zhixuan
Jonathan
Jaylan
Lotuseana
Shea
YatLong
Luca
Xinuo
Blake
Cherise
Connie
Connor
Jocelyn
Kyle
Alan
Kunlin
Saphire
ZiXi
Alexander
Trevor
Aden
Casey
Chloe
Haofeng
Matthew
Alyssa
Timothy
Zhijian
Quinn
Matthew Ly
Isabella
Leo
Sarah
Ian
Annie
Hyunjae
Nathan
Jaime
Eunbi
Katelyn
Koa
Sabrina
William
Ryan
Chelsea
Tressyn
Henry
Bosco
Pierce
Ronan
Ryan
Jacob
Chase
Erika
Lushi
Tina
Leilani
Caleb
Diamond
Alton
Nathanuel
JunMin
Justin
William
Preston
Katie
Aden
Kylie
Eva
Aegis
Samantha
Jason
Nicholas
Greta
Griffin
Conn
Austin
Elton
JianXiang
Evan
William
Adam
Steven
Layla
Nika
Danny
Kaitlyn
Connor
Lilian
Justin
Dean
Irving
Miles
Carrie
Jenny
Max
Benjamin
Ezra