Search the web
Sign In
New User? Sign Up
AVRButterFly · AVR ButterFly & Beginners Group
? Already a member? Sign in to Yahoo!

Yahoo! Groups Tips

Did you know...
Hear how Yahoo! Groups has changed the lives of others. Take me there.

Best of Y! Groups

   Check them out and nominate your group.
Having problems with message search? Fill out this form to ensure your group is one of the first to be migrated to the new message search system.

Messages

  Messages Help
Advanced
THEREMIN AEROPHONE - Makes Music Based on PhotoResistor (In Assemble   Message List  
Reply | Forward Message #977 of 996 |
This is a simple assembly language program (approx 90 bytes) that plays the
classic music used in classic horror and sci-fi films.
The frequency is based on the amount of light hitting the LDR-CDS cell, which
you can vary by waving your hand over the LDR.

[code]
;-------------------------------------;
; A BASIC THEREMIN AETHERPHONE ;
; PLAYS NOTES ACCORDING TO THE LIGHT ;
; SENSITIVE ON-BOARD CDS CELL ;
; BY RETRODAN 7-OCT-09 ;
;-------------------------------------;

.include "m169def.inc"

.DEF A = R16
.DEF AH = R17
.DEF B = R18
.DEF C = R19
.DEF D = R20
.DEF I = R21
.DEF J = R22
.DEF K = R23
.DEF N = R24

.ORG $0000
RJMP RESET

RESET: LDI A,HIGH(RAMEND) ;SETUP THE STACK POINTER
OUT SPH,A ;AT TOP OF MEMORY AND
LDI A,LOW(RAMEND) ;GROW DOWNWARDS
OUT SPL,A
LDI A,128 ;SET CLOCK SPEED
STS CLKPR,A
LDI A,3 ;0=8MHz 1=4MHz 2=2MHz 3=1MHz
STS CLKPR,A ;BUTTERFLY RUNS AT 2MHZ OUT-OF-THE-BOX

LDI A,2 ;SELECT INPUT 0=TEMP,2=LIGHT
STS ADMUX,A

LDI A,0x83 ;(1<<ADEN) | (1<<ADPS1) | (1<<ADPS0) ;set ADC
prescaler to , 1MHz / 8 = 125kHz
STS ADCSRA,A

SBI PORTF,PORTF3 ;INTIALIZE PORT F
SBI DDRF,PORTF3 ;

READEM:
LDI A,0xC3 ;(1<<ADSC) | (1<<ADEN) | (1<<ADPS1) | (1<<ADPS0)
;set ADC prescaler to , 1MHz / 8 = 125kHz
STS ADCSRA,A........;START ANALOG TO DIGITAL CONVERSION
DISPLAY:
LDS A,ADCSRA ;WAIT FOR ADC CONVERSION
ANDI A,(1<<ADIF)
BREQ DISPLAY

LDS A, ADCL ;MUST READ ADCL BEFORE ADCH
LDS AH, ADCH
RCALL SOUNDER ;MAKE MUSIC
RJMP READEM

;================= SUBROUTINES ===================

;----------------------------------------------------;
; SOUNDS A FREQUENCY BASED ON CONTENTS OF A REGISTER ;
;----------------------------------------------------;
SOUNDER:SBI DDRB,5 ;SET PORTB-BIT5 FOR OUTPUT
BLUPE: SBI PORTB,5 ;SET PORTB-BIT5
RCALL BPAUSE ;WAIT
CBI PORTB,5 ;CLEAR BORTB-BIT5
RCALL BPAUSE ;WAIT
RET

BPAUSE: PUSH A ;PAUSE TWEEN PULSES
BPLUPE: INC A ;IE DETERMINS FREQ
BRNE BPLUPE
POP A
RET
[/code]




Mon Oct 19, 2009 9:15 pm

retr0dan
Offline Offline
Send Email Send Email

Forward
Message #977 of 996 |
Expand Messages Author Sort by Date

This is a simple assembly language program (approx 90 bytes) that plays the classic music used in classic horror and sci-fi films. The frequency is based on...
retr0dan
Offline Send Email
Oct 19, 2009
9:18 pm
Advanced

Copyright © 2009 Yahoo! Inc. All rights reserved.
Privacy Policy - Terms of Service - Guidelines - Help