TAMS / Java / Hades / applets: contents | previous | next | ||||
Hades Applets contents visual index introduction std_logic_1164 gatelevel circuits delay models flipflops adders and arithm... counters LFSR and selftest memories programmable logic state-machine editor misc. demos I/O and displays DCF-77 clock relays (switch-le... CMOS circuits (sw... RTLIB logic RTLIB registers Prima processor D*CORE MicroJava Pic16 cosimulation Mips R3000 cosimu... Intel MCS4 (i4004) image processing ... [Sch04] Codeumsetzer [Sch04] Addierer [Sch04] Flipflops [Sch04] Schaltwerke [Sch04] RALU, Min... [Fer05] State-Mac... [Fer05] PIC16F84/... PIC LCD cont... PIC LCD chro... PIC calculator PIC mastermi... PIC16F84 ele... PIC RX/TX PIC CCP PIC CCP PIC Tetris [Fer05] Miscellan... [Fer05] Femtojava FreeTTS | PIC16F84 mastermind game
Circuit Description
This applet demonstrates a
PIC16 mastermind game.
The circuit consists of the microcontroller,
a standard ASCII-mode liquid-crystal display,
and three switches.
The program implements the 'mastermind' game with four places
and ten colors, with a four-digit decimal number used instead
of colored pegs.
Your task is to guess - or rather, deduce - the secret number
stored in the C source code (senha array).
(Note: If you prefer to change roles and have the computer deduce your secret number in turn, check out our mastermind solver applet, also based on the PIC16F84 microcontroller.) Press the up and down switches to change the current digit, and then next to enter a new digit. After you entered your 4 digit guess, the microcontroller checks your answer and the LC display shows the number of correct digits/colors at the correct positions (left) and the number of correct digits/colors at wrong positions (right). For the next round, press the next button again, then repeat entering your next guess via the up- and down-buttons, and press the next-switch to select the next digit. The goal is to reach the 4-0 rating and the corresponding greeting from the program. Open the PIC user-interface to watch the program execution, setting breakpoints, etc. (I recommend to uncheck the 'update display' checkbox and to click the data and program memories to enforce repainting. This saves a lot of CPU cycles and makes the animation go smoothly). To change the secret number, either edit the source code and recompile, or edit the memory values at addresses 01b,01c,01d,01e (bank0) at runtime. Of course, changing the stored number invalidates the previous answers from the program. Adding a random number generator function to initialize the secret number at program start with a random value would probably make a nice one-evening programming project. The C source code has been written by Alisson G.D. Garcia, Elizio Rezende, Daniel Rocha, Renato Silva, and Ricardo Ferreira, during the Computer Organization Undergraduate Course, Universidade Federal de Viçosa, Brazil. The following C code (archive with sources and include files) has been compiled by using picclite from Hitech: // /usr/hitech/bin/picl -16f84 -C -Zg senha.c lcd8.c delay.c // /usr/hitech/bin/picl -16f84 -Osenha.hex senha.obj lcd8.obj delay.obj #include | |||
Print version | Run this demo in the Hades editor (via Java WebStart) | ||||
Usage | FAQ | About | License | Feedback | Tutorial (PDF) | Referenzkarte (PDF, in German) | ||||
Impressum | http://tams.informatik.uni-hamburg.de/applets/hades/webdemos/95-dpi/pic16f84-mastermind/senha.html |