Discuss Scratch
- Discussion Forums
- » Connecting to the Physical World
- » Scratch 2.0 Extension Available for CodeShield
- itchy20
-
Scratcher
100+ posts
Scratch 2.0 Extension Available for CodeShield
Simon,
Now that I understand how pyfirmata works, you are correct it really is quite simple to use. Since S2A is my first python endeavor, trying to understand the pyfirmata code, which is virtually uncommented, was a challenge. The way it is organized also led me to much confusion and therefore I abandonded it for sormething that I knew would work.
So what does this all mean? In the next couple of 3 weeks (my schedule is a mess until mid October), I am going to adapt S2A to use firmata. I will probably be either putting a wrapper around pyfirmata, or use it as a basis for my own python firmata interface (most likely the latter).
Here are the additions/changes I am planning for pyfirmata:
1. Allow the user to redefine pin use after calling get_pin
2. For a digital reporter that has not changed its state, return a zero instead a value of None.
If I create my python firmata interface, it will be fully commented, with “private” methods clearly shown as such, and method names that are more reflective of what the method does (for example, get_pin will be renamed to assign_pin)
I will also need to add 2 sysex commands to the Arduino firmata.h file. One for the supporting rotoary encoders and the other for the Tone library. This means that I will also need to modify standard firmata with callbacks for each.
I also intend on packaging all the pieces necessary for S2A to work that I did not write (arduino libraries, python libraries, etc) with full credit to the authors, but to make it easier for folks to install.
BTW, I will be using the latest arduino firmata files (2.3.6) since it supposedly supports streaming. I am looking ahead to when I receive my digiX board (arduino compatbile board with built-in wifi).
I have no experience with Raspberry PI or BeagleBone Black at this point in time, but if it is possible to control the GPIO pins of these devices with firmata, my intention is to have S2A support them as well.
One last comment and I will end this diatribe. The RGB_GREEN you mention is only meaningful to Scratch and is not embedded anywhere in the S2A code itself. It is only found in the JSON descriptor file sent to Scratch (not my JSON client, but the file that builds the blocks), and in the mapping configuration file. You can name any extension block to anything you like and then map it in the configuration file to match it. So if you wish to use a consistant naming convention for all Scratch projects, then there is no restriction in S2A preventing this. Coming up with a standard set of nomenclature sounds like it would be worth pursuing.
Alan
Now that I understand how pyfirmata works, you are correct it really is quite simple to use. Since S2A is my first python endeavor, trying to understand the pyfirmata code, which is virtually uncommented, was a challenge. The way it is organized also led me to much confusion and therefore I abandonded it for sormething that I knew would work.
So what does this all mean? In the next couple of 3 weeks (my schedule is a mess until mid October), I am going to adapt S2A to use firmata. I will probably be either putting a wrapper around pyfirmata, or use it as a basis for my own python firmata interface (most likely the latter).
Here are the additions/changes I am planning for pyfirmata:
1. Allow the user to redefine pin use after calling get_pin
2. For a digital reporter that has not changed its state, return a zero instead a value of None.
If I create my python firmata interface, it will be fully commented, with “private” methods clearly shown as such, and method names that are more reflective of what the method does (for example, get_pin will be renamed to assign_pin)
I will also need to add 2 sysex commands to the Arduino firmata.h file. One for the supporting rotoary encoders and the other for the Tone library. This means that I will also need to modify standard firmata with callbacks for each.
I also intend on packaging all the pieces necessary for S2A to work that I did not write (arduino libraries, python libraries, etc) with full credit to the authors, but to make it easier for folks to install.
BTW, I will be using the latest arduino firmata files (2.3.6) since it supposedly supports streaming. I am looking ahead to when I receive my digiX board (arduino compatbile board with built-in wifi).
I have no experience with Raspberry PI or BeagleBone Black at this point in time, but if it is possible to control the GPIO pins of these devices with firmata, my intention is to have S2A support them as well.
One last comment and I will end this diatribe. The RGB_GREEN you mention is only meaningful to Scratch and is not embedded anywhere in the S2A code itself. It is only found in the JSON descriptor file sent to Scratch (not my JSON client, but the file that builds the blocks), and in the mapping configuration file. You can name any extension block to anything you like and then map it in the configuration file to match it. So if you wish to use a consistant naming convention for all Scratch projects, then there is no restriction in S2A preventing this. Coming up with a standard set of nomenclature sounds like it would be worth pursuing.
Alan
- SimpleScratch
-
Scratcher
500+ posts
Scratch 2.0 Extension Available for CodeShield
I'll hold off with switching to using JSON then and then hopefully be able to just use your super duper Firmata libraries/classes as they look very elegant and “correct”
(I'm looking at the way you write your Python code and trying to comprehend it so I can maybe re-use it in my projects )
Keep up the great work
Simon
(I'm looking at the way you write your Python code and trying to comprehend it so I can maybe re-use it in my projects )
Keep up the great work

Simon
- debashman
-
Scratcher
1 post
Scratch 2.0 Extension Available for CodeShield
I just want to make sure I am not missing anything here, but this does not work on MAC correct, because I can not install PySerial.
Thanks
Deb
Thanks
Deb
- itchy20
-
Scratcher
100+ posts
Scratch 2.0 Extension Available for CodeShield
I do not have a MAC so I cannot verify this, but looking at the pyserial documentation, they claim that it works with MAC.
Here are steps that might work:
1. Go to https://pypi.python.org/pypi/pyserial and download the pyserial (on that page click pyserial-2.6.tar.gz (md5) under the File heading at the top of the page).
2. Extract the files - here is a link that explains how to do his on the MAC (scroll down a little to see that section) : http://www.wikihow.com/Extract-a-Gz-File
3. To install pyserial, using a command line terminal window, first cd to the directory that you just extracted (should look like pyserial-2.6)
4. Type the following: python setup.py install
Hopefully that should work.
Here are steps that might work:
1. Go to https://pypi.python.org/pypi/pyserial and download the pyserial (on that page click pyserial-2.6.tar.gz (md5) under the File heading at the top of the page).
2. Extract the files - here is a link that explains how to do his on the MAC (scroll down a little to see that section) : http://www.wikihow.com/Extract-a-Gz-File
3. To install pyserial, using a command line terminal window, first cd to the directory that you just extracted (should look like pyserial-2.6)
4. Type the following: python setup.py install
Hopefully that should work.
- itchy20
-
Scratcher
100+ posts
Scratch 2.0 Extension Available for CodeShield
If you are trying to use the interface, there was a discrepancy between the serial baudrate that the Arduino sketch was set to (57600) and the baudrate in the .cfg files (115200). This can easily be fixed, by either downloading and using my latest Arduino sketch on github, or just change the baurdrate in the .cfg files.
I apologize for any confustion.
I apologize for any confustion.
- U_W_N
-
Scratcher
15 posts
Scratch 2.0 Extension Available for CodeShield
Let's move this topic into the developing extensions forum.
- smartter15
-
New Scratcher
1 post
Scratch 2.0 Extension Available for CodeShield
Thanks very much for the information. I am interested in writing and programming. I do programming projects for http://www.myprivateresearcher.com/
Last edited by smartter15 (Dec. 5, 2015 11:50:04)
- aggreysmith
-
New Scratcher
1 post
Scratch 2.0 Extension Available for CodeShield
Thank you for sharing this, does this still work?
SmartWrite
SmartWrite
- TurtleLegos
-
Scratcher
1000+ posts
Scratch 2.0 Extension Available for CodeShield
Thank you for sharing this, does this still work?I doubt it, this is an eight year old 2.0 demo I think.
SmartWrite
- itchy20
-
Scratcher
100+ posts
Scratch 2.0 Extension Available for CodeShield
There is a modern set of Scratch 3 extensions available. Check out the user's guide.
- rrobert24
-
New Scratcher
2 posts
Scratch 2.0 Extension Available for CodeShield
It was working . https://sites.google.com/site/bestessaywritingservicereview/
Last edited by rrobert24 (March 19, 2022 10:03:43)
- Dahipuri
-
Scratcher
1000+ posts
Scratch 2.0 Extension Available for CodeShield
Let's move this topic into the developing extensions forum.Please do not necropost
Last edited by Dahipuri (April 1, 2022 11:09:28)
- Dahipuri
-
Scratcher
1000+ posts
Scratch 2.0 Extension Available for CodeShield
It was working . https://sites.google.com/site/bestessaywritingservicereview/
There is a modern set of Scratch 3 extensions available. Check out the user's guide.
cool!
Please don't Necropost.
- Discussion Forums
- » Connecting to the Physical World
-
» Scratch 2.0 Extension Available for CodeShield








