Tutorials For Marissa

I wrote these tutorials for Marissa Dominguez during her scholarship at the Center for Sensorimotor Neural Engineering. Her work involved designing and building a small, inexpensive electromyography (EMG) data acquisition system. I assumed that since she'd never written a line of code before her scholarship, learning how to program an Arduino take the entire summer. After virtually mastering the Arduino on day two, I decided that she needed a bigger challenge. These tutorials are designed to introduce general programming methods by walking the reader through various exercises.


C++ Tutorial

You can download the raw tutorial here. After unzipping it, you will have a folder titled 'CppTutorialForMarissa.' In that folder you'll find five .cpp files numbered 1 through 5. You guessed it; open the one titled '1Intro.cpp' first. Also in the folder you'll see another folder titled 'Exercises.' You will be instructed to do these exercises as you read along in parts 1 through 5. Each file is to be read from top to bottom, one line at a time (kinda like how a computer reads it).

If you've never done anything in C++ (which should be the case if you're about to use this tutorial), then you'll need to have some way to compile and build your C++ code. This can be done with g++ via the command line or with some interactive development environment (IDE) like Xcode, Microsoft Visual Studio, Geany or Emacs. If you choose to use an IDE, make sure you download the software for your platform (Mac, Windows, Linux). To check that you're ready to begin this tutorial, let's compile and build the file 'exercise1.cpp' in the Exercises folder.

If you're using an IDE, find how to open a new file. (This can usually be done by pressing Control+O or Command+O while in the IDE application. If that doesn't work, there will be some way to open new files by navigating to 'File'->'Open'->'Open New File' or something like that.) Find the file 'exercise1.cpp' and open it. Your IDE will have a button or command to Run the file that's currently open. The output of the program should read, 'Hello World!'.

If you're using the command line, you'll need to know the full path to 'exercise1.cpp.' After I unzipped the folder 'CppTutorialForMarissa,' I put the folder on my Desktop. An easy way to find the full path is to open up the folder containing the file, then right click on the file and select 'Get Info' or 'Properties.' I simply double-clicked the folder 'CppTutorialForMarissa' on my Desktop, then double-clicked the 'Exercises' folder, right-clicked 'exercise1.cpp', and selected 'Get Info.'

I found that the full path to 'exercise1.cpp' on my computer is /Users/justinthompson/Desktop/CppTutorialForMarissa/Exercises/. Yours will be similar. (Note that if you're running Windows, your path will look more like this: C:\ComputerName\OtherStuff\etc\Desktop\etc.) Now I need to tell the computer where to find this file. I do this by typing the following command into the terminal and pressing return:

$ cd /Users/justinthompson/Desktop/CppTutorialForMarissa/Exercises/

Now that the computer knows where to find this file, I have to tell it what to do with it. I want the compiler to take the code in 'exercise1.cpp' and turn it into an executable program named 'Hi.' In the terminal, I run:

$ g++ -o Hi exercise1.cpp

After hitting 'Return,' the compiler will make an executable named 'Hi' and put it in this directory. You can open up the 'Exercises' folder and you'll see the executable. You can run this file by either double-clicking on the executable in the 'Exercises' folder, or we can run this in the terminal:

$ ./Hi

If everything went right, the output of the program should be, 'Hello World!'. Note that you don't need to name the executable that we're making. We could have run this instead:

$ g++ exercise1.cpp

After hitting return, the command above will name the executable 'a.out' by default. You can run a.out like this:

$ ./a.out

Once you run the executable and see 'Hello World!' pop up, you're ready to begin. Have fun!


Python Tutorial

The raw Python tutorial is here. If you've done the C++ tutorial, this will flow naturally. If not, this is Python. You really can't go wrong. Just do some googling and find how to get your system running Python and follow along.