GithubHelp home page GithubHelp logo

arduino's Introduction

Arduino Resources

This repository is dedicated to learning about Arduino and the ATmega328p microcontroller.

I have a Arduino UNO R3.

Important: This respository does not use the Arduino abstraction layer built on top the AVR libc. So there are no methods like digitalWrite(), setup() or loop(). If you wish to work on top of the Arduino abstraction layer, this tutorial is not neccessary, just download the Arduino IDE and hit upload.

Getting Started: Installing the development toolchain

There are several ways to obtain the Arduino developement toolchain. The easiest way is to piggyback on the avr-gcc toolchain installed with the Arduino IDE. On MacOS, you can find the toolchain at ~/Library/Arduino15/packages/arduino/tools.

However, downloading and installing the avr-gcc toolchain in a seperate directory allows for better organization and removes the Arduino IDE dependency.

The following toolchain components need to be installed

  1. avr-binutils
  2. avr-gcc
  3. avr-libc
  4. avrdude (for uploading code to the arduino)

A tutorial for installing all these components can be found at https://www.nongnu.org/avr-libc/user-manual/install_tools.html#path

There are two files, config.sub and config.guess that seem to be out of date for the latest release of avr-libc. Before the configure step, it is advisable to replace these two files with the latest version found at https://github.com/gcc-mirror/gcc/tree/master

Compile, Link and Upload

Once you have installed the toolchain, the compile, link and uplaod process to the Arduino is also not trivial. The following is the Makefile used for compiling the code in the hello-world directory. This Makefile assumes the toolchain was installed in the repository root under a directory named avr-gcc/.

CC=avr-gcc/avr/bin/avr-gcc
MMCU=atmega328p
CPU_CLK_SPEED=16000000UL
PROGRAMMER=arduino
AVRDUDE=avr-gcc/avr/bin/avrdude
OBJCOPY=avr-gcc/avr/bin/avr-objcopy

hello: hello.c
	$(CC) -Os -mmcu=$(MMCU) -DF_CPU=$(CPU_CLK_SPEED) hello.c -o hello.elf
	$(OBJCOPY) -j .text -j .data -O ihex hello.elf hello.hex

upload: hello.hex
	$(AVRDUDE) -c $(PROGRAMMER) -p $(MMCU) -P /dev/cu.usbmodem1101 -U flash:w:hello.hex:i
	

Programs

Many of the are Proof of Concepts, don't expect anything too advanced. I have a plan to make a automatic plant watering circuit. Still need to buy a soil moisture detector and pump.

SOS Program

The SOS program blinks an LED attached to PIN 7 on the arduino in a SOS pattern

Traffic Light Simulator

Simulates a Traffic light cycle

Serial UART Communication

Work in progress: A CLI and arduino program that allows for communication between the device and the computer through USB.

ATmega328p DIP edition Pin Diagram

The datasheet for the ATmega328p microcontroller can be downloaded at https://ww1.microchip.com/downloads/en/DeviceDoc/Atmel-7810-Automotive-Microcontrollers-ATmega328P_Datasheet.pdf

arduino's People

Contributors

coconutjj avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.