-
Notifications
You must be signed in to change notification settings - Fork 21
Assignments
Christopher Baker edited this page Oct 5, 2013
·
12 revisions
Upcoming questions ...
- What are ofPushMatrix()
and ofPopMatrix()
and how do they work with ofTranslate()
, ofRotate()
and ofScale()
?
- What are ofPushStyle()
and ofPopStyle()
and how does it work with ofSetColor()
... etc.
- (sugested) Review Chapter 5 (object oriented programming, pointers, etc).
- Extend the particle system in class by doing several of the following (to meet your particular artistic goals):
- Add a "force" other than gravity. You might consider modifying the particle's acceleration or modifying the particle's velocity directly. The force can be attractive (like a black hole) or repulsive (like oil and water). Consider only applying the force to particles whose distance is less than some threshold (see the distance calculation in the code to see how to calculate the distance between two points).
- Add several other "constraints". The
age
/maxAge
is a constraint that we use to remove particles if they are of a certain age. Other ideas include:- Creatively deal with the edges instead of letting the particles fall off the screen (and die), make the particles wrap around to the other side of the screen (like asteroids) (see this video if you don't know what I mean ... http://www.youtube.com/watch?v=cZfsnA7dAHI)
- Or, have them bounce off of the walls (we did something like this in class)
- Incorporate additional media (fonts, letters, images, shapes, etc)
- At the end of each particle's life, cause new particles to be spawned from the location where the old particle died (kind of like fireworks ...).
- Use the particles to control something besides the visuals -- maybe use the headings of the particles to control the pitch or speed of videos or sound or Arduino output.
- ...
- You must also demonstate your ability to extend the
BaseParticle
to create your own custom particle. See theSpecialParticle
class for an example of how to do this. - Please ask questions on the forum!
- Be able to answer the following questions from memory (or without a reference):
- What is a
class
? - What is an
object
? - What is object-oriented programming?
- What is a pointer?
- What is a "shared pointer" (
ofPtr
is a shared pointer. What does it do? How does it differ from a "normal" pointer?)
- What is a
- Combining the assignments from this week and last, create a program system that implements bidirectional communication between the Arduino and openFrameworks. The Arduino should send (at least) three values (buttons and/or potentiometers or other sensor data) to openFrameworks where it should be displayed animated or rendered in some way -- be creative (hints: check out
ofImage
,ofTrueTypeFont
,ofMesh
, etc)! openFrameworks should simultaneously be able to send (at least) three values generated by the keyboard, mouse or other source to the Arduino (hint: Consider using the virtual buttons shown in this weeks' examples, or perhaps create your own "slider" or other controller or data stream? Also check out the serial.write() or serial.writeBytes()*). Use the three (or more) values streaming from openFrameworks to control output on the Arduino. This could be the brightness of an LED or something more exciting like a motor or a solenoid (hint: on the Arduino you will useSerial.read()
). Please set up your piece of code poetry during the first 10 minutes of class next week so we can make our way around the room and check out what you've made. - Be able to answer the following questions from memory (or without a reference):
- How are numbers represented in base 2 (binary)?
- How would you represent the decimal number 55 in binary?
- How might you represent the number -55 in binary?
- What are bits?
- What are bytes?
- What is the difference between a serial connection and a paraellel connection?
- What are bauds?
- What is an array?
- How is an array different from a std::vector<>?
- What is a "reference"?
- What is a "pointer"?
- What do the
new
anddelete
keywords do? - What are the risks of using pointers and
new
anddelete
? - What are the alternatives to
new
anddelete
?
*To use ofSerial::writeBytes()
consider the following example:
// in void setup()
ofSerial mySerial;
mySerial.setup(); // fill in your data
// ...
// in void update()
ofBuffer outputBuffer;
outputBuffer.append(ofToString(VALUE_0));
outputBuffer.append(",");
outputBuffer.append(ofToString(VALUE_1));
outputBuffer.append(",");
outputBuffer.append(ofToString(VALUE_2));
outputBuffer.append("\r\n");
int numBytesWritten = mySerial.writeBytes(outputBuffer.getBinaryBuffer(), outputBuffer.size());
if(numBytesWritten != outputBuffer.size())
{
// warning ... something probably went wrong ...
}
// You will then READ the values in a similar way on the arduino using Serial.read();
// Consider this approach:
// http://stackoverflow.com/questions/11068450/arduino-c-language-parsing-string-with-delimiter-input-through-serial-interfa
- Do the std::vector tutorial here.
- Expand our in-class demonstration to animate the incoming potentiometer data.
- Ideas: rotate the hands on a clock, rotate an image, etc.
- Expand our in-class demonstration to send the state of 2 potentiometers from Arduino to openFrameworks.
- Hints: I recommend sending your values from Arduino in the following format:
VALUE1,VALUE2\r\n
. To do this you'll do:Serial.print(VALUE1); Serial.print(","); Serial.println(VALUE2);
Then on the openFrameworks side, everything will look the same but you will SPLIT the string at the comma usingofSplitString
(you'll need to do the std::vector tutorial for this!) and extract the text of the two numbers, which you will then convert to integers usingofToInt
. - Ideas: make an etch-a-sketch, manipulate the y/z rotation of an image, control frequency and pitch of a tone.
- Hints: I recommend sending your values from Arduino in the following format:
- Draw a block of 256 vertical lines right next to each other using a
for
loop.- Make all of the
odd
lines red and all ofeven
lines yellow. (hint: use andif
statement and the modulo operator%
) - Change the color of those lines to form a gradient, with the first line white and the last line black.
- (Bonus) Produce the same visual output (the gradient) without a
for
loop. (hint: Consider usingofMesh
orofVboMesh
)
- Make all of the
- Be able to answer the following questions from memory:
- What is a vector?
- What is does an 'if' - 'else' - statement do?
- What does a 'switch' statement do?
- What does a
for
loop do and how does it differ from awhile
loop? - What is a modulo operator and how do you use it?
- Read Chapters 4, 5, 8 in Programming Interactivity
- Program an Arduino to blink the message
What hath God wrought
inAmericanInternational Morse Code on an LED. Use one variable to control the length of thedits
and and one variable to control the length of thedahs
. Do not "hard code" any numbers in your program, except when assigning variables.- Place program in folder
ExperimentalMedia/people/YOUR_USERNAME/Week4/Arduino/MorseBasic
- Place program in folder
-
Bonus Modify the Arduino program to encode any arbitrary string in morse code using the LED.
- Place program in folder
ExperimentalMedia/people/YOUR_USERNAME/Week4/Arduino/MorseAdvanced
- Place program in folder
-
Bonus Use the camera and openFrameworks to watch the LED, decipher the message and print it on the screen.
- Place program in folder
ExperimentalMedia/people/YOUR_USERNAME/Week4/openFrameworks/MorseDecoder
- Place program in folder
- Render Sol LeWitt’s 1971 Wall Drawing for the School of the MFA Boston in openFrameworks. Save your output as a
.pdf
. (hint: considerofGetWidth()
,ofGetHeight()
,ofRandom()
,ofLine()
,ofCircle()
,examples/pdfExample
).- Place program in folder
ExperimentalMedia/people/YOUR_USERNAME/Week4/openFrameworks/SolLewitt1971
- Place
pdf
in folderExperimentalMedia/people/YOUR_USERNAME/Week4/openFrameworks/SolLewitt1971/bin/*.pdf
- Place program in folder
-
Bonus Add the ability to generate a new (and different) rendering of the piece each time the spacebar is pressed.
- Place program in folder
ExperimentalMedia/people/YOUR_USERNAME/Week4/openFrameworks/SolLewitt1971Advanced
- Place program in folder
- Add all of your programs and output to your fork of our class repository and issue a pull request to me before class begins.
- Be able to answer the following questions from memory:
- What do
int
,long
,short
andbyte
have in common? How are they different? - What do
float
anddouble
have in common? How are they different? - What does the
unsigned
mean when used withint
,long
,short
andbyte
? - What is the function of the
void setup()
function in both openFrameworks and Arduino? - What is the function of the
void loop()
in Arduino andvoid draw()
in openFrameworks? - What is a preprocessor?
- What is a compiler?
- What is a linker?
- What is an IDE?
- What programming language forms the foundation of both Arduino and openFrameworks? Who invented the language and when?
- What do
- Remember to work together!
- Bring your Arduino to class.
- Command Line Tasks (hint: learn more about command options with
man
- e.g.man ls
)- Download and save this image file with
curl
. - Change the name of the image file above using
mv
. - Make a duplicate of the image file using
cp
. - List the contents of your home directory using the long form. Now do it using
~
. Now do it printing each file's serial number. - Count the number of Presidential orders on the topic of "Fitness" in this file using
curl
, pipes|
,wc
andgrep
. Do it all in a single line. Confirm your answer using Excel or Google docs.
- Download and save this image file with
- Get familiar with Git / Github. Check out this brief github Bootcamp.
- Set up git for your platform. Instructions here. While git will suggest that you "Forget the terminal. Download our native app instead.", please use the command-line version for this assignment, rather than the native app. If you hate the command line version, you're free to use the native app after this!
- Fork our class repository (you may have already done this in class).
- Clone your fork of our repository into
YOUR_OPEN_FRAMEWORKS_ROOT/ExperimentalMedia
- Create a folder called
YOUR_OPEN_FRAMEWORKS_ROOT/ExperimentalMedia/people/YOUR_USERNAME
(fill in the blanks appropriately) - Using
nano
on the command line, create a markdown file in your folder calledabout.md
and add some information about yourself. Try out some of the markdown formatting features. Get a quick markdown tutorial here. - Add your new file to a change set (hint: use
git add
) - Commit your changes (hint: use `git commit -m "Your commit note here ...")
- Push your commit(s) online to github (hint: use
git push origin
). - Once back on the github site, you should see your changes. Issue a "Pull Request" for me to merge your changes into the main repository.
- Work together on this! Teach each other! If you get stuck, open an issue and I'll jump in.
- Bonus: Once you see that other people's changes are showing up the the main class repository, "pull" those changes into your repository, so your repository stays synchronized with the main repository. (hint:
git pull upstream master
)
- Make sure you read chapter 6 from Programming Interactivity.
- Sign up for the openFrameworks forum. Browse around and see what people are up to. Perhaps consider introducing yourself.
- If you are an IRC user, you can usually find other openFrameworks users here.
- If you are a Twitter user, consider following @openframeworks and @ofxaddons.
- Using the tag openFrameworks find at least openFrameworks works that you find particularly interesting.
- Bring your Arduino to class for week 3.
- Get Books!
- Getting Started with Arduino, Second Edition, By Massimo Banzi
- This is optional because Programming Interactivity covers most of it, but it’s a nice handly little guide if you want to drop an extra $5.
-
Programming Interactivity, Joshua Noble
- This will be our main reference.
- Note: Both books are available in DRM-free eBook/PDF form from http://oreilly.com/ Steep discounts (50%+) are available: http://www.google.com/?q=coupon+oreilly.com
- Getting Started with Arduino, Second Edition, By Massimo Banzi
- Read!
- Ch. 1, 2 and 6 of Programming Interactivity
- Install!
- OpenFrameworks (0.8.0 for your platform) http://www.openframeworks.cc/download/
- You will also need to install the IDE / Developer tools for your platform
- OS X - Install XCode from the App Store
- Note: This documentation is mostly wrong : http://www.openframeworks.cc/setup/xcode/. Ignore it.
- Windows - Install Visual Studio 2012 or Codeblocks
- Note: This documentation is mostly right: http://www.openframeworks.cc/setup/vs/ Do what it says!
- Linux - Install Codeblocks and oF dependencies
- Note: This documentation is mostly right: http://www.openframeworks.cc/setup/linux-codeblocks/ Do what it says.
- Arduino (latest version) http://arduino.cc/en/Main/Software
- Processing (latest version) http://processing.org/download/
- Why?! We may occasionally cross-reference our oF work with Processing.
- Fritzing (latest version) http://fritzing.org/download/
- Git (follow the instructions for your platform here: http://git-scm.com/downloads)
- OpenFrameworks (0.8.0 for your platform) http://www.openframeworks.cc/download/
- Sign up!
- Sign up for the blog! http://courses.christopherbaker.net/2013/Fall/ExperimentalMedia/wp-login.php?action=register
- Sign up for http://github.com. Just get a free account.
- Get Equipment
- Acquire an Arduino UNO or newer ( in reality older ones with the Atmega 328 or better will be fine). Arduino UNOs are available in SAIC resale or in the vending machines. You are welcome to get a newer Arduino (like a Due), but you probably won’t need it. That said. the Leonardo is pretty rad since it can emulate USB devices like a keyboard.
- Do it!
- Attempt to get openFrameworks Examples running!