Skip to content

Instantly share code, notes, and snippets.

@awkward-ninja
Last active November 23, 2017 18:45
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save awkward-ninja/cee598222f29cb8944463351b500ed48 to your computer and use it in GitHub Desktop.
Save awkward-ninja/cee598222f29cb8944463351b500ed48 to your computer and use it in GitHub Desktop.
Barebones Blinky for Arduino Nano over USB
#include "Arduino.h"
int main () {
init ();
pinMode (13, OUTPUT);
for (;;) {
digitalWrite (13, HIGH);
delay (100);
digitalWrite (13, LOW);
delay (100);
}
}
ARDUINO_DIR = /usr/share/arduino/hardware/arduino
ARDUINO_CORE_DIR = $(ARDUINO_DIR)/cores/arduino
ARCH = atmega328p
CORE_SRC = \
$(ARDUINO_CORE_DIR)/wiring.c \
$(ARDUINO_CORE_DIR)/wiring_digital.c
.PHONY: all
all: main.elf
.PHONY: clean
clean:
-rm -f main.elf
.PHONY: install
install: main.elf
avrdude -p $(ARCH) -c arduino -P /dev/ttyUSB0 -b 57600 -D -U flash:w:$<
main.elf: main.c $(CORE_SRC)
avr-gcc -mmcu=$(ARCH) -DF_CPU=16000000L \
-I $(ARDUINO_CORE_DIR) \
-I $(ARDUINO_DIR)/variants/eightanaloginputs \
-o $@ $^
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment