Writing to the ports
acker_dackerly
Posts: 6
in BASIC Stamp
BS2 question:
It has been a long time since I wrote anything on the BASIC Stamp... so forgive me please for forgetting most of it...
That said, I am trying to figure out how I can write a byte value to ports.
The idea is to generate a random number, then write the three least significant bits to three port in succession.
The ultimate goal is to generate a random RGB color from LEDs (driven by a set of relays) based on the values of least-significant bits in a random number.
The process would be placed in a loop thus creating a sequence of non-repeatable colors on a lighting fixture as a game show effect.
Getting the least significant contents of a random number into three ports elegantly is the task...
Comments
I discovered that you can't get there from here....
That said, I am taking another, less magical tack with my project.
I'll post the resulting BASIC Stamp device on this thread later.
Writing 4 bits is done in one instruction and all the bits will change at the same time.
The large blue glowing thing is indeed right.
Oh and welcome back to the board and the firm.
And this message is being sponsored by the New Rebel Alliance
i KNEW there was a solution!
Thanks, Sapphire!
Next question:
I want to drive a set of three DIP-format relay with the above pins. the coil resistance is 960 ohms. can I drive them directly? And should I run them VDD or VSS?
That is probably one reason why I could not find a solution...
Hmmmm.
I just found an answer to my "drive relays directly" and the OUTA questions.
According to an article I found on the output loads for a BASIC stamp, the minimum resistance across an output pin should be no less than 1000 ohms
OUTA is one of the several commands for moving variable values to ports OUTA loads the least significant 4 bits of a byte into selected ports OUTB loads the upper 4 bits of a byte - etc.
It is all coming back to me!
Thanks!
You should always refer to the BASIC Stamp Manual as the online help is not as comprehensive.
https://www.parallax.com/downloads/basic-stamp-manual
thank you!