Discuss Scratch
- Discussion Forums
- » Connecting to the Physical World
- » How do I read/write USB serial port?
- gtoal
-
1000+ posts
How do I read/write USB serial port?
I've built an arduino-controlled etch-a-sketch that I'd like to drive from scratch. I can have the arduino read drawing commands from the serial port, and for flow control I'd like to be able to write back an acknowledgement to the serial port so that the PC doesn't send a second drawing command until the first line has been drawn. (Otherwise the display will get out of synch, not to mention possible data loss from buffer overflows).
Does Scratch support this now? Preferably in the standard config although some non-standard version would still be OK. And if so, how?
Thanks,
Graham
Does Scratch support this now? Preferably in the standard config although some non-standard version would still be OK. And if so, how?
Thanks,
Graham
- drmcw
-
1000+ posts
How do I read/write USB serial port?
Do you mean serial port or USB port as they are different things. You'd need to write a scratch extension to get external hardware working with scratch. Scratch extensiona are still in beta testing afaik but there are topics about it in the advanced forum.
- gtoal
-
1000+ posts
How do I read/write USB serial port?
Do you mean serial port or USB port as they are different things. You'd need to write a scratch extension to get external hardware working with scratch. Scratch extensions are still in beta testing afaik but there are topics about it in the advanced forum.
I mean something that functions as an RS232 but plugs in to the USB port, eg an FTDI adapter like this: https://www.sparkfun.com/products/9716
You access it from C etc on the host side as if it were any other serial port, you don't need to drive it at the USB level yourself, there's a driver that hides that level of interface.
I haven't been around scratch since the switchover to V2 and when I noticed the Studio on the front page with projects using real-world sensors, I thought maybe this stuff has been added into the mainstream scratch now. Looks like you're saying it hasn't. I did try scratch with the MakeyMakey last year using one of those custom releases, but if there was a standard interface for it that would have been a lot nicer. (Especially since I wanted to release the same program for people to practice with that would be used at our Maker Faire this summer to drive the real hardware)
Are there any other hacks around that could substitute? For instance writing the commands to a cloud variable, and having a process on another machine somewhere read that and send it to the arduino outside of Scratch? After all, all you need to implement a communications channel is a single shared variable :-) (Are cloud variables visible via a web interface? JSON?)
thanks,
G
- drmcw
-
1000+ posts
How do I read/write USB serial port?
One of the topics about extensions is here. I'm pretty sure that the cloud variables could not be used as exposing the API for external access would be open to abuse and consequently I've not seen that API made public. The best method would be to write an extension. The only other alternative is to find a 1.4 mod which would support this. Whether one does I'm afraid I don't know.
- Discussion Forums
- » Connecting to the Physical World
-
» How do I read/write USB serial port?