View Single Post
  #15   Report Post  
Posted to rec.crafts.metalworking
Dave August Dave August is offline
external usenet poster
 
Posts: 124
Default Little project for DoN or Jeff

Equally easy in PIC assembler. 10 "bit test and skip" in a row where they
skip over a jump to light the correct LED, which just loops waiting for the
"clear" button and jumps back to the 10 Test and skips, some thing like
this...

ALLOFF:
MOVLW 0xFF ;assumes high is off
MOVWF PORTC
MOVWF PORTD

CHECKSWITCHS:
BTFSS PORTB,0 ;test 1st switch, skip if it's not pushed
BRA TUNRON0 ;go turn on LED
BTFSS PORTB,1
BRA TUNRON1
BTFSS PORTB,2
BRA TUNRON2
BTFSS PORTB,3
BRA TUNRON3
BTFSS PORTB,4
BRA TUNRON4
BTFSS PORTB,5
BRA TUNRON5
BTFSS PORTB,6
BRA TUNRON6
BTFSS PORTB,7
BRA TUNRON7
BTFSS PORTA,0 ;note we switch to port A for the last 2 switchs
BRA TUNRON8
BTFSS PORTA,1
BRA TUNRON9
BRA CHECKSWITCHS ;keep trying.


TURNON0:
BCF PORTD,7 ;buzzer on
BCF PORTC,0 ;assumes lo is on
BTFSS PORTA,3 ;is the "clear putton pushed?
BRA ALLOFF ;yes go turn everything off
BRA TURNON0 ;keep checking

TURNON1:
BCF PORTD,7 ;buzzer on
BCF PORTC,1 ;assumes lo is on
BTFSS PORTA,3 ;is the "clear putton pushed?
BRA ALLOFF ;yes go turn everything off
BRA TURNON1 ;keep checking

;;;8 more of these for each LEDS.... last 2 would use bits in PORTD

Wanna see it in C...
How about a couple of C++ classes...
Mabe JAVA?, or are you a PHP type?... ohh I know you want it in PYTHON...


Theres also no need for debouncing the push buttons since once one pushed
you hang in the led loop for clear and vica-versa..

Of course this dosen't test for "multiple pushs at once", but that wasn't
part of the spec :-) Pretty easy to do though, just read all the switchs at
once.

You could also make the program slightly more complicated and after you
light the correct LED jump to a loop that either pulses the buzzer... of
buzzes it for a set ammount of time and then goes quite, but still leaves
the LED on...

FYI PIC's run just fine off batteries and have a built in 8MHZ Oscillator
and cost 3 bucks... parts list would be the PIC, 4 external resistors, the
buzzer, switchs, and LED's.. LEDS will need current limit R's unless you buy
the expensive ones with them built in. Other external R's are because only
one port on the PIC has builtin pullups for 8 of the 11 switchs, the 11th is
"clear button" or you *could* just power it down. and back up. :-)

--.- Dave


"Pete C." wrote in message
...

Stealth Pilot wrote:

On Wed, 16 Jul 2008 21:37:32 -0500, "Pete C."
wrote:


Andy Asberry wrote:

This project is for a student Quiz Bowl (think Jeopardy). Eight
handheld push button switches that turn on an led indicator (one for
each player) and energize a buzzer. It must also block all other
buttons so there are no simultaneous lights. Oh, and must be battery
powered.

Just to clue you in on my capabilities, the last course I took in
electronics was for tube radios. I can solder.

--Andy Asberry--
------Texas-----

One of the cheap little basic programmable microcontrollers ought to do
the job, something with 16 I/O lines preferably so you don't need
additional support chips. I believe Radio Scrap carries some of the
Parallax micros, as does Fry's.


I had an idle moment today and this little puzzle came to mind.
here is roughly how I would do it in one of the little GE PLC's.
(ladder logic using logicmaster)

it will look crap in a proportional font. use courier new in notepad
and you will see the typical logicmaster paper logic print.

you need to add the subroutine declaration and call in the main block
(placating the spell checkers out there).


Ow.

Simpler in basic. Just a loop doing a peek of the input port looking for
a value other than 255 (presuming switches pull low). Looping a some 10s
of killoHertz should be plenty fast in any of the current little micro
chips. After that it's a simple test to see which line went low or if
there is a tie. Gives you the ability to handle that rare tie better,
perhaps a rapid flash on the appropriate LEDs, can also do sound effects
easily.