Skip to content

Instantly share code, notes, and snippets.

@Annon201
Annon201 / Prac2.asm
Created November 26, 2019 09:12
Read a switch and flash some LEDs - AVR8/atmega2560
; Created: 25/11/2019 9:45:37 AM
; Author : Annon
; defining some labels to make the code easier to read
.def LEDs = r20
.def Switches = r21
.def outer = r22 .def inner = r23
.def inner1 = r24
.org 0000 ; start the code at 0x0000 - we arent using interrupts so don't waste space on them
.db "Look ma, I'm on a chip!!" ; :P
Start:

MCP23008 Button input Board

This board has like.. a bunch of buttons on it. It is controlled by the MCP23008E/P I2C I/O Expander.

It supports configurable 3 bit i2c addresses and allows upto 8 devices on the i2c bus.

The datasheet for the IC can be found on the Microchip website

Pictures

The IC

:100000000C9462000C9465030C943E030C948A00DB
:100010000C948A000C948A000C948A000C948A0038
:100020000C948A000C948A000C948A000C948A0028
:100030000C948A000C948A000C948A000C948A0018
:100040000C94F4020C948A000C94C2020C949C024E
:100050000C948A000C948A000C948A000C948A00F8
:100060000C948A000C948A000000000025002800EF
:100070002B0000000000240027002A0000000000E0
:1000800023002600290004040404040404040202DA
:100090000202020203030303030301020408102007
#define CONSERVATIVE
#define BUFSIZE 8
#define pulse() pinMode(ioPin, OUTPUT); delayMicroseconds(16); pinMode(ioPin, INPUT)
#define qPulse() pinMode(ioPin, OUTPUT); delayMicroseconds(8); pinMode(ioPin, INPUT)
#define ioPin 3
unsigned char dynBits[] =
{
B10100010,