Lab Assignment Setup
The following is a summary of the recommended steps that should be taken for setting up all EE109 lab assignments including the final project.
Before attempting any lab assignmemnts be sure you have all the tools installed as described in the writeup for Lab 0 including the AVR-gcc compiler toolchain and a working text editor such as Visuals Studio Code.
One time setup (both Mac and Windows)
- On your Desktop create a folder “ee109”
- In that “ee109” folder download the Makefile from the website. This will serve as a template that you can copy into any new project you create and just edit a bit.
Setup per assignment
-
Start a terminal (search for Terminal in Mac Finder or “cmd” in Windows) or command window (for both Mac and Windows the terminal/command window will start in your top-level user folder). Mac users can drag the Terminal icon to the application launcher bar so it is permanently available.
-
Go to your ee109 folder on the desktop by using commands in the terminal/command window:
$ cd Desktop/ee109
- Create a new folder with the lab assignment name for your new assignment: Do NOT use spaces or capital letters … use names like (ex1, proj2, button_test, etc.)
$ mkdir proj2 (or whatever name you choose)
- Copy the Makefile into your project_folder.
$ cp Makefile proj2 (replace proj2 with whatever name you chose)
- Now you can change directory into the project_folder by typing:
$ cd proj2 (or whatever name you chose)
-
With your text editor create a new text file and write your C code and save the file with a “.c” extension (i.e. main.c or example.c) in the assignment folder you created (e.g. Desktop/ee109/proj2/main.c).
-
Use your text editor to open and edit the “Makefile” in this assignment folder (not the one in your ee109 folder). Find the line near the top that says OBJECTS=demo.o and change demo.o to ex1.o or proj2.o or whatever prefix you’ve chosen (don’t change it to ex1.c or proj2.c … leave the .o extension.)
-
Save the Makefile.
-
At the terminal/command prompt list the files in your directory:
$ ls
Make sure you see your .c file and the Makefile (make sure it isn’t named Makefile.txt or anything different like that.)
- At the terminal/command prompt compile your program by typing:
$ make
Fix any compile errors.
- Once you compile successfully, do another listing and make sure a .hex file exists.
$ ls (look for a .hex file in the files that are printed)
-
Connect your Arduino via USB. (Windows users may need to edit and save your Makefile again to make sure the COM port listed in the Makefile is set with the correct value that your computer assigned to the Arduino.)
-
Download the code to your Arduino.
$ make flash
- Inspect your results on the Arduino board. Make modifications to your code if need be, but be sure to recompile using “make” and redownload using “make flash”.