Stereo Mood Lighting with the Propeller
I need to ask this question,
I want to use the mic. on the Propeller Demo Board to input music and generate lights at random as a output for a wall fixture I am creating for my room.
Has anyone done this type of thing ?
I looked in the object exchange and did not see anything like that ? Maybe I missed it.
Any help to steer me in the right direction would help.
Thank you.
I want to use the mic. on the Propeller Demo Board to input music and generate lights at random as a output for a wall fixture I am creating for my room.
Has anyone done this type of thing ?
I looked in the object exchange and did not see anything like that ? Maybe I missed it.
Any help to steer me in the right direction would help.
Thank you.

Comments
shows the start of it. I plan on having 7 columns of lights with 7 rows. The left column shows the current sound reading then
shifts to the right column.
www.facebook.com/video/video.php?v=326653910549
Post Edited (Thomas Fletcher) : 2/17/2010 9:55:31 PM GMT
CON _clkmode = xtal1 + pll16x _xinfreq = 5_000_000 VAR long lighton,volume long pin,col1,col2,col3,col4,col5,col6,col7 long high,low long i,x,height OBJ 'vp : "Conduit" mike : "get microphone volume" PUB main dira[noparse][[/noparse]0..5]~~ volume:=1 col1 := 0 col2 := 0 col3 := 0 col4 := 0 col5 := 0 col6 := 0 col7 := 0 mike.start 'vp.config(string("start:dso")) 'vp.config(string("var[img]http://forums.parallax.com/images/smilies/tongue.gif[/img]in,column1,column2")) 'vp.config(string("dso:view=pin(offset=0,scale=0.5),timescale=1s,ymode=manual")) 'vp.share(@pin,@col2) repeat GetCurrentLevel repeat 20 ' larger number decreases updates but increases lag between columns TransverseColumns 'waitcnt (900 + cnt) PUB GetCurrentLevel volume := mike.get col7 := col6 col6 := col5 col5 := col4 col4 := col3 col3 := col2 col2 := col1 if (volume > 2345) pin := 7 elseif (volume > 2340) pin := 6 elseif (volume > 2335) pin := 5 elseif (volume > 2330) pin := 4 elseif (volume > 2325) pin := 3 elseif (volume > 2320) pin := 2 elseif (volume > 2315) pin := 1 elseif (volume > 2308) pin := 0 col1 := pin PUB TransverseColumns i := 1 repeat until (i > 2) 'number of columns if i := 1 low := 0 high := 2 height := col1 LightTheColumn if i := 2 low := 3 high := 5 height := col7 LightTheColumn i++ PUB LightTheColumn x := 0 repeat until (x > height) if x == 0 outa[noparse][[/noparse]low..high] := %111 if x == 1 outa[noparse][[/noparse]low..high] := %000 if x == 2 outa[noparse][[/noparse]low..high] := %001 if x == 3 outa[noparse][[/noparse]low..high] := %010 if x == 4 outa[noparse][[/noparse]low..high] := %011 if x == 5 outa[noparse][[/noparse]low..high] := %100 if x == 6 outa[noparse][[/noparse]low..high] := %101 if x == 7 outa[noparse][[/noparse]low..high] := %110 x++{{ This program demonstrates the use of the counter in POS detector with feedback to perform ADC calculations using the following circuit: 3.3V  1nF 150kΩ adcpin ─────┳──╋─────────── Analog In 100kΩ 1nF fbpin ─────┘  Vss The two capacitors and the 100kΩ resistor must be placed within 1" of the Propeller for stable operation of the circuit and any excess leads must be cut away. This circuit will not work by placing it on the Demoboard's breadboard. The 150kΩ resistor may need slight adjustment of it's value in order to obtain as close to full scale without clipping either end. This can be tested by tieing the Analog In to 3.3V and Vss and noting the value produced, these values should be as near to 2^(sample bits)-1 (255 for bits=8) and 0 without actually being either of these numbers (otherwise clipping occurs and a range of voltages cannot be measured). These final numbers are used to compute what the full-on and full-off (3.3V and 0V) values are. Use of the circuit and program is sufficient for obtaining the voltage of a node between 0 and 3.3V. To obtain a current value, place a small ohm (<1Ω) resistor (called a current sense resistor) in the current path and use two ADC circuits to measure the voltage on both sides of the resistor. Use Ohm's law to calculate the current flowing through the resistor. The code shown below can be expanded to use both counters on the cog (CNTB in addition to the CNTA as shown below) to better utilize each cog's resources. Doing this doubling up will yeild a maximum of 16 ADC circuits, however 14 ADC circuits will be the highest practical implementation since at least 1 cog will be needed to process the data. }} CON '_clkmode = xtal1 + pll16x '_xinfreq = 5_000_000 ' At 80MHz the ADC/DAC sample resolutions and rates are as follows: ' ' sample sample ' bits rate ' ---------------- ' 5 2.5 MHz ' 6 1.25 MHz ' 7 625 KHz ' 8 313 KHz ' 9 156 KHz ' 10 78 KHz ' 11 39 KHz ' 12 19.5 KHz ' 13 9.77 KHz ' 14 4.88 KHz bits = 12 'try different values from table here 'these are the pins used for the above circuit, rename these values to reassign the pins 'for best results use two pins which are not consecutive (ie not 0&1, 2&3 etc), since crosstalk 'can occur and cause fluctuations of the computed ADC value. fbpin = 9 adcpin = 8 OBJ 'vp : "Conduit" VAR long volume,i PUB start 'vp.share(@volume,@i) cognew(@asm_entry, @volume) 'launch assembly program into a COG) pub get : vol vol := volume DAT ' ' ' Assembly program ' org asm_entry mov dira,asm_dira 'make pins 8 (ADC) and 0 (DAC) outputs movs ctra,#adcpin 'POS W/FEEDBACK mode for CTRA movd ctra,#fbpin movi ctra,#%01001_000 mov frqa,#1 mov asm_cnt,cnt 'prepare for WAITCNT loop add asm_cnt,asm_cycles :loop waitcnt asm_cnt,asm_cycles 'wait for next CNT value (timing is determinant after WAITCNT) mov asm_sample,phsa 'capture PHSA and get difference sub asm_sample,asm_old add asm_old,asm_sample wrlong asm_sample, par jmp #:loop 'wait for next sample period ' ' ' Data ' asm_cycles long |< bits - 1 'sample time asm_dira long |< fbpin 'output mask asm_cnt res 1 asm_old res 1 asm_sample res 1·http://www.discovercircuits.com/C/color-org.htm
Jim
EDIT:··Wait a minute. Tom's code is starting to get interesting.
Great video.
What I intended to do was have the mic. pick up sounds and have the propeller display the sounds by flashing lights in five column bars with four lights per column at random.
Thanks for your help.
Jim,
Something like that is what I was thinking, however I thought it might be fun to learn how to do it with the Propeller and learn some programming at the same time.
Post Edited (Rob7) : 2/17/2010 9:15:13 PM GMT
Jim