IFD:EAI SoS21/course material/Session 2: Data Types, Classes and Piezo Amp: Difference between revisions
From Medien Wiki
(5 intermediate revisions by the same user not shown) | |||
Line 1: | Line 1: | ||
==Session 2: Basics== | ==Session 2: Basics== | ||
===Piezo Amp=== | |||
* An explanation of the type of amplifier for our piezo disc is given here: [http://www.openmusiclabs.com/learning/sensors/electret-microphones/ Open Music Labs] | |||
* Where to buy the teensy and audio shield (rev. D)? [https://www.exp-tech.de/plattformen/teensy/9596/teensy-4.0-development-board e.g. Exptech] | |||
Needed Material: | |||
* Teensy 4.0 | |||
* Teensy Audio Shield Rev.D | |||
* Piezo Disc (bigger is louder, i use 3.5 cm outer diameter) | |||
* flexible Cable with two wires | |||
* N-Channel JFET Type Transistor either | |||
** [https://pdf1.alldatasheet.com/datasheet-pdf/view/100890/SANYO/2SK596.html 2SK596] scrapped from electret mic or | |||
** [https://www.musikding.de/2N5457 2N5457] together with a 10kOhm -- 100kOhm Resistor | |||
===C++ Intro=== | |||
You can find (and edit) the code examples from today in the following links: | You can find (and edit) the code examples from today in the following links: | ||
* [https://replit.com/@abnutzer/ | * [https://replit.com/@abnutzer/DataTypesInCpp Data Types] | ||
* [https://replit.com/@abnutzer/ClassesInCpp Classes] | * [https://replit.com/@abnutzer/ClassesInCpp Classes] | ||
Line 16: | Line 29: | ||
}</source> Include that function in our Point2D class and make it calculate the distance! | }</source> Include that function in our Point2D class and make it calculate the distance! | ||
# Last but not least, watch [https://youtu.be/W0aE-w61Cb8 that introductory video about pointers]. We will use pointers next week! | # Last but not least, watch [https://youtu.be/W0aE-w61Cb8 that introductory video about pointers]. We will use pointers next week! | ||
Send me your code via mail or a link to your Repl.it repository until friday!!! Ask if something doesn't work!!! | Send me your code via mail or a link to your Repl.it repository until friday!!! Ask if something doesn't work!!! | ||
... | ... | ||
Have fun! :D | Have fun! :D |
Latest revision as of 14:11, 26 April 2021
Session 2: Basics
Piezo Amp
- An explanation of the type of amplifier for our piezo disc is given here: Open Music Labs
- Where to buy the teensy and audio shield (rev. D)? e.g. Exptech
Needed Material:
- Teensy 4.0
- Teensy Audio Shield Rev.D
- Piezo Disc (bigger is louder, i use 3.5 cm outer diameter)
- flexible Cable with two wires
- N-Channel JFET Type Transistor either
C++ Intro
You can find (and edit) the code examples from today in the following links:
Homework
As a homework task I want you to extend the code in Repl.it. as follows:
- For the "Classes" example above, add a Header (Point2D.h) and a Function definitions (Point2D.cpp) file to the project where you define the class and its functions seperately. Finally include the header file with #include "Point2D.h" in the main.cpp file, so we can use our custom C++ class. Watch this online tutorial to learn how to do that! You don't need to put the .h and .cpp file in different folders, as shown in the video. Putting them in the same folder as the main.cpp works as well.
- As a second task, I want you to extend the code of the Point2D to include a function to measure the distance between two points in 2D space. Do you remember the "Theorem of Pythagoras"? The function body should look like this: Include that function in our Point2D class and make it calculate the distance!
float distanceToOtherPoint(Point2D otherPoint) { float distance = ... // calculate distance here return distance; }
- Last but not least, watch that introductory video about pointers. We will use pointers next week!
Send me your code via mail or a link to your Repl.it repository until friday!!! Ask if something doesn't work!!!
...
Have fun! :D