EE109 – Fall 2022: Introduction to Embedded Systems
Be sure you have all the tools installed (more info available here)
- Windows: Get NotePad++
- Mac: Get BBEdit
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 example/project
- 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 project name for your new example/project: 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)
- Create a new text file (using BBEdit (Mac) or Notepad++ (Windows)) and write your C code and save the file with a .c extension (i.e. main.c or example.c) in the project folder you created (i.e. Desktop/ee109/project_folder).
- Use your text editor to open and edit the "Makefile" in your project 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:
Make sure you see your .c file and the Makefile (make sure it isn't name Makefile.txt or anything different like that.)
- At the terminal/command prompt compile your program by typing:
Fix any compile errors.
- Once you compile, 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".