hi everyone,
i have been having a bit of a bad time with pic at the moment. Burning out two 18m2 because of a faulty power supply and pic not programming. But i have sorted them problems out now. (power supply in the bin lol )
but i have 1 last problem that i can not fix.
i have been tring to genarate a random number (0 or 1 or 2) and save that random number in a varable using picaxe and logicator.
then that varable will deside what led to turn on.I HAVE DONE THIS PART
now i have been back after school (had to buy my own 18m2 lol) every day for the past 4 weeks(2:30-5) and spending hours at home. now i do code php at a high level currently doing a booking system for a department in manchster uni so i do have a good idea on coding. though basic is quite new to me.
What i have tried
1)
i have tryed the random command that genarates a number from 0-255. Now i have tried bitshifting (dividing by 128) it worked on the software, but when programed onto the pic it went to the same led MOST time it just was not random at all.
2)
so i scarpped that idea and then i tried using the random command and saving that command to a varable and then running that varable though some compare eg (k the varable i saved the random number to)
k >= 84 (if yes then i set the varable m to 0)
k >= 169 (if yes then i set the varable m to 1)
k >= 170 (if yes then i set the varable m to 2)
(this to pick which led to turn on).
Again on the software this worked fine. On the pic i get led 1 lighting first then led 2 lighting ALL the time
so the only option i have now is to do some kind of look up table. Though this is not so random
so that is what i have tried. Please can some one give me some help or a way to genatare a random number (0 or 1 or 2)
thanks you so much. i really need this. and i have been working my hardest but just not getting there.
p.s
i have been reading about that random command and some one said you need to seed the time function to the random command. i dont know what this means.
so can some one exsplain how to use the randoms command properly.
At the moment i have just put the random number on to the flowchart and set it to put the value into varable k
thanks alot for your time
UPATE
i have just slightly improved it
am am now making just the random command k three time eg
random k ----------random k----------------random k--------------them a load od compares
but still it light up mainlly the same two leds
i have been having a bit of a bad time with pic at the moment. Burning out two 18m2 because of a faulty power supply and pic not programming. But i have sorted them problems out now. (power supply in the bin lol )
but i have 1 last problem that i can not fix.
i have been tring to genarate a random number (0 or 1 or 2) and save that random number in a varable using picaxe and logicator.
then that varable will deside what led to turn on.I HAVE DONE THIS PART
now i have been back after school (had to buy my own 18m2 lol) every day for the past 4 weeks(2:30-5) and spending hours at home. now i do code php at a high level currently doing a booking system for a department in manchster uni so i do have a good idea on coding. though basic is quite new to me.
What i have tried
1)
i have tryed the random command that genarates a number from 0-255. Now i have tried bitshifting (dividing by 128) it worked on the software, but when programed onto the pic it went to the same led MOST time it just was not random at all.
2)
so i scarpped that idea and then i tried using the random command and saving that command to a varable and then running that varable though some compare eg (k the varable i saved the random number to)
k >= 84 (if yes then i set the varable m to 0)
k >= 169 (if yes then i set the varable m to 1)
k >= 170 (if yes then i set the varable m to 2)
(this to pick which led to turn on).
Again on the software this worked fine. On the pic i get led 1 lighting first then led 2 lighting ALL the time
so the only option i have now is to do some kind of look up table. Though this is not so random
so that is what i have tried. Please can some one give me some help or a way to genatare a random number (0 or 1 or 2)
thanks you so much. i really need this. and i have been working my hardest but just not getting there.
p.s
i have been reading about that random command and some one said you need to seed the time function to the random command. i dont know what this means.
so can some one exsplain how to use the randoms command properly.
At the moment i have just put the random number on to the flowchart and set it to put the value into varable k
thanks alot for your time
UPATE
i have just slightly improved it
am am now making just the random command k three time eg
random k ----------random k----------------random k--------------them a load od compares
but still it light up mainlly the same two leds
Last edited: