Right... but what's the point? As if anyone's going to even remember 256 combinations.
Type: Posts; User: Melanie; Keyword(s):
Right... but what's the point? As if anyone's going to even remember 256 combinations.
Yes you can do as per your example, as long as your RANDOM statement uses W0 (or it's assigned name).
No it won't crash... you'll just ignore the upper 8 bits... it'll work like this...
The first column is initial EEPROM Contents, the second column is after you've added 23 (remember 23 is just an...
I'm on the run today, so ultra-fast replies...
* Program starts for the evening for the first time ever:
Read 0,B0
(B0 now contains %00000000 as it has not had anything wrote to it yet)
...
+23 is just an ODD number. You can have any ODD number here - even ONE. If you use an even number, you will not have 256 random seedings, but 128. I'll leave you to figure why.
If W0 is made up...
If you enter RANDOM with the same number (be it zero or otherwise) it will always produce the same repeatable sequence.
If you had your five projects, all identical, all powered up on the same day...
Random works thus...
You provide RANDOM with a WORD variable, the contents of which is a number anywhere between 0-65535. This number is your 'seed'.
When RANDOM executes it performs an...
I keep forgetting that not everyone has PBP...
Unfortunately not having PBC I'm relying on the manual only...
RandomSeed is W0
I don't know if B0 or B1 is the Lowbyte... let's say it's B0...
Lets set this piece by piece.
1. RandomSeed in my FINAL example is a WORD (16 bits) because the RANDOM command works on a Word variable, so we need a WORD.
2. RandomSeed.Lowbyte only acts on...
Ignore my first example - it's actually unnescessarily complicated. Chosing the second example only...
Pic Powers Up and executes this code...
RandomSeed var WORD
LightSelector var BYTE
...
Actually, here's a real easy way to get a fresh seed for your Random function every time you power up... no description... see if you can figure it...
RandomSeed var Byte
PIC powers up and runs...
OK, so lets assume you fill all your EEPROM starting from location 1 to the end (let's pretend its address 127) with a Random sequence of Numbers from 1 to 16... EEPROM address zero is reserved.
...
How often does the PIC get turned on? Each evening, or every time the lady of the house strips off to jump in the pool, or... ?
Your 555 is total overkill.
You've got 16 lights you want to randomly switch.
Chose a PIC with EEPROM. Fill the EEPROM with a random selection of numbers, and you're away. Nobody's ever going to guess you're recycling a...
The easiest and simplest way to start with a Random Number seed is to employ the services of the User (unbeknown to them of course).
If you have an On/Off BUTTON, then the PIC powers up very...