This is a read-only archive of the old Scratch 1.x Forums.
Try searching the current Scratch discussion forums.

#1 2011-04-20 05:35:08

rakel87
New Scratcher
Registered: 2011-03-15
Posts: 10

Send signals from Scratch to plate

Hello, I need help. I am developing a project with Scratch. This project consist in connect one plate (this plate have a microcontroler 8051) with Scratch. I get that the plate send signals to Scratch correctly, but now I will get that Scratch send signals to the plate. The plate is connect for a serial port. Anyone know what functions the source code I can use for to send signals. Thanks

Offline

 

#2 2011-04-20 11:25:38

abee
Scratcher
Registered: 2007-05-25
Posts: 100+

Re: Send signals from Scratch to plate

Hi, rakel87,
Wow, 8051! It's a classic.
Are you familiar with Smalltalk? If so, browse SerialPort2 class. It manages serial port. You may find the source code that uses SerialPort2 in SensorBoardMorph class. It explains how to use serial port in Scratch.

Offline

 

#3 2011-04-21 05:59:08

rakel87
New Scratcher
Registered: 2011-03-15
Posts: 10

Re: Send signals from Scratch to plate

Hello, Abi.
I'm not familiar with Smalltalk code. I would appreciate some guidance. I've been looking SensorBoardMorph class and I've not seen any request to send data. Can be used the two classes, the serial port i the SensorBoardMorph.
Thanks for the infomation

Offline

 

#4 2011-04-21 07:43:56

abee
Scratcher
Registered: 2007-05-25
Posts: 100+

Re: Send signals from Scratch to plate

The key method is SensorBoardMorph>>processIncomingData. (This notation means "instance method 'processIncomingData' of 'SensorBoardMorph' class.")

    buf _ port readByteArray.

This message expression means "receive data from the serial port as a bytearray and assign it to a temporary variable 'buf'".

    port nextPut: 1.

This message expression means "send a byte value '1' to the serial port".

Anyway I recommend that you read a book about Squeak Smalltalk.
For example:
http://www.amazon.com/Squeak-Programming-Robots-Technology-Action/dp/1590594916
http://www.amazon.com/Squeak-Quick-ObjectLand-Gene-Korienek/dp/0201731142/

Last edited by abee (2011-04-21 08:04:03)

Offline

 

#5 2011-04-26 12:50:34

rakel87
New Scratcher
Registered: 2011-03-15
Posts: 10

Re: Send signals from Scratch to plate

Hi, Abi.
I've been testing, and I don't get connect SCRATCH to the plate and not send it signals. Could you give me the full code that sends a value to the board?
Thanks

Offline

 

#6 2011-04-26 17:43:19

ReddNinja
New Scratcher
Registered: 2011-04-26
Posts: 1

Re: Send signals from Scratch to plate

how do u add pics???

Offline

 

#7 2011-04-27 00:48:02

abee
Scratcher
Registered: 2007-05-25
Posts: 100+

Re: Send signals from Scratch to plate

rakel87,
It is a difficult request. Because I don't know the protocol of your device.
However most simple code is as following.

| port buf |
port _ SerialPort2 new.
port openPortNamed: 'COM1' baud: 9600.
port nextPut: 1.
buf _ port readByteArray.
port close.
^ buf

I think there are no shortcuts to understanding Smalltalk. So you need to read the book.
BTW, I'm not Abi.

Last edited by abee (2011-04-27 00:53:47)

Offline

 

Board footer