Pine

🌲 Indoor Infrared receiver and transmitter with temperature sensor 🎐

power AA
wireless Infrared
mcu SAMD21G18
bom items 49
bom cost USD $9.71
vendors 2
completed September 2020

Blinky

blinky easy

Blinky LED on a crystalless Arduino Zero


Before starting

Details

Crystalless option

Create a blinky LED firmware with SAMD21G micro-controller on a custom PCB without crystal.

To ensure the blinky works with the crytalless option, you have to:

  1. Ensure the bootloader code has the crystalless option
  2. Ensure compiled code has the cyrstalless option in build.extra_flags in ~/Library/Arduino15/packages/arduino/hardware/samd/1.8.6/boards.txt on macOS or as part of options in the arduino-cli command
arduino-cli compile --fqbn arduino:samd:arduino_zero_native --build-properties build.extra_flags="-DCRYSTALLESS -D__SAMD21G18A__ {build.usb_flags}" ./

Serial

For serial printing, SerialUSB.println() should be used instead of Serial.println() because SerialUSB uses the Native Port, which is an emulated serial port (USB-CDC).

Upload firmware

  Steps to upload the blinky firmware:

  1. Press the reset button twice to go into the bootloader mode
  2. Run make to upload the blinky firmware with crystalless option

Schematic

Wire up the hardware accordingly

 setup

Code

Download code
#define LED 13

void setup() {
  pinMode(LED, OUTPUT);

  // SerialUSB.begin(9600);
  // while (!SerialUSB) {}
  // delay(1000);

  // SerialUSB.println("Start!");
}

void loop() {
  // SerialUSB.println("HIGH");
  digitalWrite(LED, HIGH);
  delay(200);

  // SerialUSB.println("LOW");
  digitalWrite(LED, LOW);
  delay(200);
}

Makefile

BOARD?=arduino:samd:arduino_zero_native
PORT := $(shell ls /dev/cu.usbmodem*)

.PHONY: default lint all flash clean

default: lint all flash clean

lint:
	cpplint --extensions=ino --filter=-legal/copyright,-whitespace/line_length,-readability/casting,-readability/todo *.ino

all:
	# This custom PCB does not have a crytal on pins PA00 and PA01
	# Hence, use -DCRYSTALLESS to replace the extra_flags in boards.txt
	arduino-cli compile --fqbn $(BOARD) --build-properties build.extra_flags="-DCRYSTALLESS -D__SAMD21G18A__ {build.usb_flags}" ./

flash:
	arduino-cli upload -p $(PORT) --fqbn $(BOARD)

clean:
	rm -r build

References