[Newbies] Timer in Morph

Garret Raziel boloomka at gmail.com
Fri Feb 5 17:56:43 UTC 2010

Thanks so much, it just works! And I have another problem, but now I will be
propably more difficult. I have morph that reads values from SerialPort and
on the other end of Serial cabel I have an arduino (AVR microchip). I am
reading values from 0 to 255 on arduino's pin (I have infrared receiver
here) and I am sending them immediately over serial to squeak. Here I am
setting Morph's color to value I have received every 500 steps. I have this

    | s n |
    n := SerialPort new.
    n baudRate: 9600.
    n openPort: 7.
    s := n readString asInteger.
    Transcript show: s; cr.
    s := s - 46 * (1/60).
    self color: (Color r:s g:s b:s).
    n close.

and it works almost fine. But there is a bug. Time to time I receive only a
part of value, for example I am receiving: 56 55 56 55 5 6 55 ... 102 103
103 100 102 1 1 0 102 102. Those one-digit values are truly false and it
looks like the mistake in receiving. How can I synchonize sending and
receiving? Or do I have to use other method of SerialPort? Thanks.

On Thu, Feb 4, 2010 at 9:46 PM, Edgar J. De Cleene <
edgardec2001 at yahoo.com.ar> wrote:

> On 2/4/10 7:18 PM, "Garret Raziel" <boloomka at gmail.com> wrote:
> hi, can anyone help me with some code? I want to have a Morph object that
> change his color by values that squeak gets from SerialPort. I have wroted
> code of getting values and changing color but I dunno how to do that the
> morph change its color forever. If i call method "AMorph changeColor" in
> some to:do: it stucks and shows only last color. I want to use some kind of
> timer, that will call this method every second and updates this Morph. what
> must I use?
> You should use step and stepTime methods.
> In step you put whatever you like your morph do.
> In stepTime  you put the time in milliseconds for each change
> I add a example, you could drag and drop on any Squeak you have and see a
> red thing in the upper corner of Squeak telling the name of the current
> project and position of mouse.
> Select load as morph.
> Edgar
> _______________________________________________
> Beginners mailing list
> Beginners at lists.squeakfoundation.org
> http://lists.squeakfoundation.org/mailman/listinfo/beginners
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.squeakfoundation.org/pipermail/beginners/attachments/20100205/72059a79/attachment.htm

More information about the Beginners mailing list