Hello guys,
I was messing around with programming the AtomPro28 using the RANDOM Function. What I am trying to do is:
1.) Learn Mbasic
2.) Generate 10 random numbers, 0-9, for the purpose of a future project I have in mind.
I would like to be able to generate, randomly, 10 possible numbers and take the value to branch to a unique phrase to send to my SpeakJet. For example, when a particular event happens, say bump into a wall, that event would run a random generator routine before passing the value to the Bump in wall speech section. What this would do is let the software choose what to say for that particular event.
Possible Phrases:
- oops
- I need to watch were I am going!
- uh oh
- what’s this wall doing here?
- Yikes, did I do that?
- Darn programmers!
- I meant to do that.
- opps, didn’t mean to do that!
- If I only had a brain
- Where am I?
The problem I have right now is the random numbers are working except sometimes I get a really big number returned to me like 14734921 when it should be only one digit!
Here is the code example:
;-----------------------------------------------------------------------------------
;
; Compiled using IDE version 08.0.0.0
; Program By Mike B.
; Debug ouput example using random generator
; MCU: AtomPro 28
;
;-----------------------------------------------------------------------------------
a var long
a = random TCA
loop
a = random a ; uses "a" to generate a new "a"
debug "Actual Number: ", dec a, 13] ; Print the lable then value.
debug "Modified Number: ", dec a dig 3, 13] ; DIG 3: number returned 3 digits left from the right
; Example: the number 100500 would return 5 because 5 is
; the third digit counting from right to left <---------
pause 5000
debug [0] ; clear the screen
goto loop
END