| ??? 04/03/01 19:15 Read: times |
#10528 - RE: 8051 microcontroller help!!!!! |
You can keep a constant time for each loop by using a state machine. The state machine can represent the dice values and can be randomized within itself. Where each state has an index to the next value. And, don't forget we are probably dealing with two dice here which means 6x6 (36) possible results.
pseudo code (kind of like 'C').... // Randomly distribute the numbers 0..31 // make sure there are no loops in the // state machine though. int next_state[] = { 4,1,20,9,29,6,..., 0,31,25,2 } int last_state = 0; void show_dice() { while( !keypressed() ) ;// wait for button while ( keypressed() ) last_state = next_state[last_state]; print "First Die is ", last_state/6 +1; print "Second Die is ", last_state%6 +1; } |
| Topic | Author | Date |
| 8051 microcontroller help!!!!! | 01/01/70 00:00 | |
| RE: 8051 microcontroller help!!!!! | 01/01/70 00:00 | |
| RE: 8051 microcontroller help!!!!! | 01/01/70 00:00 | |
| RE: 8051 microcontroller help!!!!! | 01/01/70 00:00 | |
| RE: 8051 microcontroller help!!!!! | 01/01/70 00:00 | |
| RE: 8051 microcontroller help!!!!! | 01/01/70 00:00 | |
| RE: 8051 microcontroller help!!!!! | 01/01/70 00:00 | |
| RE: 8051 microcontroller help!!!!! | 01/01/70 00:00 | |
| RE: 8051 microcontroller help!!!!! | 01/01/70 00:00 | |
| RE: 8051 microcontroller help!!!!! | 01/01/70 00:00 | |
| RE: 8051 microcontroller help!!!!! | 01/01/70 00:00 | |
| RE: 8051 microcontroller help!!!!! | 01/01/70 00:00 | |
| RE: 8051 microcontroller help!!!!! | 01/01/70 00:00 | |
Rio Estika | 01/01/70 00:00 |



