• Stars
    star
    688
  • Rank 65,257 (Top 2 %)
  • Language
    C
  • License
    MIT License
  • Created almost 12 years ago
  • Updated over 3 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Code examples for the book "Make: AVR Programming"

Code and Examples from "Make: AVR Programming"

Welcome!

Here you'll find all the code (and more!) for the Maker Media book Make: AVR Programming.

Getting Started

  • First, download the contents of this repository onto your hard-drive. The easiest way is with the "Download ZIP" button above and on the right-hand side of this very web page. Extract the zip file wherever is comfy. (Feel free to clone the repo if you are comfortable with Git.)

  • Most of the projects share a common set of pin defines and a common simple USART serial library in the AVR-Programming-Library directory. The makefiles I've included depend on the directory structure here by default, so don't go moving the folders around unless you also change the path to included files in the makefile.

  • If you're using the Arduino IDE, you'll want to copy the AVR-Programming-Library directory into your sketchbook/libraries folder. If you don't know where this is, you can find out in the "File...Settings" dialog within Arduino. Now you can link your code to use this library simply using "Sketch...Import Library" and selecting the library from the the menu.

  • Now you will be set to open the code, edit it, and flash it into the AVR following the directions in the book.

Repo Layout

All of the project code is organized by the chapters in the book. So if you're looking for an example of some SPI code, see the "Chapter16_SPI" folder for SPI-related projects. That's obvious.

But a bunch of the projects are interesting in addition to the topic covered in the chapter. For instance, "Chapter05_Serial-IO" includes a project that uses the serial communication between your desktop computer and the AVR to turn your computer keyboard into a musical keyboard that plays notes generated on the AVR, turning it into a serial-port-controlled organ. You wouldn't think to go looking in the Serial I/O chapter unles you were following along in the book.

So for an overview all the projects, the file allProjectsList lists them all out by name.

setupProject

If you'd like a blank template to start writing your own AVR code, have a look in the setupProject directory that I've included here. Inside, you'll find main.c and main.h files that are essentially blank and ready to go. main.c makes use of my simple USART library, which is also included an linked in by the Makefile. In short, you could copy this directory, rename files, and start using it in your own projects.

But you don't have to do that manually. Running python setupProject.py myProjectName will create a directory called myProjectName for you, copy the blank main files, renaming them as appropriate, and set up the Makefile accordingly. All that's left for you to do is the hard part -- actually coding.

If you use this setup a lot, you'll want to personalize the Makefile and the two main files to suit your own preferences. That way, whenever you start up a new project, it'll include a customized Makefile that has your programmer, chip type, and favorite baud rate already set.

Finally, if you like to map out your pin definitions in macro definitions, run python createPinDefines.py. The program will ask you what you'd like to call each pin macro (e.g. "LED0") and then which pin on the AVR you'd like to associate with it (e.g. "PB1"). When you're done entering your pin layout, it'll create a "pinDefines.h" file with (I hope) nicely-named macros. Move this file into the right directory, and include it in your code. Calling LED0_SET_HIGH will turn your LED on.

More!

You've read the book, you've built the projects, you've worked through the code. But still you hunger for more projects, more examples, more, more, more! If I may toot my own horn, you should visit LittleHacks.org where I blog about whatever microcontroller projects I'm currently up to.

In particular, if you're reading Make: AVR Programming, and you're interested in fully-elaborated versions of the projects with more photos, videos, and explanation than could fit in a book, head on over to LittleHacks.org's AVR-Programming Section.

Once you've exhausted all of these resources, you should definitely head over to The Cornell University ECE 4760 Final Projects list page. It's an awe-inspiring collection of applications, and sure to spark some creative thoughts. It's all well-documented and there's tons of source code in C. [Professor Land's links section] (http://people.ece.cornell.edu/land/courses/ece4760/#links) is also top-notch, and his lectures on YouTube are also worth a look if you're getting serious about this whole AVR deal.

More Repositories

1

jan_ostmans_synths

Synthesizers for Arduino / AVR ATMega32 from https://janostman.wordpress.com/
C
126
star
2

hackaday-forth

Mecrisp-Stellaris Forth Plus Extra Goodies
Forth
55
star
3

klangorium

Hardware and tutorials for the Hackaday / Logic Noise Klangorium demo board
KiCad Layout
46
star
4

everled

Run a dim LED + microcontroller on 10 uA? Sure! A ripoff of Ted Yapo's Tritilight Project
KiCad Layout
33
star
5

hackaday_supercon_2019_logic_noise_FPGA_workshop

Hackaday Supercon 2019 Logic Noise Badge Workshop
Verilog
28
star
6

hackaday_mqtt

ESP8266 / NodeMCU MQTT Sensor and Display Demo
Lua
19
star
7

arduino_CLI

Experiments with compiling/linking/flashing Arduino-style .ino files without the IDE
Makefile
17
star
8

mqtt-javascript-demo

Demo using Javascript/Websockets as MQTT Client
JavaScript
15
star
9

embed_with_elliot-circular_buffer

Demo code to go along with Hackaday article on circular buffers
Makefile
15
star
10

hackaday_esp-14_power_meter

An experiment in crazy: running an interactive Forth shell on a tiny microcontroller, connected to WiFi
KiCad Layout
14
star
11

barking_dogs_dds_demo

A Quick Demo of doing Direct Digital Synthesis on an AVR / Arduino
C
13
star
12

AVR_ProPack

Circuit bits that make breadboarding with AVR micros less painful!
Shell
8
star
13

Forth-vs-UV-EPROMS

Forth
7
star
14

elliot-s_eggbot

Integrating Bart Dring's Servo Pen Control and GRBL
C
6
star
15

vusbWebinar

Slides and code for O'Reilly Webinar on V-USB AVR Library
C
6
star
16

vusb_tiny_designs

5
star
17

serialMiniproj

Makefile
5
star
18

corona-clock

A quick clock hack for my son during stay-at-home quarantine.
Lua
4
star
19

embed_with_elliot-ARM_makefiles_example

Makefile Examples Disguised as an STM32F4 ARM LED-Blinky Project
C
3
star
20

avr_atomic_demo

Demonstrates problems with interrupts and failure of atomicity / race condition
Makefile
3
star
21

Supercon-Logic-Noise-Workshop

Lost? Start here:
JavaScript
3
star
22

fastboot-made-easy

C++
3
star
23

pid-all-the-things

Intro to PID talk given at CCCamp 2023
HTML
2
star
24

stm32l0_libopencm3_template

The simplest possible working OpenCM3 application for the STM32l0 chips.
Makefile
2
star
25

lowPowerClock

A quick and dirty (approximate) low power clock routine for AVRs
C
1
star
26

stm32f0_libopencm3_template

The simplest possible working OpenCM3 application for the STM32f0 chips.
Makefile
1
star
27

stm32f1_libopencm3_template

The simplest possible working OpenCM3 application for the STM32f1 chips.
Makefile
1
star
28

stm32f3_libopencm3_template

The simplest possible working OpenCM3 application for the STM32f3 chips.
Makefile
1
star
29

stm32f2_libopencm3_template

The simplest possible working OpenCM3 application for the STM32f2 chips.
Makefile
1
star