diff --git a/Firmware/Old-Simon_C/Makefile b/Firmware/Old-Simon_C/Makefile index f949a91..29ea664 100644 --- a/Firmware/Old-Simon_C/Makefile +++ b/Firmware/Old-Simon_C/Makefile @@ -1,556 +1,556 @@ -# Hey Emacs, this is a -*- makefile -*- -#---------------------------------------------------------------------------- -# WinAVR Makefile Template written by Eric B. Weddington, Jörg Wunsch, et al. -# -# Released to the Public Domain -# -# Additional material for this makefile was written by: -# Peter Fleury -# Tim Henigan -# Colin O'Flynn -# Reiner Patommel -# Markus Pfaff -# Sander Pool -# Frederik Rouleau -# -#---------------------------------------------------------------------------- -# On command line: -# -# make all = Make software. -# -# make clean = Clean out built project files. -# -# make coff = Convert ELF to AVR COFF. -# -# make extcoff = Convert ELF to AVR Extended COFF. -# -# make program = Download the hex file to the device, using avrdude. -# Please customize the avrdude settings below first! -# -# make debug = Start either simulavr or avarice as specified for debugging, -# with avr-gdb or avr-insight as the front end for debugging. -# -# make filename.s = Just compile filename.c into the assembler code only. -# -# make filename.i = Create a preprocessed source file for use in submitting -# bug reports to the GCC project. -# -# To rebuild project do "make clean" then "make all". -#---------------------------------------------------------------------------- - - - -# MCU name -MCU = atmega328 - - -# Processor frequency. -# This will define a symbol, F_CPU, in all source code files equal to the -# processor frequency. You can then use this symbol in your source code to -# calculate timings. Do NOT tack on a 'UL' at the end, this will be done -# automatically to create a 32-bit value in your source code. -F_CPU = 8000000 - - -# Output format. (can be srec, ihex, binary) -FORMAT = ihex - - -# Target file name (without extension). -TARGET = Simon - - -# List C source files here. (C dependencies are automatically generated.) -SRC = $(TARGET).c - - -# List Assembler source files here. -# Make them always end in a capital .S. Files ending in a lowercase .s -# will not be considered source files but generated files (assembler -# output from the compiler), and will be deleted upon "make clean"! -# Even though the DOS/Win* filesystem matches both .s and .S the same, -# it will preserve the spelling of the filenames, and gcc itself does -# care about how the name is spelled on its command-line. -ASRC = - - -# Optimization level, can be [0, 1, 2, 3, s]. -# 0 = turn off optimization. s = optimize for size. -# (Note: 3 is not always the best optimization level. See avr-libc FAQ.) -OPT = s - - -# Debugging format. -# Native formats for AVR-GCC's -g are dwarf-2 [default] or stabs. -# AVR Studio 4.10 requires dwarf-2. -# AVR [Extended] COFF format requires stabs, plus an avr-objcopy run. -DEBUG = dwarf-2 - - -# List any extra directories to look for include files here. -# Each directory must be seperated by a space. -# Use forward slashes for directory separators. -# For a directory that has spaces, enclose it in quotes. -EXTRAINCDIRS = - - -# Compiler flag to set the C Standard level. -# c89 = "ANSI" C -# gnu89 = c89 plus GCC extensions -# c99 = ISO C99 standard (not yet fully implemented) -# gnu99 = c99 plus GCC extensions -CSTANDARD = -std=gnu99 - - -# Place -D or -U options here -CDEFS = -DF_CPU=$(F_CPU)UL - - -# Place -I options here -CINCS = - - - -#---------------- Compiler Options ---------------- -# -g*: generate debugging information -# -O*: optimization level -# -f...: tuning, see GCC manual and avr-libc documentation -# -Wall...: warning level -# -Wa,...: tell GCC to pass this to the assembler. -# -adhlns...: create assembler listing -CFLAGS = -g$(DEBUG) -CFLAGS += $(CDEFS) $(CINCS) -CFLAGS += -O$(OPT) -CFLAGS += -funsigned-char -funsigned-bitfields -fpack-struct -fshort-enums -CFLAGS += -Wall -Wstrict-prototypes -CFLAGS += -Wa,-adhlns=$(<:.c=.lst) -CFLAGS += $(patsubst %,-I%,$(EXTRAINCDIRS)) -CFLAGS += $(CSTANDARD) - - -#---------------- Assembler Options ---------------- -# -Wa,...: tell GCC to pass this to the assembler. -# -ahlms: create listing -# -gstabs: have the assembler create line number information; note that -# for use in COFF files, additional information about filenames -# and function names needs to be present in the assembler source -# files -- see avr-libc docs [FIXME: not yet described there] -ASFLAGS = -Wa,-adhlns=$(<:.S=.lst),-gstabs - - -#---------------- Library Options ---------------- -# Minimalistic printf version -PRINTF_LIB_MIN = -Wl,-u,vfprintf -lprintf_min - -# Floating point printf version (requires MATH_LIB = -lm below) -PRINTF_LIB_FLOAT = -Wl,-u,vfprintf -lprintf_flt - -# If this is left blank, then it will use the Standard printf version. -PRINTF_LIB = -#PRINTF_LIB = $(PRINTF_LIB_MIN) -#PRINTF_LIB = $(PRINTF_LIB_FLOAT) - - -# Minimalistic scanf version -SCANF_LIB_MIN = -Wl,-u,vfscanf -lscanf_min - -# Floating point + %[ scanf version (requires MATH_LIB = -lm below) -SCANF_LIB_FLOAT = -Wl,-u,vfscanf -lscanf_flt - -# If this is left blank, then it will use the Standard scanf version. -SCANF_LIB = -#SCANF_LIB = $(SCANF_LIB_MIN) -#SCANF_LIB = $(SCANF_LIB_FLOAT) - - -MATH_LIB = -lm - - - -#---------------- External Memory Options ---------------- - -# 64 KB of external RAM, starting after internal RAM (ATmega128!), -# used for variables (.data/.bss) and heap (malloc()). -#EXTMEMOPTS = -Wl,-Tdata=0x801100,--defsym=__heap_end=0x80ffff - -# 64 KB of external RAM, starting after internal RAM (ATmega128!), -# only used for heap (malloc()). -#EXTMEMOPTS = -Wl,--defsym=__heap_start=0x801100,--defsym=__heap_end=0x80ffff - -EXTMEMOPTS = - - - -#---------------- Linker Options ---------------- -# -Wl,...: tell GCC to pass this to linker. -# -Map: create map file -# --cref: add cross reference to map file -LDFLAGS = -Wl,-Map=$(TARGET).map,--cref -LDFLAGS += $(EXTMEMOPTS) -LDFLAGS += $(PRINTF_LIB) $(SCANF_LIB) $(MATH_LIB) - - - -#---------------- Programming Options (avrdude serial bootloader) ---------------- - -#"C:\arduino\hardware\tools\avr\bin\avrdude" -PCOM3 -c stk500v1 -patmega168 -b19200 -Uflash:w:Simon-PTH-v1.hex -V -F -C"C:\arduino\hardware\tools\avr\etc\avrdude.conf" -#avrdude -PCOM3 -c stk500v1 -patmega168 -b19200 -Uflash:w:Simon-PTH-v1.hex -V -F -SERIAL_AVRDUDE = avrdude -#SERIAL_AVRDUDE_CONFIG = "C:\arduino\hardware\tools\avr\etc\avrdude.conf" -SERIAL_AVRDUDE_PORT = COM3 -SERIAL_AVRDUDE_SPEED = 19200 -SERIAL_AVRDUDE_PROGRAMMER = stk500v1 - -SERIAL_AVRDUDE_FLAGS = -p $(MCU) -P $(SERIAL_AVRDUDE_PORT) -c $(SERIAL_AVRDUDE_PROGRAMMER) -b$(SERIAL_AVRDUDE_SPEED) -#SERIAL_AVRDUDE_FLAGS += -C$(SERIAL_AVRDUDE_CONFIG) -SERIAL_AVRDUDE_FLAGS += $(AVRDUDE_NO_VERIFY) -SERIAL_AVRDUDE_FLAGS += $(AVRDUDE_VERBOSE) -SERIAL_AVRDUDE_FLAGS += $(AVRDUDE_ERASE_COUNTER) - - -#---------------- Programming Options (avrdude) ---------------- - -# Programming hardware: alf avr910 avrisp bascom bsd -# dt006 pavr picoweb pony-stk200 sp12 stk200 stk500 -# -# Type: avrdude -c ? -# to get a full listing. -AVRDUDE_PROGRAMMER = stk200 -#AVRDUDE_PROGRAMMER = ponyser - -# com1 = serial port. Use lpt1 to connect to parallel port. -AVRDUDE_PORT = lpt1 -#AVRDUDE_PORT = COM1 - -AVRDUDE_WRITE_FLASH = -U flash:w:$(TARGET).hex -#AVRDUDE_WRITE_EEPROM = -U eeprom:w:$(TARGET).eep - - -# Uncomment the following if you want avrdude's erase cycle counter. -# Note that this counter needs to be initialized first using -Yn, -# see avrdude manual. -#AVRDUDE_ERASE_COUNTER = -y - -# Uncomment the following if you do /not/ wish a verification to be -# performed after programming the device. -#AVRDUDE_NO_VERIFY = -V - -# Increase verbosity level. Please use this when submitting bug -# reports about avrdude. See -# to submit bug reports. -#AVRDUDE_VERBOSE = -v -v - -AVRDUDE_FLAGS = -p $(MCU) -P $(AVRDUDE_PORT) -c $(AVRDUDE_PROGRAMMER) -AVRDUDE_FLAGS += $(AVRDUDE_NO_VERIFY) -AVRDUDE_FLAGS += $(AVRDUDE_VERBOSE) -AVRDUDE_FLAGS += $(AVRDUDE_ERASE_COUNTER) - -#---------------- Programming Options (STK500) ---------------- -# Programming hardware: stk500 (the AVR MKII ISP version) - -STK500 = stk500 - -# Location of STK500.exe - no trailing '\' -STK500_PATH = C:\Program Files\Atmel\AVR Tools\STK500 - -# The STK500 AVR ISP MKII is USB. The USB drivers must already be installed. -# Do this normally by installing AVR Studio. -STK500_PORT = USB - -#-erase chip -Program Flash -Verify Flash -File name -Serial programing(ISP) -STK500_WRITE_FLASH = -e -pf -vf -if$(TARGET).hex -ms - -STK500_FLAGS = -d$(MCU) -c$(STK500_PORT) - -#-Set ISP frequency to 250kHz. Limit is 1/4 of internal osc which is default 1MHz -#Reduce this to 100kHz if you run into flash verification problems in low-voltage systems -STK500_FLAGS += -I250kHz - -#---------------- Debugging Options ---------------- - -# For simulavr only - target MCU frequency. -DEBUG_MFREQ = $(F_CPU) - -# Set the DEBUG_UI to either gdb or insight. -# DEBUG_UI = gdb -DEBUG_UI = insight - -# Set the debugging back-end to either avarice, simulavr. -DEBUG_BACKEND = avarice -#DEBUG_BACKEND = simulavr - -# GDB Init Filename. -GDBINIT_FILE = __avr_gdbinit - -# When using avarice settings for the JTAG -JTAG_DEV = /dev/com1 - -# Debugging port used to communicate between GDB / avarice / simulavr. -DEBUG_PORT = 4242 - -# Debugging host used to communicate between GDB / avarice / simulavr, normally -# just set to localhost unless doing some sort of crazy debugging when -# avarice is running on a different computer. -DEBUG_HOST = localhost - - - -#============================================================================ - - -# Define programs and commands. -SHELL = sh -CC = avr-gcc -OBJCOPY = avr-objcopy -OBJDUMP = avr-objdump -SIZE = avr-size -NM = avr-nm -AVRDUDE = avrdude -REMOVE = rm -f -COPY = cp -WINSHELL = cmd - - -# Define Messages -# English -MSG_ERRORS_NONE = Errors: none -MSG_BEGIN = -------- begin -------- -MSG_END = -------- end -------- -MSG_SIZE_BEFORE = Size before: -MSG_SIZE_AFTER = Size after: -MSG_COFF = Converting to AVR COFF: -MSG_EXTENDED_COFF = Converting to AVR Extended COFF: -MSG_FLASH = Creating load file for Flash: -MSG_EEPROM = Creating load file for EEPROM: -MSG_EXTENDED_LISTING = Creating Extended Listing: -MSG_SYMBOL_TABLE = Creating Symbol Table: -MSG_LINKING = Linking: -MSG_COMPILING = Compiling: -MSG_ASSEMBLING = Assembling: -MSG_CLEANING = Cleaning project: - - - - -# Define all object files. -OBJ = $(SRC:.c=.o) $(ASRC:.S=.o) - -# Define all listing files. -LST = $(SRC:.c=.lst) $(ASRC:.S=.lst) - - -# Compiler flags to generate dependency files. -GENDEPFLAGS = -MD -MP -MF .dep/$(@F).d - - -# Combine all necessary flags and optional flags. -# Add target processor to flags. -ALL_CFLAGS = -mmcu=$(MCU) -I. $(CFLAGS) $(GENDEPFLAGS) -ALL_ASFLAGS = -mmcu=$(MCU) -I. -x assembler-with-cpp $(ASFLAGS) - - - - - -# Default target. -all: begin gccversion sizebefore build sizeafter end - -build: elf hex eep lss sym - -elf: $(TARGET).elf -hex: $(TARGET).hex -eep: $(TARGET).eep -lss: $(TARGET).lss -sym: $(TARGET).sym - - - -# Eye candy. -# AVR Studio 3.x does not check make's exit code but relies on -# the following magic strings to be generated by the compile job. -begin: - @echo - @echo $(MSG_BEGIN) - -end: - @echo $(MSG_END) - @echo - - -# Display size of file. -HEXSIZE = $(SIZE) --target=$(FORMAT) $(TARGET).hex -#New -ELFSIZE = $(SIZE) --mcu=$(MCU) --format=avr $(TARGET).elf -#Old -#ELFSIZE = $(SIZE) -A $(TARGET).elf - -AVRMEM = avr-mem.sh $(TARGET).elf $(MCU) - -sizebefore: - @if test -f $(TARGET).elf; then echo; echo $(MSG_SIZE_BEFORE); $(ELFSIZE); \ - $(AVRMEM) 2>/dev/null; echo; fi - -sizeafter: - @if test -f $(TARGET).elf; then echo; echo $(MSG_SIZE_AFTER); $(ELFSIZE); \ - $(AVRMEM) 2>/dev/null; echo; fi - - - -# Display compiler version information. -gccversion : - @$(CC) --version - - - -# Program the device. -program: $(TARGET).hex $(TARGET).eep - $(AVRDUDE) $(AVRDUDE_FLAGS) $(AVRDUDE_WRITE_FLASH) $(AVRDUDE_WRITE_EEPROM) - -program_stk500: $(TARGET).hex $(TARGET).eep - $(STK500_PATH)\$(STK500) $(STK500_FLAGS) $(STK500_WRITE_FLASH) - -program_serial: $(TARGET).hex $(TARGET).eep - $(SERIAL_AVRDUDE) $(SERIAL_AVRDUDE_FLAGS) $(AVRDUDE_WRITE_FLASH) - -# Generate avr-gdb config/init file which does the following: -# define the reset signal, load the target file, connect to target, and set -# a breakpoint at main(). -gdb-config: - @$(REMOVE) $(GDBINIT_FILE) - @echo define reset >> $(GDBINIT_FILE) - @echo SIGNAL SIGHUP >> $(GDBINIT_FILE) - @echo end >> $(GDBINIT_FILE) - @echo file $(TARGET).elf >> $(GDBINIT_FILE) - @echo target remote $(DEBUG_HOST):$(DEBUG_PORT) >> $(GDBINIT_FILE) -ifeq ($(DEBUG_BACKEND),simulavr) - @echo load >> $(GDBINIT_FILE) -endif - @echo break main >> $(GDBINIT_FILE) - -debug: gdb-config $(TARGET).elf -ifeq ($(DEBUG_BACKEND), avarice) - @echo Starting AVaRICE - Press enter when "waiting to connect" message displays. - @$(WINSHELL) /c start avarice --jtag $(JTAG_DEV) --erase --program --file \ - $(TARGET).elf $(DEBUG_HOST):$(DEBUG_PORT) - @$(WINSHELL) /c pause - -else - @$(WINSHELL) /c start simulavr --gdbserver --device $(MCU) --clock-freq \ - $(DEBUG_MFREQ) --port $(DEBUG_PORT) -endif - @$(WINSHELL) /c start avr-$(DEBUG_UI) --command=$(GDBINIT_FILE) - - - - -# Convert ELF to COFF for use in debugging / simulating in AVR Studio or VMLAB. -COFFCONVERT=$(OBJCOPY) --debugging \ ---change-section-address .data-0x800000 \ ---change-section-address .bss-0x800000 \ ---change-section-address .noinit-0x800000 \ ---change-section-address .eeprom-0x810000 - - -coff: $(TARGET).elf - @echo - @echo $(MSG_COFF) $(TARGET).cof - $(COFFCONVERT) -O coff-avr $< $(TARGET).cof - - -extcoff: $(TARGET).elf - @echo - @echo $(MSG_EXTENDED_COFF) $(TARGET).cof - $(COFFCONVERT) -O coff-ext-avr $< $(TARGET).cof - - - -# Create final output files (.hex, .eep) from ELF output file. -%.hex: %.elf - @echo - @echo $(MSG_FLASH) $@ - $(OBJCOPY) -O $(FORMAT) -R .eeprom $< $@ - -%.eep: %.elf - @echo - @echo $(MSG_EEPROM) $@ - -$(OBJCOPY) -j .eeprom --set-section-flags=.eeprom="alloc,load" \ - --change-section-lma .eeprom=0 -O $(FORMAT) $< $@ - -# Create extended listing file from ELF output file. -%.lss: %.elf - @echo - @echo $(MSG_EXTENDED_LISTING) $@ - $(OBJDUMP) -h -S $< > $@ - -# Create a symbol table from ELF output file. -%.sym: %.elf - @echo - @echo $(MSG_SYMBOL_TABLE) $@ - $(NM) -n $< > $@ - - - -# Link: create ELF output file from object files. -.SECONDARY : $(TARGET).elf -.PRECIOUS : $(OBJ) -%.elf: $(OBJ) - @echo - @echo $(MSG_LINKING) $@ - $(CC) $(ALL_CFLAGS) $^ --output $@ $(LDFLAGS) - - -# Compile: create object files from C source files. -%.o : %.c - @echo - @echo $(MSG_COMPILING) $< - $(CC) -c $(ALL_CFLAGS) $< -o $@ - - -# Compile: create assembler files from C source files. -%.s : %.c - $(CC) -S $(ALL_CFLAGS) $< -o $@ - - -# Assemble: create object files from assembler source files. -%.o : %.S - @echo - @echo $(MSG_ASSEMBLING) $< - $(CC) -c $(ALL_ASFLAGS) $< -o $@ - -# Create preprocessed source for use in sending a bug report. -%.i : %.c - $(CC) -E -mmcu=$(MCU) -I. $(CFLAGS) $< -o $@ - - -# Target: clean project. -clean: begin clean_list end - -clean_list : - @echo - @echo $(MSG_CLEANING) - $(REMOVE) $(TARGET).hex - $(REMOVE) $(TARGET).eep - $(REMOVE) $(TARGET).cof - $(REMOVE) $(TARGET).elf - $(REMOVE) $(TARGET).map - $(REMOVE) $(TARGET).sym - $(REMOVE) $(TARGET).lss - $(REMOVE) $(OBJ) - $(REMOVE) $(LST) - $(REMOVE) $(SRC:.c=.s) - $(REMOVE) $(SRC:.c=.d) - $(REMOVE) .dep/* - - - -# Include the dependency files. --include $(shell mkdir .dep 2>/dev/null) $(wildcard .dep/*) - - -# Listing of phony targets. -.PHONY : all begin finish end sizebefore sizeafter gccversion \ -build elf hex eep lss sym coff extcoff \ -clean clean_list program debug gdb-config - - - +# Hey Emacs, this is a -*- makefile -*- +#---------------------------------------------------------------------------- +# WinAVR Makefile Template written by Eric B. Weddington, Jörg Wunsch, et al. +# +# Released to the Public Domain +# +# Additional material for this makefile was written by: +# Peter Fleury +# Tim Henigan +# Colin O'Flynn +# Reiner Patommel +# Markus Pfaff +# Sander Pool +# Frederik Rouleau +# +#---------------------------------------------------------------------------- +# On command line: +# +# make all = Make software. +# +# make clean = Clean out built project files. +# +# make coff = Convert ELF to AVR COFF. +# +# make extcoff = Convert ELF to AVR Extended COFF. +# +# make program = Download the hex file to the device, using avrdude. +# Please customize the avrdude settings below first! +# +# make debug = Start either simulavr or avarice as specified for debugging, +# with avr-gdb or avr-insight as the front end for debugging. +# +# make filename.s = Just compile filename.c into the assembler code only. +# +# make filename.i = Create a preprocessed source file for use in submitting +# bug reports to the GCC project. +# +# To rebuild project do "make clean" then "make all". +#---------------------------------------------------------------------------- + + + +# MCU name +MCU = atmega328 + + +# Processor frequency. +# This will define a symbol, F_CPU, in all source code files equal to the +# processor frequency. You can then use this symbol in your source code to +# calculate timings. Do NOT tack on a 'UL' at the end, this will be done +# automatically to create a 32-bit value in your source code. +F_CPU = 8000000 + + +# Output format. (can be srec, ihex, binary) +FORMAT = ihex + + +# Target file name (without extension). +TARGET = Simon + + +# List C source files here. (C dependencies are automatically generated.) +SRC = $(TARGET).c + + +# List Assembler source files here. +# Make them always end in a capital .S. Files ending in a lowercase .s +# will not be considered source files but generated files (assembler +# output from the compiler), and will be deleted upon "make clean"! +# Even though the DOS/Win* filesystem matches both .s and .S the same, +# it will preserve the spelling of the filenames, and gcc itself does +# care about how the name is spelled on its command-line. +ASRC = + + +# Optimization level, can be [0, 1, 2, 3, s]. +# 0 = turn off optimization. s = optimize for size. +# (Note: 3 is not always the best optimization level. See avr-libc FAQ.) +OPT = s + + +# Debugging format. +# Native formats for AVR-GCC's -g are dwarf-2 [default] or stabs. +# AVR Studio 4.10 requires dwarf-2. +# AVR [Extended] COFF format requires stabs, plus an avr-objcopy run. +DEBUG = dwarf-2 + + +# List any extra directories to look for include files here. +# Each directory must be seperated by a space. +# Use forward slashes for directory separators. +# For a directory that has spaces, enclose it in quotes. +EXTRAINCDIRS = + + +# Compiler flag to set the C Standard level. +# c89 = "ANSI" C +# gnu89 = c89 plus GCC extensions +# c99 = ISO C99 standard (not yet fully implemented) +# gnu99 = c99 plus GCC extensions +CSTANDARD = -std=gnu99 + + +# Place -D or -U options here +CDEFS = -DF_CPU=$(F_CPU)UL + + +# Place -I options here +CINCS = + + + +#---------------- Compiler Options ---------------- +# -g*: generate debugging information +# -O*: optimization level +# -f...: tuning, see GCC manual and avr-libc documentation +# -Wall...: warning level +# -Wa,...: tell GCC to pass this to the assembler. +# -adhlns...: create assembler listing +CFLAGS = -g$(DEBUG) +CFLAGS += $(CDEFS) $(CINCS) +CFLAGS += -O$(OPT) +CFLAGS += -funsigned-char -funsigned-bitfields -fpack-struct -fshort-enums +CFLAGS += -Wall -Wstrict-prototypes +CFLAGS += -Wa,-adhlns=$(<:.c=.lst) +CFLAGS += $(patsubst %,-I%,$(EXTRAINCDIRS)) +CFLAGS += $(CSTANDARD) + + +#---------------- Assembler Options ---------------- +# -Wa,...: tell GCC to pass this to the assembler. +# -ahlms: create listing +# -gstabs: have the assembler create line number information; note that +# for use in COFF files, additional information about filenames +# and function names needs to be present in the assembler source +# files -- see avr-libc docs [FIXME: not yet described there] +ASFLAGS = -Wa,-adhlns=$(<:.S=.lst),-gstabs + + +#---------------- Library Options ---------------- +# Minimalistic printf version +PRINTF_LIB_MIN = -Wl,-u,vfprintf -lprintf_min + +# Floating point printf version (requires MATH_LIB = -lm below) +PRINTF_LIB_FLOAT = -Wl,-u,vfprintf -lprintf_flt + +# If this is left blank, then it will use the Standard printf version. +PRINTF_LIB = +#PRINTF_LIB = $(PRINTF_LIB_MIN) +#PRINTF_LIB = $(PRINTF_LIB_FLOAT) + + +# Minimalistic scanf version +SCANF_LIB_MIN = -Wl,-u,vfscanf -lscanf_min + +# Floating point + %[ scanf version (requires MATH_LIB = -lm below) +SCANF_LIB_FLOAT = -Wl,-u,vfscanf -lscanf_flt + +# If this is left blank, then it will use the Standard scanf version. +SCANF_LIB = +#SCANF_LIB = $(SCANF_LIB_MIN) +#SCANF_LIB = $(SCANF_LIB_FLOAT) + + +MATH_LIB = -lm + + + +#---------------- External Memory Options ---------------- + +# 64 KB of external RAM, starting after internal RAM (ATmega128!), +# used for variables (.data/.bss) and heap (malloc()). +#EXTMEMOPTS = -Wl,-Tdata=0x801100,--defsym=__heap_end=0x80ffff + +# 64 KB of external RAM, starting after internal RAM (ATmega128!), +# only used for heap (malloc()). +#EXTMEMOPTS = -Wl,--defsym=__heap_start=0x801100,--defsym=__heap_end=0x80ffff + +EXTMEMOPTS = + + + +#---------------- Linker Options ---------------- +# -Wl,...: tell GCC to pass this to linker. +# -Map: create map file +# --cref: add cross reference to map file +LDFLAGS = -Wl,-Map=$(TARGET).map,--cref +LDFLAGS += $(EXTMEMOPTS) +LDFLAGS += $(PRINTF_LIB) $(SCANF_LIB) $(MATH_LIB) + + + +#---------------- Programming Options (avrdude serial bootloader) ---------------- + +#"C:\arduino\hardware\tools\avr\bin\avrdude" -PCOM3 -c stk500v1 -patmega168 -b19200 -Uflash:w:Simon-PTH-v1.hex -V -F -C"C:\arduino\hardware\tools\avr\etc\avrdude.conf" +#avrdude -PCOM3 -c stk500v1 -patmega168 -b19200 -Uflash:w:Simon-PTH-v1.hex -V -F +SERIAL_AVRDUDE = avrdude +#SERIAL_AVRDUDE_CONFIG = "C:\arduino\hardware\tools\avr\etc\avrdude.conf" +SERIAL_AVRDUDE_PORT = COM3 +SERIAL_AVRDUDE_SPEED = 19200 +SERIAL_AVRDUDE_PROGRAMMER = stk500v1 + +SERIAL_AVRDUDE_FLAGS = -p $(MCU) -P $(SERIAL_AVRDUDE_PORT) -c $(SERIAL_AVRDUDE_PROGRAMMER) -b$(SERIAL_AVRDUDE_SPEED) +#SERIAL_AVRDUDE_FLAGS += -C$(SERIAL_AVRDUDE_CONFIG) +SERIAL_AVRDUDE_FLAGS += $(AVRDUDE_NO_VERIFY) +SERIAL_AVRDUDE_FLAGS += $(AVRDUDE_VERBOSE) +SERIAL_AVRDUDE_FLAGS += $(AVRDUDE_ERASE_COUNTER) + + +#---------------- Programming Options (avrdude) ---------------- + +# Programming hardware: alf avr910 avrisp bascom bsd +# dt006 pavr picoweb pony-stk200 sp12 stk200 stk500 +# +# Type: avrdude -c ? +# to get a full listing. +AVRDUDE_PROGRAMMER = stk200 +#AVRDUDE_PROGRAMMER = ponyser + +# com1 = serial port. Use lpt1 to connect to parallel port. +AVRDUDE_PORT = lpt1 +#AVRDUDE_PORT = COM1 + +AVRDUDE_WRITE_FLASH = -U flash:w:$(TARGET).hex +#AVRDUDE_WRITE_EEPROM = -U eeprom:w:$(TARGET).eep + + +# Uncomment the following if you want avrdude's erase cycle counter. +# Note that this counter needs to be initialized first using -Yn, +# see avrdude manual. +#AVRDUDE_ERASE_COUNTER = -y + +# Uncomment the following if you do /not/ wish a verification to be +# performed after programming the device. +#AVRDUDE_NO_VERIFY = -V + +# Increase verbosity level. Please use this when submitting bug +# reports about avrdude. See +# to submit bug reports. +#AVRDUDE_VERBOSE = -v -v + +AVRDUDE_FLAGS = -p $(MCU) -P $(AVRDUDE_PORT) -c $(AVRDUDE_PROGRAMMER) +AVRDUDE_FLAGS += $(AVRDUDE_NO_VERIFY) +AVRDUDE_FLAGS += $(AVRDUDE_VERBOSE) +AVRDUDE_FLAGS += $(AVRDUDE_ERASE_COUNTER) + +#---------------- Programming Options (STK500) ---------------- +# Programming hardware: stk500 (the AVR MKII ISP version) + +STK500 = stk500 + +# Location of STK500.exe - no trailing '\' +STK500_PATH = C:\Program Files\Atmel\AVR Tools\STK500 + +# The STK500 AVR ISP MKII is USB. The USB drivers must already be installed. +# Do this normally by installing AVR Studio. +STK500_PORT = USB + +#-erase chip -Program Flash -Verify Flash -File name -Serial programing(ISP) +STK500_WRITE_FLASH = -e -pf -vf -if$(TARGET).hex -ms + +STK500_FLAGS = -d$(MCU) -c$(STK500_PORT) + +#-Set ISP frequency to 250kHz. Limit is 1/4 of internal osc which is default 1MHz +#Reduce this to 100kHz if you run into flash verification problems in low-voltage systems +STK500_FLAGS += -I250kHz + +#---------------- Debugging Options ---------------- + +# For simulavr only - target MCU frequency. +DEBUG_MFREQ = $(F_CPU) + +# Set the DEBUG_UI to either gdb or insight. +# DEBUG_UI = gdb +DEBUG_UI = insight + +# Set the debugging back-end to either avarice, simulavr. +DEBUG_BACKEND = avarice +#DEBUG_BACKEND = simulavr + +# GDB Init Filename. +GDBINIT_FILE = __avr_gdbinit + +# When using avarice settings for the JTAG +JTAG_DEV = /dev/com1 + +# Debugging port used to communicate between GDB / avarice / simulavr. +DEBUG_PORT = 4242 + +# Debugging host used to communicate between GDB / avarice / simulavr, normally +# just set to localhost unless doing some sort of crazy debugging when +# avarice is running on a different computer. +DEBUG_HOST = localhost + + + +#============================================================================ + + +# Define programs and commands. +SHELL = sh +CC = avr-gcc +OBJCOPY = avr-objcopy +OBJDUMP = avr-objdump +SIZE = avr-size +NM = avr-nm +AVRDUDE = avrdude +REMOVE = rm -f +COPY = cp +WINSHELL = cmd + + +# Define Messages +# English +MSG_ERRORS_NONE = Errors: none +MSG_BEGIN = -------- begin -------- +MSG_END = -------- end -------- +MSG_SIZE_BEFORE = Size before: +MSG_SIZE_AFTER = Size after: +MSG_COFF = Converting to AVR COFF: +MSG_EXTENDED_COFF = Converting to AVR Extended COFF: +MSG_FLASH = Creating load file for Flash: +MSG_EEPROM = Creating load file for EEPROM: +MSG_EXTENDED_LISTING = Creating Extended Listing: +MSG_SYMBOL_TABLE = Creating Symbol Table: +MSG_LINKING = Linking: +MSG_COMPILING = Compiling: +MSG_ASSEMBLING = Assembling: +MSG_CLEANING = Cleaning project: + + + + +# Define all object files. +OBJ = $(SRC:.c=.o) $(ASRC:.S=.o) + +# Define all listing files. +LST = $(SRC:.c=.lst) $(ASRC:.S=.lst) + + +# Compiler flags to generate dependency files. +GENDEPFLAGS = -MD -MP -MF .dep/$(@F).d + + +# Combine all necessary flags and optional flags. +# Add target processor to flags. +ALL_CFLAGS = -mmcu=$(MCU) -I. $(CFLAGS) $(GENDEPFLAGS) +ALL_ASFLAGS = -mmcu=$(MCU) -I. -x assembler-with-cpp $(ASFLAGS) + + + + + +# Default target. +all: begin gccversion sizebefore build sizeafter end + +build: elf hex eep lss sym + +elf: $(TARGET).elf +hex: $(TARGET).hex +eep: $(TARGET).eep +lss: $(TARGET).lss +sym: $(TARGET).sym + + + +# Eye candy. +# AVR Studio 3.x does not check make's exit code but relies on +# the following magic strings to be generated by the compile job. +begin: + @echo + @echo $(MSG_BEGIN) + +end: + @echo $(MSG_END) + @echo + + +# Display size of file. +HEXSIZE = $(SIZE) --target=$(FORMAT) $(TARGET).hex +#New +ELFSIZE = $(SIZE) --mcu=$(MCU) --format=avr $(TARGET).elf +#Old +#ELFSIZE = $(SIZE) -A $(TARGET).elf + +AVRMEM = avr-mem.sh $(TARGET).elf $(MCU) + +sizebefore: + @if test -f $(TARGET).elf; then echo; echo $(MSG_SIZE_BEFORE); $(ELFSIZE); \ + $(AVRMEM) 2>/dev/null; echo; fi + +sizeafter: + @if test -f $(TARGET).elf; then echo; echo $(MSG_SIZE_AFTER); $(ELFSIZE); \ + $(AVRMEM) 2>/dev/null; echo; fi + + + +# Display compiler version information. +gccversion : + @$(CC) --version + + + +# Program the device. +program: $(TARGET).hex $(TARGET).eep + $(AVRDUDE) $(AVRDUDE_FLAGS) $(AVRDUDE_WRITE_FLASH) $(AVRDUDE_WRITE_EEPROM) + +program_stk500: $(TARGET).hex $(TARGET).eep + $(STK500_PATH)\$(STK500) $(STK500_FLAGS) $(STK500_WRITE_FLASH) + +program_serial: $(TARGET).hex $(TARGET).eep + $(SERIAL_AVRDUDE) $(SERIAL_AVRDUDE_FLAGS) $(AVRDUDE_WRITE_FLASH) + +# Generate avr-gdb config/init file which does the following: +# define the reset signal, load the target file, connect to target, and set +# a breakpoint at main(). +gdb-config: + @$(REMOVE) $(GDBINIT_FILE) + @echo define reset >> $(GDBINIT_FILE) + @echo SIGNAL SIGHUP >> $(GDBINIT_FILE) + @echo end >> $(GDBINIT_FILE) + @echo file $(TARGET).elf >> $(GDBINIT_FILE) + @echo target remote $(DEBUG_HOST):$(DEBUG_PORT) >> $(GDBINIT_FILE) +ifeq ($(DEBUG_BACKEND),simulavr) + @echo load >> $(GDBINIT_FILE) +endif + @echo break main >> $(GDBINIT_FILE) + +debug: gdb-config $(TARGET).elf +ifeq ($(DEBUG_BACKEND), avarice) + @echo Starting AVaRICE - Press enter when "waiting to connect" message displays. + @$(WINSHELL) /c start avarice --jtag $(JTAG_DEV) --erase --program --file \ + $(TARGET).elf $(DEBUG_HOST):$(DEBUG_PORT) + @$(WINSHELL) /c pause + +else + @$(WINSHELL) /c start simulavr --gdbserver --device $(MCU) --clock-freq \ + $(DEBUG_MFREQ) --port $(DEBUG_PORT) +endif + @$(WINSHELL) /c start avr-$(DEBUG_UI) --command=$(GDBINIT_FILE) + + + + +# Convert ELF to COFF for use in debugging / simulating in AVR Studio or VMLAB. +COFFCONVERT=$(OBJCOPY) --debugging \ +--change-section-address .data-0x800000 \ +--change-section-address .bss-0x800000 \ +--change-section-address .noinit-0x800000 \ +--change-section-address .eeprom-0x810000 + + +coff: $(TARGET).elf + @echo + @echo $(MSG_COFF) $(TARGET).cof + $(COFFCONVERT) -O coff-avr $< $(TARGET).cof + + +extcoff: $(TARGET).elf + @echo + @echo $(MSG_EXTENDED_COFF) $(TARGET).cof + $(COFFCONVERT) -O coff-ext-avr $< $(TARGET).cof + + + +# Create final output files (.hex, .eep) from ELF output file. +%.hex: %.elf + @echo + @echo $(MSG_FLASH) $@ + $(OBJCOPY) -O $(FORMAT) -R .eeprom $< $@ + +%.eep: %.elf + @echo + @echo $(MSG_EEPROM) $@ + -$(OBJCOPY) -j .eeprom --set-section-flags=.eeprom="alloc,load" \ + --change-section-lma .eeprom=0 -O $(FORMAT) $< $@ + +# Create extended listing file from ELF output file. +%.lss: %.elf + @echo + @echo $(MSG_EXTENDED_LISTING) $@ + $(OBJDUMP) -h -S $< > $@ + +# Create a symbol table from ELF output file. +%.sym: %.elf + @echo + @echo $(MSG_SYMBOL_TABLE) $@ + $(NM) -n $< > $@ + + + +# Link: create ELF output file from object files. +.SECONDARY : $(TARGET).elf +.PRECIOUS : $(OBJ) +%.elf: $(OBJ) + @echo + @echo $(MSG_LINKING) $@ + $(CC) $(ALL_CFLAGS) $^ --output $@ $(LDFLAGS) + + +# Compile: create object files from C source files. +%.o : %.c + @echo + @echo $(MSG_COMPILING) $< + $(CC) -c $(ALL_CFLAGS) $< -o $@ + + +# Compile: create assembler files from C source files. +%.s : %.c + $(CC) -S $(ALL_CFLAGS) $< -o $@ + + +# Assemble: create object files from assembler source files. +%.o : %.S + @echo + @echo $(MSG_ASSEMBLING) $< + $(CC) -c $(ALL_ASFLAGS) $< -o $@ + +# Create preprocessed source for use in sending a bug report. +%.i : %.c + $(CC) -E -mmcu=$(MCU) -I. $(CFLAGS) $< -o $@ + + +# Target: clean project. +clean: begin clean_list end + +clean_list : + @echo + @echo $(MSG_CLEANING) + $(REMOVE) $(TARGET).hex + $(REMOVE) $(TARGET).eep + $(REMOVE) $(TARGET).cof + $(REMOVE) $(TARGET).elf + $(REMOVE) $(TARGET).map + $(REMOVE) $(TARGET).sym + $(REMOVE) $(TARGET).lss + $(REMOVE) $(OBJ) + $(REMOVE) $(LST) + $(REMOVE) $(SRC:.c=.s) + $(REMOVE) $(SRC:.c=.d) + $(REMOVE) .dep/* + + + +# Include the dependency files. +-include $(shell mkdir .dep 2>/dev/null) $(wildcard .dep/*) + + +# Listing of phony targets. +.PHONY : all begin finish end sizebefore sizeafter gccversion \ +build elf hex eep lss sym coff extcoff \ +clean clean_list program debug gdb-config + + + diff --git a/Firmware/Old-Simon_C/Simon.c b/Firmware/Old-Simon_C/Simon.c index 110bbf8..2c14726 100644 --- a/Firmware/Old-Simon_C/Simon.c +++ b/Firmware/Old-Simon_C/Simon.c @@ -1,641 +1,641 @@ -/** - * 6-19-2007 - * Copyright 2009, Spark Fun Electronics - * Nathan Seidle - * nathan at sparkfun.com - * - * Released under the Creative Commons Attribution Share-Alike 3.0 License - * http://creativecommons.org/licenses/by-sa/3.0 - * - * Simon Game ported for the ATmega168 - * - * Fixes and cleanup by Joshua Neal - * - * Generates random sequence, plays music, and displays button lights. - * - * Simon tones from Wikipedia - * - A (red, upper left) - 440Hz - 2.272ms - 1.136ms pulse - * - a (green, upper right, an octave higher than A) - 880Hz - 1.136ms, - * 0.568ms pulse - * - D (blue, lower left, a perfect fourth higher than the upper left) - * 587.33Hz - 1.702ms - 0.851ms pulse - * G (yellow, lower right, a perfect fourth higher than the lower left) - - * 784Hz - 1.276ms - 0.638ms pulse - * - * The tones are close, but probably off a bit, but they sound all right. - * - * The old version of SparkFun simon used an ATmega8. An ATmega8 ships - * with a default internal 1MHz oscillator. You will need to set the - * internal fuses to operate at the correct external 16MHz oscillator. - * - * Original Fuses: - * avrdude -p atmega8 -P lpt1 -c stk200 -U lfuse:w:0xE1:m -U hfuse:w:0xD9:m - * - * Command to set to fuses to use external 16MHz: - * avrdude -p atmega8 -P lpt1 -c stk200 -U lfuse:w:0xEE:m -U hfuse:w:0xC9:m - * - * The current version of Simon uses the ATmega168. The external osciallator - * was removed to reduce component count. This version of simon relies on the - * internal default 1MHz osciallator. Do not set the external fuses. - */ - -#include -#include - -/* Uncomment one of the following, corresponding to the board you have. */ -//#define BOARD_REV_6_25_08 -//#define BOARD_REV_4_9_2009 -//#define BOARD_REV_6_3_2009 -#define BOARD_REV_PTH - -#ifdef BOARD_REV_PTH - -#define CHIP_ATMEGA168 - -#define LED_RED (1 << 0) -#define LED_GREEN (1 << 1) -#define LED_BLUE (1 << 2) -#define LED_YELLOW (1 << 3) - -/* LED pin definitions */ -#define LED_RED_PIN 2 -#define LED_RED_PORT PORTB -#define LED_GREEN_PIN 3 -#define LED_GREEN_PORT PORTD -#define LED_BLUE_PIN 5 -#define LED_BLUE_PORT PORTB -#define LED_YELLOW_PIN 5 -#define LED_YELLOW_PORT PORTD - -/* Button pin definitions */ -#define BUTTON_RED_PIN 1 -#define BUTTON_RED_PORT PINB -#define BUTTON_GREEN_PIN 2 -#define BUTTON_GREEN_PORT PIND -#define BUTTON_BLUE_PIN 4 -#define BUTTON_BLUE_PORT PINB -#define BUTTON_YELLOW_PIN 6 -#define BUTTON_YELLOW_PORT PIND - -/* Buzzer pin definitions */ -#define BUZZER1 4 -#define BUZZER1_PORT PORTD -#define BUZZER2 7 -#define BUZZER2_PORT PORTD - -#endif /* BOARD_REV_PTH */ - - -#ifdef BOARD_REV_6_25_08 - -#define CHIP_ATMEGA168 - -#define LED_RED (1 << 0) -#define LED_GREEN (1 << 1) -#define LED_BLUE (1 << 2) -#define LED_YELLOW (1 << 3) - -/* LED pin definitions */ -#define LED_RED_PIN 3 -#define LED_RED_PORT PORTC -#define LED_GREEN_PIN 2 -#define LED_GREEN_PORT PORTD -#define LED_BLUE_PIN 0 -#define LED_BLUE_PORT PORTC -#define LED_YELLOW_PIN 5 -#define LED_YELLOW_PORT PORTD - -/* Button pin definitions */ -#define BUTTON_RED_PIN 2 -#define BUTTON_RED_PORT PINC -#define BUTTON_GREEN_PIN 5 -#define BUTTON_GREEN_PORT PINC -#define BUTTON_BLUE_PIN 1 -#define BUTTON_BLUE_PORT PINC -#define BUTTON_YELLOW_PIN 6 -#define BUTTON_YELLOW_PORT PIND - -/* Buzzer pin definitions */ -#define BUZZER1 3 -#define BUZZER1_PORT PORTD -#define BUZZER2 4 -#define BUZZER2_PORT PORTD - -#endif /* BOARD_REV_6_25_08 */ - - -#ifdef BOARD_REV_4_9_2009 - -#define CHIP_ATMEGA168 - -/* LED pin definitions */ -#define LED_BLUE_PIN 5 -#define LED_BLUE_PORT PORTB -#define LED_YELLOW_PIN 5 -#define LED_YELLOW_PORT PORTD -#define LED_RED_PIN 2 -#define LED_RED_PORT PORTB -#define LED_GREEN_PIN 2 -#define LED_GREEN_PORT PORTD - -/* Button pin definitions */ -#define BUTTON_RED_PIN 0 -#define BUTTON_RED_PORT PINB -#define BUTTON_GREEN_PIN 1 -#define BUTTON_GREEN_PORT PINB -#define BUTTON_BLUE_PIN 7 -#define BUTTON_BLUE_PORT PIND -#define BUTTON_YELLOW_PIN 6 -#define BUTTON_YELLOW_PORT PIND - -/* Buzzer pin definitions */ -#define BUZZER1 3 -#define BUZZER1_PORT PORTD -#define BUZZER2 4 -#define BUZZER2_PORT PORTD - -#endif /* BOARD_REV_4_9_2009 */ - -#ifdef BOARD_REV_6_3_2009 - -#define CHIP_ATMEGA168 - -#define LED_RED (1 << 0) -#define LED_GREEN (1 << 1) -#define LED_BLUE (1 << 2) -#define LED_YELLOW (1 << 3) - -/* LED pin definitions */ -#define LED_RED_PIN 2 -#define LED_RED_PORT PORTB -#define LED_GREEN_PIN 2 -#define LED_GREEN_PORT PORTD -#define LED_BLUE_PIN 5 -#define LED_BLUE_PORT PORTB -#define LED_YELLOW_PIN 5 -#define LED_YELLOW_PORT PORTD - -/* Button pin definitions */ -#define BUTTON_RED_PIN 0 -#define BUTTON_RED_PORT PINB -#define BUTTON_GREEN_PIN 1 -#define BUTTON_GREEN_PORT PINB -#define BUTTON_BLUE_PIN 7 -#define BUTTON_BLUE_PORT PIND -#define BUTTON_YELLOW_PIN 6 -#define BUTTON_YELLOW_PORT PIND - -/* Buzzer pin definitions */ -#define BUZZER1 3 -#define BUZZER1_PORT PORTD -#define BUZZER2 4 -#define BUZZER2_PORT PORTD - -#endif /* BOARD_REV_6_3_2009 */ - -/* Define game parameters */ -#define MOVES_TO_WIN 14 -#define TIME_LIMIT 3000 /* 3000ms = 3 sec */ - -#define sbi(port_name, pin_number) (port_name |= 1< 256) - { - TIFR0 = (1< 0) { - delay_us(1000); - } -} - -/* Light the given set of LEDs */ -static void set_leds(uint8_t leds) -{ - if ((leds & LED_RED) != 0) { - sbi(LED_RED_PORT, LED_RED_PIN); - } else { - cbi(LED_RED_PORT, LED_RED_PIN); - } - if ((leds & LED_GREEN) != 0) { - sbi(LED_GREEN_PORT, LED_GREEN_PIN); - } else { - cbi(LED_GREEN_PORT, LED_GREEN_PIN); - } - if ((leds & LED_BLUE) != 0) { - sbi(LED_BLUE_PORT, LED_BLUE_PIN); - } else { - cbi(LED_BLUE_PORT, LED_BLUE_PIN); - } - if ((leds & LED_YELLOW) != 0) { - sbi(LED_YELLOW_PORT, LED_YELLOW_PIN); - } else { - cbi(LED_YELLOW_PORT, LED_YELLOW_PIN); - } -} - - -#ifdef BOARD_REV_6_25_08 -static void init_gpio(void) -{ - /* 1 = output, 0 = input */ - DDRB = 0b11111111; - DDRC = 0b00001001; /* LEDs and Buttons */ - DDRD = 0b00111110; /* LEDs, buttons, buzzer, TX/RX */ - - PORTC = 0b00100110; /* Enable pull-ups on buttons 0,2,3 */ - PORTD = 0b01000000; /* Enable pull-up on button 1 */ -} -#endif /* BOARD_REV_6_25_08 */ - -#ifdef BOARD_REV_4_9_2009 -static void init_gpio(void) -{ - /* 1 = output, 0 = input */ - DDRB = 0b11111100; /* button 2,3 on PB0,1 */ - DDRD = 0b00111110; /* LEDs, buttons, buzzer, TX/RX */ - - PORTB = 0b00000011; /* Enable pull-ups on buttons 2,3 */ - PORTD = 0b11000000; /* Enable pull-up on button 0,1 */ -} -#endif /* BOARD_REV_4_9_2009 */ - -#ifdef BOARD_REV_PTH -static void init_gpio(void) -{ - /* 1 = output, 0 = input */ - DDRB = 0xFF & ~(1< 70; x--) { - for (y = 0; y < 3; y++) { - sbi(BUZZER2_PORT, BUZZER2); - cbi(BUZZER1_PORT, BUZZER1); - - delay_us(x); - - cbi(BUZZER2_PORT, BUZZER2); - sbi(BUZZER1_PORT, BUZZER1); - - delay_us(x); - } - } -} - -/* Play the winner sound and lights */ -void play_winner(void) -{ - set_leds(LED_GREEN|LED_BLUE); - winner_sound(); - set_leds(LED_RED|LED_YELLOW); - winner_sound(); - set_leds(LED_GREEN|LED_BLUE); - winner_sound(); - set_leds(LED_RED|LED_YELLOW); - winner_sound(); -} - -/* Plays the current contents of the game moves */ -static void play_moves(void) -{ - uint8_t move; - - for (move = 0; move < nmoves; move++) { - toner(moves[move], 150); - delay_ms(150); - } -} - -/* Adds a new random button to the game sequence, by sampling the timer */ -static void add_to_moves(void) -{ - uint8_t new_button; - - /* Use the lower 2 bits of the timer for the random value */ - new_button = 1 << (TCNT2 & 0x3); - - moves[nmoves++] = new_button; -} - -/* Toggle buzzer every buzz_delay_us, for a duration of buzz_length_ms. */ -static void buzz_sound(uint16_t buzz_length_ms, uint16_t buzz_delay_us) -{ - uint32_t buzz_length_us; - - buzz_length_us = buzz_length_ms * (uint32_t)1000; - while (buzz_length_us > buzz_delay_us*2) { - buzz_length_us -= buzz_delay_us*2; - - /* toggle the buzzer at various speeds */ - cbi(BUZZER1_PORT, BUZZER1); - sbi(BUZZER2_PORT, BUZZER2); - delay_us(buzz_delay_us); - - sbi(BUZZER1_PORT, BUZZER1); - cbi(BUZZER2_PORT, BUZZER2); - delay_us(buzz_delay_us); - } -} - - -/* - * Light an LED and play tone - * - * red, upper left: 440Hz - 2.272ms - 1.136ms pulse - * green, upper right: 880Hz - 1.136ms - 0.568ms pulse - * blue, lower left: 587.33Hz - 1.702ms - 0.851ms pulse - * yellow, lower right: 784Hz - 1.276ms - 0.638ms pulse - */ -static void toner(uint8_t which, uint16_t buzz_length_ms) -{ - set_leds(which); - switch (which) { - case LED_RED: - buzz_sound(buzz_length_ms, 1136); - break; - - case LED_GREEN: - buzz_sound(buzz_length_ms, 568); - break; - - case LED_BLUE: - buzz_sound(buzz_length_ms, 851); - break; - - case LED_YELLOW: - buzz_sound(buzz_length_ms, 638); - break; - } - - /* Turn off all LEDs */ - set_leds(0); -} - -/* Show an "attract mode" display while waiting for user to press button. */ -static void attract_mode(void) -{ - while (1) { - set_leds(LED_RED); - delay_ms(100); - if (check_button() != 0x00) - return; - - set_leds(LED_BLUE); - delay_ms(100); - if (check_button() != 0x00) - return; - - set_leds(LED_GREEN); - delay_ms(100); - if (check_button() != 0x00) - return; - - set_leds(LED_YELLOW); - delay_ms(100); - if (check_button() != 0x00) - return; - } -} - - -/* Wait for a button to be pressed. Returns one of led colors (LED_RED, etc.) - * if successful, 0 if timed out */ -static uint8_t wait_for_button(void) -{ - uint16_t time_limit = TIME_LIMIT; - uint8_t released = 0; - uint8_t old_button; - - while (time_limit > 0) { - uint8_t button; - - /* Implement a small bit of debouncing */ - old_button = button; - button = check_button(); - - /* - * Make sure we've seen the previous button - * released before accepting new buttons - */ - if (button == 0) - released = 1; - if (button == old_button && released == 1) { - /* Make sure just one button is pressed */ - if (button == LED_RED || - button == LED_BLUE || - button == LED_GREEN || - button == LED_YELLOW) { - return button; - } - } - - delay_ms(1); - - time_limit--; - } - return 0; /* Timed out */ -} - - - -/* Play the game. Returns 0 if player loses, or 1 if player wins. */ -static int game_mode(void) -{ - nmoves = 0; - while (nmoves < MOVES_TO_WIN) { - uint8_t move; - - /* Add a button to the current moves, then play them back */ - add_to_moves(); - play_moves(); - - /* Then require the player to repeat the sequence. */ - for (move = 0; move < nmoves; move++) { - uint8_t choice = wait_for_button(); - - /* If wait timed out, player loses. */ - if (choice == 0) - return 0; - - toner(choice, 150); - - /* If the choice is incorect, player loses. */ - if (choice != moves[move]) { - return 0; - } - } - - /* Player was correct, delay before playing moves */ - delay_ms(1000); - } - - /* player wins */ - return 1; -} - -int main(void) -{ - - /* Setup IO pins and defaults */ - ioinit(); - - /* Main loop */ - while (1) { - /* Wait for user to start game */ - attract_mode(); - - /* Indicate the start of game play */ - set_leds(LED_RED|LED_GREEN|LED_BLUE|LED_YELLOW); - delay_ms(1000); - set_leds(0); - delay_ms(250); - - if (game_mode() != 0) { - /* Player won, play winner tones */ - play_winner(); - } else { - /* Player lost, play loser tones */ - play_loser(); - } - } - - return(0); -} - +/** + * 6-19-2007 + * Copyright 2009, Spark Fun Electronics + * Nathan Seidle + * nathan at sparkfun.com + * + * Released under the Creative Commons Attribution Share-Alike 3.0 License + * http://creativecommons.org/licenses/by-sa/3.0 + * + * Simon Game ported for the ATmega168 + * + * Fixes and cleanup by Joshua Neal + * + * Generates random sequence, plays music, and displays button lights. + * + * Simon tones from Wikipedia + * - A (red, upper left) - 440Hz - 2.272ms - 1.136ms pulse + * - a (green, upper right, an octave higher than A) - 880Hz - 1.136ms, + * 0.568ms pulse + * - D (blue, lower left, a perfect fourth higher than the upper left) + * 587.33Hz - 1.702ms - 0.851ms pulse + * G (yellow, lower right, a perfect fourth higher than the lower left) - + * 784Hz - 1.276ms - 0.638ms pulse + * + * The tones are close, but probably off a bit, but they sound all right. + * + * The old version of SparkFun simon used an ATmega8. An ATmega8 ships + * with a default internal 1MHz oscillator. You will need to set the + * internal fuses to operate at the correct external 16MHz oscillator. + * + * Original Fuses: + * avrdude -p atmega8 -P lpt1 -c stk200 -U lfuse:w:0xE1:m -U hfuse:w:0xD9:m + * + * Command to set to fuses to use external 16MHz: + * avrdude -p atmega8 -P lpt1 -c stk200 -U lfuse:w:0xEE:m -U hfuse:w:0xC9:m + * + * The current version of Simon uses the ATmega168. The external osciallator + * was removed to reduce component count. This version of simon relies on the + * internal default 1MHz osciallator. Do not set the external fuses. + */ + +#include +#include + +/* Uncomment one of the following, corresponding to the board you have. */ +//#define BOARD_REV_6_25_08 +//#define BOARD_REV_4_9_2009 +//#define BOARD_REV_6_3_2009 +#define BOARD_REV_PTH + +#ifdef BOARD_REV_PTH + +#define CHIP_ATMEGA168 + +#define LED_RED (1 << 0) +#define LED_GREEN (1 << 1) +#define LED_BLUE (1 << 2) +#define LED_YELLOW (1 << 3) + +/* LED pin definitions */ +#define LED_RED_PIN 2 +#define LED_RED_PORT PORTB +#define LED_GREEN_PIN 3 +#define LED_GREEN_PORT PORTD +#define LED_BLUE_PIN 5 +#define LED_BLUE_PORT PORTB +#define LED_YELLOW_PIN 5 +#define LED_YELLOW_PORT PORTD + +/* Button pin definitions */ +#define BUTTON_RED_PIN 1 +#define BUTTON_RED_PORT PINB +#define BUTTON_GREEN_PIN 2 +#define BUTTON_GREEN_PORT PIND +#define BUTTON_BLUE_PIN 4 +#define BUTTON_BLUE_PORT PINB +#define BUTTON_YELLOW_PIN 6 +#define BUTTON_YELLOW_PORT PIND + +/* Buzzer pin definitions */ +#define BUZZER1 4 +#define BUZZER1_PORT PORTD +#define BUZZER2 7 +#define BUZZER2_PORT PORTD + +#endif /* BOARD_REV_PTH */ + + +#ifdef BOARD_REV_6_25_08 + +#define CHIP_ATMEGA168 + +#define LED_RED (1 << 0) +#define LED_GREEN (1 << 1) +#define LED_BLUE (1 << 2) +#define LED_YELLOW (1 << 3) + +/* LED pin definitions */ +#define LED_RED_PIN 3 +#define LED_RED_PORT PORTC +#define LED_GREEN_PIN 2 +#define LED_GREEN_PORT PORTD +#define LED_BLUE_PIN 0 +#define LED_BLUE_PORT PORTC +#define LED_YELLOW_PIN 5 +#define LED_YELLOW_PORT PORTD + +/* Button pin definitions */ +#define BUTTON_RED_PIN 2 +#define BUTTON_RED_PORT PINC +#define BUTTON_GREEN_PIN 5 +#define BUTTON_GREEN_PORT PINC +#define BUTTON_BLUE_PIN 1 +#define BUTTON_BLUE_PORT PINC +#define BUTTON_YELLOW_PIN 6 +#define BUTTON_YELLOW_PORT PIND + +/* Buzzer pin definitions */ +#define BUZZER1 3 +#define BUZZER1_PORT PORTD +#define BUZZER2 4 +#define BUZZER2_PORT PORTD + +#endif /* BOARD_REV_6_25_08 */ + + +#ifdef BOARD_REV_4_9_2009 + +#define CHIP_ATMEGA168 + +/* LED pin definitions */ +#define LED_BLUE_PIN 5 +#define LED_BLUE_PORT PORTB +#define LED_YELLOW_PIN 5 +#define LED_YELLOW_PORT PORTD +#define LED_RED_PIN 2 +#define LED_RED_PORT PORTB +#define LED_GREEN_PIN 2 +#define LED_GREEN_PORT PORTD + +/* Button pin definitions */ +#define BUTTON_RED_PIN 0 +#define BUTTON_RED_PORT PINB +#define BUTTON_GREEN_PIN 1 +#define BUTTON_GREEN_PORT PINB +#define BUTTON_BLUE_PIN 7 +#define BUTTON_BLUE_PORT PIND +#define BUTTON_YELLOW_PIN 6 +#define BUTTON_YELLOW_PORT PIND + +/* Buzzer pin definitions */ +#define BUZZER1 3 +#define BUZZER1_PORT PORTD +#define BUZZER2 4 +#define BUZZER2_PORT PORTD + +#endif /* BOARD_REV_4_9_2009 */ + +#ifdef BOARD_REV_6_3_2009 + +#define CHIP_ATMEGA168 + +#define LED_RED (1 << 0) +#define LED_GREEN (1 << 1) +#define LED_BLUE (1 << 2) +#define LED_YELLOW (1 << 3) + +/* LED pin definitions */ +#define LED_RED_PIN 2 +#define LED_RED_PORT PORTB +#define LED_GREEN_PIN 2 +#define LED_GREEN_PORT PORTD +#define LED_BLUE_PIN 5 +#define LED_BLUE_PORT PORTB +#define LED_YELLOW_PIN 5 +#define LED_YELLOW_PORT PORTD + +/* Button pin definitions */ +#define BUTTON_RED_PIN 0 +#define BUTTON_RED_PORT PINB +#define BUTTON_GREEN_PIN 1 +#define BUTTON_GREEN_PORT PINB +#define BUTTON_BLUE_PIN 7 +#define BUTTON_BLUE_PORT PIND +#define BUTTON_YELLOW_PIN 6 +#define BUTTON_YELLOW_PORT PIND + +/* Buzzer pin definitions */ +#define BUZZER1 3 +#define BUZZER1_PORT PORTD +#define BUZZER2 4 +#define BUZZER2_PORT PORTD + +#endif /* BOARD_REV_6_3_2009 */ + +/* Define game parameters */ +#define MOVES_TO_WIN 14 +#define TIME_LIMIT 3000 /* 3000ms = 3 sec */ + +#define sbi(port_name, pin_number) (port_name |= 1< 256) + { + TIFR0 = (1< 0) { + delay_us(1000); + } +} + +/* Light the given set of LEDs */ +static void set_leds(uint8_t leds) +{ + if ((leds & LED_RED) != 0) { + sbi(LED_RED_PORT, LED_RED_PIN); + } else { + cbi(LED_RED_PORT, LED_RED_PIN); + } + if ((leds & LED_GREEN) != 0) { + sbi(LED_GREEN_PORT, LED_GREEN_PIN); + } else { + cbi(LED_GREEN_PORT, LED_GREEN_PIN); + } + if ((leds & LED_BLUE) != 0) { + sbi(LED_BLUE_PORT, LED_BLUE_PIN); + } else { + cbi(LED_BLUE_PORT, LED_BLUE_PIN); + } + if ((leds & LED_YELLOW) != 0) { + sbi(LED_YELLOW_PORT, LED_YELLOW_PIN); + } else { + cbi(LED_YELLOW_PORT, LED_YELLOW_PIN); + } +} + + +#ifdef BOARD_REV_6_25_08 +static void init_gpio(void) +{ + /* 1 = output, 0 = input */ + DDRB = 0b11111111; + DDRC = 0b00001001; /* LEDs and Buttons */ + DDRD = 0b00111110; /* LEDs, buttons, buzzer, TX/RX */ + + PORTC = 0b00100110; /* Enable pull-ups on buttons 0,2,3 */ + PORTD = 0b01000000; /* Enable pull-up on button 1 */ +} +#endif /* BOARD_REV_6_25_08 */ + +#ifdef BOARD_REV_4_9_2009 +static void init_gpio(void) +{ + /* 1 = output, 0 = input */ + DDRB = 0b11111100; /* button 2,3 on PB0,1 */ + DDRD = 0b00111110; /* LEDs, buttons, buzzer, TX/RX */ + + PORTB = 0b00000011; /* Enable pull-ups on buttons 2,3 */ + PORTD = 0b11000000; /* Enable pull-up on button 0,1 */ +} +#endif /* BOARD_REV_4_9_2009 */ + +#ifdef BOARD_REV_PTH +static void init_gpio(void) +{ + /* 1 = output, 0 = input */ + DDRB = 0xFF & ~(1< 70; x--) { + for (y = 0; y < 3; y++) { + sbi(BUZZER2_PORT, BUZZER2); + cbi(BUZZER1_PORT, BUZZER1); + + delay_us(x); + + cbi(BUZZER2_PORT, BUZZER2); + sbi(BUZZER1_PORT, BUZZER1); + + delay_us(x); + } + } +} + +/* Play the winner sound and lights */ +void play_winner(void) +{ + set_leds(LED_GREEN|LED_BLUE); + winner_sound(); + set_leds(LED_RED|LED_YELLOW); + winner_sound(); + set_leds(LED_GREEN|LED_BLUE); + winner_sound(); + set_leds(LED_RED|LED_YELLOW); + winner_sound(); +} + +/* Plays the current contents of the game moves */ +static void play_moves(void) +{ + uint8_t move; + + for (move = 0; move < nmoves; move++) { + toner(moves[move], 150); + delay_ms(150); + } +} + +/* Adds a new random button to the game sequence, by sampling the timer */ +static void add_to_moves(void) +{ + uint8_t new_button; + + /* Use the lower 2 bits of the timer for the random value */ + new_button = 1 << (TCNT2 & 0x3); + + moves[nmoves++] = new_button; +} + +/* Toggle buzzer every buzz_delay_us, for a duration of buzz_length_ms. */ +static void buzz_sound(uint16_t buzz_length_ms, uint16_t buzz_delay_us) +{ + uint32_t buzz_length_us; + + buzz_length_us = buzz_length_ms * (uint32_t)1000; + while (buzz_length_us > buzz_delay_us*2) { + buzz_length_us -= buzz_delay_us*2; + + /* toggle the buzzer at various speeds */ + cbi(BUZZER1_PORT, BUZZER1); + sbi(BUZZER2_PORT, BUZZER2); + delay_us(buzz_delay_us); + + sbi(BUZZER1_PORT, BUZZER1); + cbi(BUZZER2_PORT, BUZZER2); + delay_us(buzz_delay_us); + } +} + + +/* + * Light an LED and play tone + * + * red, upper left: 440Hz - 2.272ms - 1.136ms pulse + * green, upper right: 880Hz - 1.136ms - 0.568ms pulse + * blue, lower left: 587.33Hz - 1.702ms - 0.851ms pulse + * yellow, lower right: 784Hz - 1.276ms - 0.638ms pulse + */ +static void toner(uint8_t which, uint16_t buzz_length_ms) +{ + set_leds(which); + switch (which) { + case LED_RED: + buzz_sound(buzz_length_ms, 1136); + break; + + case LED_GREEN: + buzz_sound(buzz_length_ms, 568); + break; + + case LED_BLUE: + buzz_sound(buzz_length_ms, 851); + break; + + case LED_YELLOW: + buzz_sound(buzz_length_ms, 638); + break; + } + + /* Turn off all LEDs */ + set_leds(0); +} + +/* Show an "attract mode" display while waiting for user to press button. */ +static void attract_mode(void) +{ + while (1) { + set_leds(LED_RED); + delay_ms(100); + if (check_button() != 0x00) + return; + + set_leds(LED_BLUE); + delay_ms(100); + if (check_button() != 0x00) + return; + + set_leds(LED_GREEN); + delay_ms(100); + if (check_button() != 0x00) + return; + + set_leds(LED_YELLOW); + delay_ms(100); + if (check_button() != 0x00) + return; + } +} + + +/* Wait for a button to be pressed. Returns one of led colors (LED_RED, etc.) + * if successful, 0 if timed out */ +static uint8_t wait_for_button(void) +{ + uint16_t time_limit = TIME_LIMIT; + uint8_t released = 0; + uint8_t old_button; + + while (time_limit > 0) { + uint8_t button; + + /* Implement a small bit of debouncing */ + old_button = button; + button = check_button(); + + /* + * Make sure we've seen the previous button + * released before accepting new buttons + */ + if (button == 0) + released = 1; + if (button == old_button && released == 1) { + /* Make sure just one button is pressed */ + if (button == LED_RED || + button == LED_BLUE || + button == LED_GREEN || + button == LED_YELLOW) { + return button; + } + } + + delay_ms(1); + + time_limit--; + } + return 0; /* Timed out */ +} + + + +/* Play the game. Returns 0 if player loses, or 1 if player wins. */ +static int game_mode(void) +{ + nmoves = 0; + while (nmoves < MOVES_TO_WIN) { + uint8_t move; + + /* Add a button to the current moves, then play them back */ + add_to_moves(); + play_moves(); + + /* Then require the player to repeat the sequence. */ + for (move = 0; move < nmoves; move++) { + uint8_t choice = wait_for_button(); + + /* If wait timed out, player loses. */ + if (choice == 0) + return 0; + + toner(choice, 150); + + /* If the choice is incorect, player loses. */ + if (choice != moves[move]) { + return 0; + } + } + + /* Player was correct, delay before playing moves */ + delay_ms(1000); + } + + /* player wins */ + return 1; +} + +int main(void) +{ + + /* Setup IO pins and defaults */ + ioinit(); + + /* Main loop */ + while (1) { + /* Wait for user to start game */ + attract_mode(); + + /* Indicate the start of game play */ + set_leds(LED_RED|LED_GREEN|LED_BLUE|LED_YELLOW); + delay_ms(1000); + set_leds(0); + delay_ms(250); + + if (game_mode() != 0) { + /* Player won, play winner tones */ + play_winner(); + } else { + /* Player lost, play loser tones */ + play_loser(); + } + } + + return(0); +} + diff --git a/Firmware/SIMON_1_BLINK/SIMON_1_BLINK.pde b/Firmware/SIMON_1_BLINK/SIMON_1_BLINK.pde new file mode 100755 index 0000000..c0ec37d --- /dev/null +++ b/Firmware/SIMON_1_BLINK/SIMON_1_BLINK.pde @@ -0,0 +1,45 @@ +/* + +Simon Experiments #1 +Blink +Pete Lewis +Sparkfun Electronics +10/13/2010 + +This example code is in the public domain. + +////////////////////////////////////////////////// +SETUP & UPLOAD INSTRUCTIONS +1. Select "Tools" from the upper window menu. +2. Select "Serial Port" and then select the COM PORT that your FTDI BASIC is connected on. (It most likely will be the COM 2 or higher). +3. Select "Tools", then "Board", then "LilyPad Arduino w/ ATmega328" +4. Click on the "upload button" - it looks like a box with an arrow to the right. +////////////////////////////////////////////////// + +*/ + + + +int ledPin = 3; // The simon board has 4 LEDs on it. + // For this example, we're just going to use one. + // The other LEDs are on pins 3,5,10 and 13. + // For fun, try switching "ledPin" to another LED and see what happens! + + +// The setup() funtion runs once, when the sketch starts + +void setup() { + // initialize the digital pin as an output: + pinMode(ledPin, OUTPUT); +} + +// the loop() function runs over and over again, +// as long as the Arduino has power + +void loop() +{ + digitalWrite(ledPin, HIGH); // set the LED on + delay(1000); // wait for a second + digitalWrite(ledPin, LOW); // set the LED off + delay(1000); // wait for a second +} diff --git a/Firmware/SIMON_1_BLINK/applet/HardwareSerial.cpp.o b/Firmware/SIMON_1_BLINK/applet/HardwareSerial.cpp.o new file mode 100755 index 0000000..5201b37 Binary files /dev/null and b/Firmware/SIMON_1_BLINK/applet/HardwareSerial.cpp.o differ diff --git a/Firmware/SIMON_1_BLINK/applet/Print.cpp.o b/Firmware/SIMON_1_BLINK/applet/Print.cpp.o new file mode 100755 index 0000000..0fccf77 Binary files /dev/null and b/Firmware/SIMON_1_BLINK/applet/Print.cpp.o differ diff --git a/Firmware/SIMON_1_BLINK/applet/SIMON_1_BLINK.cpp b/Firmware/SIMON_1_BLINK/applet/SIMON_1_BLINK.cpp new file mode 100755 index 0000000..986895a --- /dev/null +++ b/Firmware/SIMON_1_BLINK/applet/SIMON_1_BLINK.cpp @@ -0,0 +1,59 @@ +/* + +Simon Experiments #1 +Blink +Pete Lewis +Sparkfun Electronics +10/13/2010 + +////////////////////////////////////////////////// +SETUP & UPLOAD INSTRUCTIONS +1. Select "Tools" from the upper window menu. +2. Select "Serial Port" and then select the COM PORT that your FTDI BASIC is connected on. (It most likely will be the COM 2 or higher). +3. Select "Tools", then "Board", then "LilyPad Arduino w/ ATmega328" +4. Click on the "upload button" - it looks like a box with an arrow to the right. +////////////////////////////////////////////////// + +*/ + + + +#include "WProgram.h" +void setup(); +void loop(); +int ledPin = 3; // The simon board has 4 LEDs on it. + // For this example, we're just going to use one. + // The other LEDs are on pins 3,5,10 and 13. + // For fun, try switching "ledPin" to another LED and see what happens! + + +// The setup() funtion runs once, when the sketch starts + +void setup() { + // initialize the digital pin as an output: + pinMode(ledPin, OUTPUT); +} + +// the loop() function runs over and over again, +// as long as the Arduino has power + +void loop() +{ + digitalWrite(ledPin, HIGH); // set the LED on + delay(1000); // wait for a second + digitalWrite(ledPin, LOW); // set the LED off + delay(1000); // wait for a second +} + +int main(void) +{ + init(); + + setup(); + + for (;;) + loop(); + + return 0; +} + diff --git a/Firmware/SIMON_1_BLINK/applet/SIMON_1_BLINK.cpp.eep b/Firmware/SIMON_1_BLINK/applet/SIMON_1_BLINK.cpp.eep new file mode 100755 index 0000000..7c166a1 --- /dev/null +++ b/Firmware/SIMON_1_BLINK/applet/SIMON_1_BLINK.cpp.eep @@ -0,0 +1 @@ +:00000001FF diff --git a/Firmware/SIMON_1_BLINK/applet/SIMON_1_BLINK.cpp.elf b/Firmware/SIMON_1_BLINK/applet/SIMON_1_BLINK.cpp.elf new file mode 100755 index 0000000..45b9907 Binary files /dev/null and b/Firmware/SIMON_1_BLINK/applet/SIMON_1_BLINK.cpp.elf differ diff --git a/Firmware/SIMON_1_BLINK/applet/SIMON_1_BLINK.cpp.hex b/Firmware/SIMON_1_BLINK/applet/SIMON_1_BLINK.cpp.hex new file mode 100755 index 0000000..710e32b --- /dev/null +++ b/Firmware/SIMON_1_BLINK/applet/SIMON_1_BLINK.cpp.hex @@ -0,0 +1,60 @@ +:100000000C9461000C947E000C947E000C947E0095 +:100010000C947E000C947E000C947E000C947E0068 +:100020000C947E000C947E000C947E000C947E0058 +:100030000C947E000C947E000C947E000C947E0048 +:100040000C94A4000C947E000C947E000C947E0012 +:100050000C947E000C947E000C947E000C947E0028 +:100060000C947E000C947E00000000002400270009 +:100070002A0000000000250028002B0000000000DE +:1000800023002600290004040404040404040202DA +:100090000202020203030303030301020408102007 +:1000A0004080010204081020010204081020000012 +:1000B0000007000201000003040600000000000029 +:1000C000000011241FBECFEFD8E0DEBFCDBF11E08E +:1000D000A0E0B1E0E6E9F3E002C005900D92A230A5 +:1000E000B107D9F711E0A2E0B1E001C01D92AB3039 +:1000F000B107E1F70E949D000C94C9010C94000027 +:100100008091000161E00E947C0168EE73E080E074 +:1001100090E00E94F8008091000160E00E947C0164 +:1001200068EE73E080E090E00E94F800089580910E +:10013000000161E00E945C0108950E9422010E947A +:1001400097000E948000FDCF1F920F920FB60F9272 +:1001500011242F933F934F935F936F937F938F93CC +:100160009F93AF93BF932091060130910701409177 +:1001700008015091090170910A01DA01C901029642 +:10018000A11DB11D672F6A5F6D3730F06D57DA0121 +:10019000C9010396A11DB11D60930A018093060158 +:1001A00090930701A0930801B09309018091020187 +:1001B00090910301A0910401B09105010196A11D48 +:1001C000B11D8093020190930301A0930401B093A9 +:1001D0000501BF91AF919F918F917F916F915F9139 +:1001E0004F913F912F910F900FBE0F901F90189538 +:1001F000EF92FF920F931F937B018C018FB7F894BE +:100200004091060150910701609108017091090128 +:100210008FBF2FB7F8948091060190910701A091AC +:100220000801B09109012FBF841B950BA60BB70BDA +:10023000E816F9060A071B0760F71F910F91FF9058 +:10024000EF900895789484B5826084BD84B5816010 +:1002500084BD85B5826085BD85B5816085BDEEE6CE +:10026000F0E0808181608083E1E8F0E0808182605D +:100270008083808181608083E0E8F0E0808181601C +:100280008083E1EBF0E0808184608083E0EBF0E04C +:10029000808181608083EAE7F0E0808184608083F0 +:1002A000808182608083808181608083808180689A +:1002B00080831092C1000895282F30E0C90186562E +:1002C0009F4FFC0194912A573F4FF9018491882355 +:1002D00091F0E82FF0E0EE0FFF1FE859FF4FA591D6 +:1002E000B491662329F48C91909589238C93089579 +:1002F0008C91892B8C930895482F50E0CA01825528 +:100300009F4FFC012491CA0186569F4FFC01949196 +:100310004A575F4FFA0134913323D1F1222331F14F +:10032000233021F4809180008F7705C0243031F490 +:10033000809180008F7D8093800018C0213019F457 +:1003400084B58F7704C0223021F484B58F7D84BDBD +:100350000DC0263021F48091B0008F7705C0273082 +:1003600029F48091B0008F7D8093B000E32FF0E0FE +:10037000EE0FFF1FEE58FF4FA591B491662329F4AD +:100380008C91909589238C9308958C91892B8C93D3 +:060390000895F894FFCF70 +:02039600030062 +:00000001FF diff --git a/Firmware/SIMON_1_BLINK/applet/SIMON_1_BLINK.cpp.o b/Firmware/SIMON_1_BLINK/applet/SIMON_1_BLINK.cpp.o new file mode 100755 index 0000000..fc35559 Binary files /dev/null and b/Firmware/SIMON_1_BLINK/applet/SIMON_1_BLINK.cpp.o differ diff --git a/Firmware/SIMON_1_BLINK/applet/WInterrupts.c.o b/Firmware/SIMON_1_BLINK/applet/WInterrupts.c.o new file mode 100755 index 0000000..55cc05d Binary files /dev/null and b/Firmware/SIMON_1_BLINK/applet/WInterrupts.c.o differ diff --git a/Firmware/SIMON_1_BLINK/applet/WMath.cpp.o b/Firmware/SIMON_1_BLINK/applet/WMath.cpp.o new file mode 100755 index 0000000..487f075 Binary files /dev/null and b/Firmware/SIMON_1_BLINK/applet/WMath.cpp.o differ diff --git a/Firmware/SIMON_1_BLINK/applet/core.a b/Firmware/SIMON_1_BLINK/applet/core.a new file mode 100755 index 0000000..3dde725 Binary files /dev/null and b/Firmware/SIMON_1_BLINK/applet/core.a differ diff --git a/Firmware/SIMON_1_BLINK/applet/pins_arduino.c.o b/Firmware/SIMON_1_BLINK/applet/pins_arduino.c.o new file mode 100755 index 0000000..85b1e16 Binary files /dev/null and b/Firmware/SIMON_1_BLINK/applet/pins_arduino.c.o differ diff --git a/Firmware/SIMON_1_BLINK/applet/wiring.c.o b/Firmware/SIMON_1_BLINK/applet/wiring.c.o new file mode 100755 index 0000000..14a7028 Binary files /dev/null and b/Firmware/SIMON_1_BLINK/applet/wiring.c.o differ diff --git a/Firmware/SIMON_1_BLINK/applet/wiring_analog.c.o b/Firmware/SIMON_1_BLINK/applet/wiring_analog.c.o new file mode 100755 index 0000000..248bb21 Binary files /dev/null and b/Firmware/SIMON_1_BLINK/applet/wiring_analog.c.o differ diff --git a/Firmware/SIMON_1_BLINK/applet/wiring_digital.c.o b/Firmware/SIMON_1_BLINK/applet/wiring_digital.c.o new file mode 100755 index 0000000..9a3f6f1 Binary files /dev/null and b/Firmware/SIMON_1_BLINK/applet/wiring_digital.c.o differ diff --git a/Firmware/SIMON_1_BLINK/applet/wiring_pulse.c.o b/Firmware/SIMON_1_BLINK/applet/wiring_pulse.c.o new file mode 100755 index 0000000..ac72d3c Binary files /dev/null and b/Firmware/SIMON_1_BLINK/applet/wiring_pulse.c.o differ diff --git a/Firmware/SIMON_1_BLINK/applet/wiring_shift.c.o b/Firmware/SIMON_1_BLINK/applet/wiring_shift.c.o new file mode 100755 index 0000000..21da028 Binary files /dev/null and b/Firmware/SIMON_1_BLINK/applet/wiring_shift.c.o differ diff --git a/Firmware/SIMON_2_BUTTON/SIMON_2_BUTTON.pde b/Firmware/SIMON_2_BUTTON/SIMON_2_BUTTON.pde new file mode 100755 index 0000000..18fd0b4 --- /dev/null +++ b/Firmware/SIMON_2_BUTTON/SIMON_2_BUTTON.pde @@ -0,0 +1,69 @@ +/* + +Simon Experiments #2 +Button +Pete Lewis +Sparkfun Electronics +10/13/2010 + +This example code is in the public domain. + +////////////////////////////////////////////////// +SETUP & UPLOAD INSTRUCTIONS +1. Select "Tools" from the upper window menu. +2. Select "Serial Port" and then select the COM PORT that your FTDI BASIC is connected on. (It most likely will be the COM 2 or higher). +3. Select "Tools", then "Board", then "LilyPad Arduino w/ ATmega328" +4. Click on the "upload button" - it looks like a box with an arrow to the right. +////////////////////////////////////////////////// + +*/ + + + +int ledPin = 3; // The simon board has 4 LEDs on it. + // For this example, we're just going to use one. + // The other LEDs are on pins 3,5,10 and 13. + // For fun, try switching "ledPin" to another pin number and see what happens! + +int buttonPin = 2; // The simon board has 4 BUTTONS on it. + // For this example, we're just going to use one. + // The other BUTTONS are on pins 2,6,9 and 12. + // For fun, try switching "buttonPin" to another pin number and see what happens! + +int button_state; // This variable will be used to "store" the state of the button. + // It will allow us to know whether the button is pressed or not. + + +// The setup() funtion runs once, when the sketch starts + +void setup() { + // initialize the led pin as an output: + pinMode(ledPin, OUTPUT); + // initialize the internal pull-up on the button pin: + digitalWrite(buttonPin, HIGH); + // initialize the button pin as an input: + pinMode(buttonPin, INPUT); + +} + +// the loop() function runs over and over again, +// as long as the Arduino has power + +void loop() +{ + + // Using the digitalRead() function, we can read the state of a pin, and know whether or not it is Logic HIGH or Logic LOW. + // When you press the button, you are actually causing an electrical connection between the pin on the micro (buttonPin) and Logic LOW (aka GND). + // Every time the loop starts over it will first set the variable "button_state" to the state of the pin. + // It is refreshing every time the loop starts over. + int button_state = digitalRead(buttonPin); + + // The second step in the loop is to actually do something with this variable. + // In this next "if statement" we are going to decide to do something. Here we are going to turn on the ledPin for a second. + if(button_state == 1){ + digitalWrite(ledPin, HIGH); // set the LED on + delay(1000); // wait for a second + digitalWrite(ledPin, LOW); // set the LED off + } + +} diff --git a/Firmware/SIMON_2_BUTTON/applet/HardwareSerial.cpp.o b/Firmware/SIMON_2_BUTTON/applet/HardwareSerial.cpp.o new file mode 100755 index 0000000..5201b37 Binary files /dev/null and b/Firmware/SIMON_2_BUTTON/applet/HardwareSerial.cpp.o differ diff --git a/Firmware/SIMON_2_BUTTON/applet/Print.cpp.o b/Firmware/SIMON_2_BUTTON/applet/Print.cpp.o new file mode 100755 index 0000000..0fccf77 Binary files /dev/null and b/Firmware/SIMON_2_BUTTON/applet/Print.cpp.o differ diff --git a/Firmware/SIMON_2_BUTTON/applet/SIMON_2_BUTTON.cpp b/Firmware/SIMON_2_BUTTON/applet/SIMON_2_BUTTON.cpp new file mode 100755 index 0000000..56686a0 --- /dev/null +++ b/Firmware/SIMON_2_BUTTON/applet/SIMON_2_BUTTON.cpp @@ -0,0 +1,80 @@ +/* + +Simon Experiments #2 +Button +Pete Lewis +Sparkfun Electronics +10/13/2010 + +////////////////////////////////////////////////// +SETUP & UPLOAD INSTRUCTIONS +1. Select "Tools" from the upper window menu. +2. Select "Serial Port" and then select the COM PORT that your FTDI BASIC is connected on. (It most likely will be the COM 2 or higher). +3. Select "Tools", then "Board", then "LilyPad Arduino w/ ATmega328" +4. Click on the "upload button" - it looks like a box with an arrow to the right. +////////////////////////////////////////////////// + +*/ + + + +#include "WProgram.h" +void setup(); +void loop(); +int ledPin = 3; // The simon board has 4 LEDs on it. + // For this example, we're just going to use one. + // The other LEDs are on pins 3,5,10 and 13. + // For fun, try switching "ledPin" to another pin number and see what happens! + +int buttonPin = 2; // The simon board has 4 BUTTONS on it. + // For this example, we're just going to use one. + // The other BUTTONS are on pins 2,6,9 and 12. + // For fun, try switching "buttonPin" to another pin number and see what happens! + +int button_state; // This variable will be used to "store" the state of the button. + // It will allow us to know whether the button is pressed or not. + + +// The setup() funtion runs once, when the sketch starts + +void setup() { + // initialize the led pin as an output: + pinMode(ledPin, OUTPUT); + // initialize the button pin as an input: + pinMode(buttonPin, INPUT); +} + +// the loop() function runs over and over again, +// as long as the Arduino has power + +void loop() +{ + + // Using the digitalRead() function, we can read the state of a pin, and know whether or not it is Logic HIGH or Logic LOW. + // When you press the button, you are actually causing an electrical connection between the pin on the micro (buttonPin) and Logic HIGH (aka power). + // Every time the loop starts over it will first set the variable "button_state" to the state of the pin. + // It is refreshing every time the loop starts over. + int button_state = digitalRead(buttonPin); + + // The second step in the loop is to actually do something with this variable. + // In this next "if statement" we are going to decide to do something. Here we are going to turn on the ledPin for a second. + if(button_state == 1){ + digitalWrite(ledPin, HIGH); // set the LED on + delay(1000); // wait for a second + digitalWrite(ledPin, LOW); // set the LED off + } + +} + +int main(void) +{ + init(); + + setup(); + + for (;;) + loop(); + + return 0; +} + diff --git a/Firmware/SIMON_2_BUTTON/applet/SIMON_2_BUTTON.cpp.eep b/Firmware/SIMON_2_BUTTON/applet/SIMON_2_BUTTON.cpp.eep new file mode 100755 index 0000000..7c166a1 --- /dev/null +++ b/Firmware/SIMON_2_BUTTON/applet/SIMON_2_BUTTON.cpp.eep @@ -0,0 +1 @@ +:00000001FF diff --git a/Firmware/SIMON_2_BUTTON/applet/SIMON_2_BUTTON.cpp.elf b/Firmware/SIMON_2_BUTTON/applet/SIMON_2_BUTTON.cpp.elf new file mode 100755 index 0000000..110397a Binary files /dev/null and b/Firmware/SIMON_2_BUTTON/applet/SIMON_2_BUTTON.cpp.elf differ diff --git a/Firmware/SIMON_2_BUTTON/applet/SIMON_2_BUTTON.cpp.hex b/Firmware/SIMON_2_BUTTON/applet/SIMON_2_BUTTON.cpp.hex new file mode 100755 index 0000000..d2625e0 --- /dev/null +++ b/Firmware/SIMON_2_BUTTON/applet/SIMON_2_BUTTON.cpp.hex @@ -0,0 +1,70 @@ +:100000000C9461000C947E000C947E000C947E0095 +:100010000C947E000C947E000C947E000C947E0068 +:100020000C947E000C947E000C947E000C947E0058 +:100030000C947E000C947E000C947E000C947E0048 +:100040000C94A9000C947E000C947E000C947E000D +:100050000C947E000C947E000C947E000C947E0028 +:100060000C947E000C947E00000000002400270009 +:100070002A0000000000250028002B0000000000DE +:1000800023002600290004040404040404040202DA +:100090000202020203030303030301020408102007 +:1000A0004080010204081020010204081020000012 +:1000B0000007000201000003040600000000000029 +:1000C000000011241FBECFEFD8E0DEBFCDBF11E08E +:1000D000A0E0B1E0EEE3F4E002C005900D92A430A0 +:1000E000B107D9F711E0A4E0B1E001C01D92AD3035 +:1000F000B107E1F70E94A2000C941D020C940000CD +:10010000809102010E94CE01019781F4809100014B +:1001100061E00E94810168EE73E080E090E00E945F +:10012000FD008091000160E00E94810108958091AE +:10013000000161E00E9461018091020160E00E9483 +:10014000610108950E9427010E9497000E9480008B +:10015000FDCF1F920F920FB60F9211242F933F9352 +:100160004F935F936F937F938F939F93AF93BF93BF +:10017000209108013091090140910A0150910B0131 +:1001800070910C01DA01C9010296A11DB11D672F02 +:100190006A5F6D3730F06D57DA01C9010396A11D12 +:1001A000B11D60930C018093080190930901A09305 +:1001B0000A01B0930B018091040190910501A09177 +:1001C0000601B09107010196A11DB11D80930401A4 +:1001D00090930501A0930601B0930701BF91AF91E1 +:1001E0009F918F917F916F915F914F913F912F914F +:1001F0000F900FBE0F901F901895EF92FF920F93E4 +:100200001F937B018C018FB7F894409108015091A6 +:10021000090160910A0170910B018FBF2FB7F8940B +:100220008091080190910901A0910A01B0910B0100 +:100230002FBF841B950BA60BB70BE816F9060A0710 +:100240001B0760F71F910F91FF90EF90089578942E +:1002500084B5826084BD84B5816084BD85B58260CB +:1002600085BD85B5816085BDEEE6F0E08081816069 +:100270008083E1E8F0E0808182608083808181601A +:100280008083E0E8F0E0808181608083E1EBF0E052 +:10029000808184608083E0EBF0E0808181608083F6 +:1002A000EAE7F0E0808184608083808182608083DF +:1002B0008081816080838081806880831092C1000A +:1002C0000895282F30E0C90186569F4FFC01949174 +:1002D0002A573F4FF9018491882391F0E82FF0E0ED +:1002E000EE0FFF1FE859FF4FA591B491662329F443 +:1002F0008C91909589238C9308958C91892B8C9364 +:100300000895482F50E0CA0182559F4FFC01249167 +:10031000CA0186569F4FFC0194914A575F4FFA01DC +:1003200034913323D1F1222331F1233021F4809110 +:1003300080008F7705C0243031F4809180008F7D5C +:100340008093800018C0213019F484B58F7704C0E1 +:10035000223021F484B58F7D84BD0DC0263021F478 +:100360008091B0008F7705C0273029F48091B000CC +:100370008F7D8093B000E32FF0E0EE0FFF1FEE586B +:10038000FF4FA591B491662329F48C919095892310 +:100390008C9308958C91892B8C930895682F70E02D +:1003A000CB0182559F4FFC012491CB0186569F4F74 +:1003B000FC0144916A577F4FFB019491992319F4F2 +:1003C00020E030E038C0222331F1233021F4809145 +:1003D00080008F7705C0243031F4809180008F7DBC +:1003E0008093800018C0213019F484B58F7704C041 +:1003F000223021F484B58F7D84BD0DC0263021F4D8 +:100400008091B0008F7705C0273029F48091B0002B +:100410008F7D8093B000892F90E0880F991F8458BA +:100420009F4FFC01A591B4918C9120E030E0842392 +:0E04300011F021E030E0C9010895F894FFCFEB +:04043E0003000200B5 +:00000001FF diff --git a/Firmware/SIMON_2_BUTTON/applet/SIMON_2_BUTTON.cpp.o b/Firmware/SIMON_2_BUTTON/applet/SIMON_2_BUTTON.cpp.o new file mode 100755 index 0000000..a816ec2 Binary files /dev/null and b/Firmware/SIMON_2_BUTTON/applet/SIMON_2_BUTTON.cpp.o differ diff --git a/Firmware/SIMON_2_BUTTON/applet/WInterrupts.c.o b/Firmware/SIMON_2_BUTTON/applet/WInterrupts.c.o new file mode 100755 index 0000000..55cc05d Binary files /dev/null and b/Firmware/SIMON_2_BUTTON/applet/WInterrupts.c.o differ diff --git a/Firmware/SIMON_2_BUTTON/applet/WMath.cpp.o b/Firmware/SIMON_2_BUTTON/applet/WMath.cpp.o new file mode 100755 index 0000000..487f075 Binary files /dev/null and b/Firmware/SIMON_2_BUTTON/applet/WMath.cpp.o differ diff --git a/Firmware/SIMON_2_BUTTON/applet/core.a b/Firmware/SIMON_2_BUTTON/applet/core.a new file mode 100755 index 0000000..1868e3e Binary files /dev/null and b/Firmware/SIMON_2_BUTTON/applet/core.a differ diff --git a/Firmware/SIMON_2_BUTTON/applet/pins_arduino.c.o b/Firmware/SIMON_2_BUTTON/applet/pins_arduino.c.o new file mode 100755 index 0000000..85b1e16 Binary files /dev/null and b/Firmware/SIMON_2_BUTTON/applet/pins_arduino.c.o differ diff --git a/Firmware/SIMON_2_BUTTON/applet/simon.h b/Firmware/SIMON_2_BUTTON/applet/simon.h new file mode 100755 index 0000000..dfeda66 --- /dev/null +++ b/Firmware/SIMON_2_BUTTON/applet/simon.h @@ -0,0 +1,13 @@ + +int ledPin = 3; // The simon board has 4 LEDs on it. + // For this example, we're just going to use one. + // The other LEDs are on pins 3,5,10 and 13. + // For fun, try switching "ledPin" to another pin number and see what happens! + +int buttonPin = 2; // The simon board has 4 BUTTONS on it. + // For this example, we're just going to use one. + // The other BUTTONS are on pins 2,6,9 and 12. + // For fun, try switching "buttonPin" to another pin number and see what happens! + +int button_state; // This variable will be used to "store" the state of the button. + // It will allow us to know whether the button is pressed or not. diff --git a/Firmware/SIMON_2_BUTTON/applet/wiring.c.o b/Firmware/SIMON_2_BUTTON/applet/wiring.c.o new file mode 100755 index 0000000..14a7028 Binary files /dev/null and b/Firmware/SIMON_2_BUTTON/applet/wiring.c.o differ diff --git a/Firmware/SIMON_2_BUTTON/applet/wiring_analog.c.o b/Firmware/SIMON_2_BUTTON/applet/wiring_analog.c.o new file mode 100755 index 0000000..248bb21 Binary files /dev/null and b/Firmware/SIMON_2_BUTTON/applet/wiring_analog.c.o differ diff --git a/Firmware/SIMON_2_BUTTON/applet/wiring_digital.c.o b/Firmware/SIMON_2_BUTTON/applet/wiring_digital.c.o new file mode 100755 index 0000000..9a3f6f1 Binary files /dev/null and b/Firmware/SIMON_2_BUTTON/applet/wiring_digital.c.o differ diff --git a/Firmware/SIMON_2_BUTTON/applet/wiring_pulse.c.o b/Firmware/SIMON_2_BUTTON/applet/wiring_pulse.c.o new file mode 100755 index 0000000..ac72d3c Binary files /dev/null and b/Firmware/SIMON_2_BUTTON/applet/wiring_pulse.c.o differ diff --git a/Firmware/SIMON_2_BUTTON/applet/wiring_shift.c.o b/Firmware/SIMON_2_BUTTON/applet/wiring_shift.c.o new file mode 100755 index 0000000..21da028 Binary files /dev/null and b/Firmware/SIMON_2_BUTTON/applet/wiring_shift.c.o differ diff --git a/Firmware/SIMON_3_BUZZER/SIMON_3_BUZZER.pde b/Firmware/SIMON_3_BUZZER/SIMON_3_BUZZER.pde new file mode 100755 index 0000000..91e6fd5 --- /dev/null +++ b/Firmware/SIMON_3_BUZZER/SIMON_3_BUZZER.pde @@ -0,0 +1,69 @@ +/* +Simon Experiments #2 +Buzzer +Pete Lewis +Sparkfun Electronics +10/13/2010 + +This example code is in the public domain. + +*/ + + + +int ledPin = 3; // LEDs are on pins 3,5,10 and 13. +int buttonPin = 2; // BUTTONS are on pins 2,6,9 and 12. +int button_state; // This variable will be used to "store" the state of the button. + +/// These next two definitions are setting up the buzzer pins. +/// By sending these HIGH/LOW we can create a sound from the buzzer. +int buzzer_1 = 4; +int buzzer_2 = 7; + + +void setup() { + pinMode(ledPin, OUTPUT); + + digitalWrite(buttonPin, HIGH); + pinMode(buttonPin, INPUT); + + pinMode(buzzer_1, OUTPUT); + pinMode(buzzer_2, OUTPUT); + digitalWrite(buzzer_1, LOW); // buzzer_1 will toggle HIGH/LOW to create the sound - see buzz() function below. + digitalWrite(buzzer_2, LOW); // buzzer_2 will toggle as well (to create more volume). +} + + +void loop() +{ + int button_state = digitalRead(buttonPin); + + if(button_state == 1){ + + digitalWrite(ledPin, HIGH); // set the LED on + delay(1000); // wait for a second + digitalWrite(ledPin, LOW); // set the LED off + + // Call the "buzz()" funtion. See below to know what this does. + buzz(); + + } + +} + + +////////////////////////////////////////////////////////////////////////////////////// +void buzz(){ + /// this function makes the buzzer pin move and crease a sound. + /// By writing the pin HIGH/LOW in a pattern we can create a frequency. + /// this FOR LOOP is used to repeat the pattern and let us hear the note for second. + for(int i = 0; i < 100; i++){ + digitalWrite(buzzer_1, HIGH); + digitalWrite(buzzer_2, LOW); + delay(1); + digitalWrite(buzzer_1, LOW); + digitalWrite(buzzer_2, HIGH); + delay(1); + } +} + diff --git a/Firmware/SIMON_3_BUZZER/applet/HardwareSerial.cpp.o b/Firmware/SIMON_3_BUZZER/applet/HardwareSerial.cpp.o new file mode 100755 index 0000000..5201b37 Binary files /dev/null and b/Firmware/SIMON_3_BUZZER/applet/HardwareSerial.cpp.o differ diff --git a/Firmware/SIMON_3_BUZZER/applet/Print.cpp.o b/Firmware/SIMON_3_BUZZER/applet/Print.cpp.o new file mode 100755 index 0000000..0fccf77 Binary files /dev/null and b/Firmware/SIMON_3_BUZZER/applet/Print.cpp.o differ diff --git a/Firmware/SIMON_3_BUZZER/applet/SIMON_3_BUZZER.cpp b/Firmware/SIMON_3_BUZZER/applet/SIMON_3_BUZZER.cpp new file mode 100755 index 0000000..c395ad4 --- /dev/null +++ b/Firmware/SIMON_3_BUZZER/applet/SIMON_3_BUZZER.cpp @@ -0,0 +1,79 @@ +/* +Simon Experiments #2 +Buzzer +Pete Lewis +Sparkfun Electronics +10/13/2010 +*/ + + + +#include "WProgram.h" +void setup(); +void loop(); +void buzz(); +int ledPin = 3; // LEDs are on pins 3,5,10 and 13. +int buttonPin = 2; // BUTTONS are on pins 2,6,9 and 12. +int button_state; // This variable will be used to "store" the state of the button. + +/// These next two definitions are setting up the buzzer pins. +/// By sending these HIGH/LOW we can create a sound from the buzzer. +int buzzer_1 = 4; +int buzzer_2 = 7; + + +void setup() { + pinMode(ledPin, OUTPUT); + pinMode(buttonPin, INPUT); + + pinMode(buzzer_1, OUTPUT); + pinMode(buzzer_2, OUTPUT); + digitalWrite(buzzer_1, LOW); // buzzer_1 will toggle HIGH/LOW to create the sound - see buzz() function below. + digitalWrite(buzzer_2, LOW); // buzzer_2 will always stay low. +} + + +void loop() +{ + int button_state = digitalRead(buttonPin); + + if(button_state == 1){ + + digitalWrite(ledPin, HIGH); // set the LED on + delay(1000); // wait for a second + digitalWrite(ledPin, LOW); // set the LED off + + // Call the "buzz()" funtion. See below to know what this does. + buzz(); + + } + +} + + +////////////////////////////////////////////////////////////////////////////////////// +void buzz(){ + /// this function makes the buzzer pin move and crease a sound. + /// By writing the pin HIGH/LOW in a pattern we can create a frequency. + /// this FOR LOOP is used to repeat the pattern and let us hear the note for second. + for(int i = 0; i < 100; i++){ + digitalWrite(buzzer_1, HIGH); + delay(1); + digitalWrite(buzzer_1, LOW); + delay(1); + } +} + + +int main(void) +{ + init(); + + setup(); + + for (;;) + loop(); + + return 0; +} + diff --git a/Firmware/SIMON_3_BUZZER/applet/SIMON_3_BUZZER.cpp.eep b/Firmware/SIMON_3_BUZZER/applet/SIMON_3_BUZZER.cpp.eep new file mode 100755 index 0000000..7c166a1 --- /dev/null +++ b/Firmware/SIMON_3_BUZZER/applet/SIMON_3_BUZZER.cpp.eep @@ -0,0 +1 @@ +:00000001FF diff --git a/Firmware/SIMON_3_BUZZER/applet/SIMON_3_BUZZER.cpp.elf b/Firmware/SIMON_3_BUZZER/applet/SIMON_3_BUZZER.cpp.elf new file mode 100755 index 0000000..22a46fd Binary files /dev/null and b/Firmware/SIMON_3_BUZZER/applet/SIMON_3_BUZZER.cpp.elf differ diff --git a/Firmware/SIMON_3_BUZZER/applet/SIMON_3_BUZZER.cpp.hex b/Firmware/SIMON_3_BUZZER/applet/SIMON_3_BUZZER.cpp.hex new file mode 100755 index 0000000..996ef3f --- /dev/null +++ b/Firmware/SIMON_3_BUZZER/applet/SIMON_3_BUZZER.cpp.hex @@ -0,0 +1,77 @@ +:100000000C9461000C947E000C947E000C947E0095 +:100010000C947E000C947E000C947E000C947E0068 +:100020000C947E000C947E000C947E000C947E0058 +:100030000C947E000C947E000C947E000C947E0048 +:100040000C94E0000C947E000C947E000C947E00D6 +:100050000C947E000C947E000C947E000C947E0028 +:100060000C947E000C947E00000000002400270009 +:100070002A0000000000250028002B0000000000DE +:1000800023002600290004040404040404040202DA +:100090000202020203030303030301020408102007 +:1000A0004080010204081020010204081020000012 +:1000B0000007000201000003040600000000000029 +:1000C000000011241FBECFEFD8E0DEBFCDBF11E08E +:1000D000A0E0B1E0ECEAF4E002C005900D92A83097 +:1000E000B107D9F711E0A8E0B1E001C01D92A1313C +:1000F000B107E1F70E94D9000C9454020C9400005F +:10010000CF93DF93C0E0D0E08091040161E00E94D2 +:10011000B80161E070E080E090E00E9434018091DD +:10012000040160E00E94B80161E070E080E090E0CE +:100130000E9434012196C436D10531F7DF91CF9169 +:100140000895809102010E940502019791F4809127 +:10015000000161E00E94B80168EE73E080E090E089 +:100160000E9434018091000160E00E94B8010E9469 +:10017000800008958091000161E00E9498018091C3 +:10018000020160E00E9498018091040161E00E94F8 +:1001900098018091060161E00E949801809104011C +:1001A00060E00E94B8018091060160E00E94B80101 +:1001B00008950E945E010E94BA000E94A100FDCF36 +:1001C0001F920F920FB60F9211242F933F934F93CC +:1001D0005F936F937F938F939F93AF93BF93209180 +:1001E0000C0130910D0140910E0150910F01709161 +:1001F0001001DA01C9010296A11DB11D672F6A5FC6 +:100200006D3730F06D57DA01C9010396A11DB11D9C +:100210006093100180930C0190930D01A0930E0147 +:10022000B0930F018091080190910901A0910A01FA +:10023000B0910B010196A11DB11D8093080190930F +:100240000901A0930A01B0930B01BF91AF919F9157 +:100250008F917F916F915F914F913F912F910F906F +:100260000FBE0F901F901895EF92FF920F931F9360 +:100270007B018C018FB7F89440910C0150910D01D6 +:1002800060910E0170910F018FBF2FB7F89480918C +:100290000C0190910D01A0910E01B0910F012FBFA3 +:1002A000841B950BA60BB70BE816F9060A071B076C +:1002B00060F71F910F91FF90EF900895789484B5A7 +:1002C000826084BD84B5816084BD85B5826085BD52 +:1002D00085B5816085BDEEE6F0E080818160808338 +:1002E000E1E8F0E0808182608083808181608083AA +:1002F000E0E8F0E0808181608083E1EBF0E08081E4 +:1003000084608083E0EBF0E0808181608083EAE7B5 +:10031000F0E080818460808380818260808380813E +:10032000816080838081806880831092C1000895FD +:10033000282F30E0C90186569F4FFC0194912A571F +:100340003F4FF9018491882391F0E82FF0E0EE0F00 +:10035000FF1FE859FF4FA591B491662329F48C91B2 +:10036000909589238C9308958C91892B8C93089573 +:10037000482F50E0CA0182559F4FFC012491CA01C9 +:1003800086569F4FFC0194914A575F4FFA01349172 +:100390003323D1F1222331F1233021F480918000E5 +:1003A0008F7705C0243031F4809180008F7D809359 +:1003B000800018C0213019F484B58F7704C0223032 +:1003C00021F484B58F7D84BD0DC0263021F4809149 +:1003D000B0008F7705C0273029F48091B0008F7D61 +:1003E0008093B000E32FF0E0EE0FFF1FEE58FF4FB9 +:1003F000A591B491662329F48C91909589238C93CF +:1004000008958C91892B8C930895682F70E0CB010F +:1004100082559F4FFC012491CB0186569F4FFC01D2 +:1004200044916A577F4FFB019491992319F420E07E +:1004300030E038C0222331F1233021F48091800054 +:100440008F7705C0243031F4809180008F7D8093B8 +:10045000800018C0213019F484B58F7704C0223091 +:1004600021F484B58F7D84BD0DC0263021F48091A8 +:10047000B0008F7705C0273029F48091B0008F7DC0 +:100480008093B000892F90E0880F991F84589F4F68 +:10049000FC01A591B4918C9120E030E0842311F00F +:0C04A00021E030E0C9010895F894FFCF7E +:0804AC00030002000400070038 +:00000001FF diff --git a/Firmware/SIMON_3_BUZZER/applet/SIMON_3_BUZZER.cpp.o b/Firmware/SIMON_3_BUZZER/applet/SIMON_3_BUZZER.cpp.o new file mode 100755 index 0000000..f6b281e Binary files /dev/null and b/Firmware/SIMON_3_BUZZER/applet/SIMON_3_BUZZER.cpp.o differ diff --git a/Firmware/SIMON_3_BUZZER/applet/WInterrupts.c.o b/Firmware/SIMON_3_BUZZER/applet/WInterrupts.c.o new file mode 100755 index 0000000..55cc05d Binary files /dev/null and b/Firmware/SIMON_3_BUZZER/applet/WInterrupts.c.o differ diff --git a/Firmware/SIMON_3_BUZZER/applet/WMath.cpp.o b/Firmware/SIMON_3_BUZZER/applet/WMath.cpp.o new file mode 100755 index 0000000..487f075 Binary files /dev/null and b/Firmware/SIMON_3_BUZZER/applet/WMath.cpp.o differ diff --git a/Firmware/SIMON_3_BUZZER/applet/core.a b/Firmware/SIMON_3_BUZZER/applet/core.a new file mode 100755 index 0000000..5ddbf53 Binary files /dev/null and b/Firmware/SIMON_3_BUZZER/applet/core.a differ diff --git a/Firmware/SIMON_3_BUZZER/applet/pins_arduino.c.o b/Firmware/SIMON_3_BUZZER/applet/pins_arduino.c.o new file mode 100755 index 0000000..85b1e16 Binary files /dev/null and b/Firmware/SIMON_3_BUZZER/applet/pins_arduino.c.o differ diff --git a/Firmware/SIMON_3_BUZZER/applet/wiring.c.o b/Firmware/SIMON_3_BUZZER/applet/wiring.c.o new file mode 100755 index 0000000..14a7028 Binary files /dev/null and b/Firmware/SIMON_3_BUZZER/applet/wiring.c.o differ diff --git a/Firmware/SIMON_3_BUZZER/applet/wiring_analog.c.o b/Firmware/SIMON_3_BUZZER/applet/wiring_analog.c.o new file mode 100755 index 0000000..248bb21 Binary files /dev/null and b/Firmware/SIMON_3_BUZZER/applet/wiring_analog.c.o differ diff --git a/Firmware/SIMON_3_BUZZER/applet/wiring_digital.c.o b/Firmware/SIMON_3_BUZZER/applet/wiring_digital.c.o new file mode 100755 index 0000000..9a3f6f1 Binary files /dev/null and b/Firmware/SIMON_3_BUZZER/applet/wiring_digital.c.o differ diff --git a/Firmware/SIMON_3_BUZZER/applet/wiring_pulse.c.o b/Firmware/SIMON_3_BUZZER/applet/wiring_pulse.c.o new file mode 100755 index 0000000..ac72d3c Binary files /dev/null and b/Firmware/SIMON_3_BUZZER/applet/wiring_pulse.c.o differ diff --git a/Firmware/SIMON_3_BUZZER/applet/wiring_shift.c.o b/Firmware/SIMON_3_BUZZER/applet/wiring_shift.c.o new file mode 100755 index 0000000..21da028 Binary files /dev/null and b/Firmware/SIMON_3_BUZZER/applet/wiring_shift.c.o differ