Translate

Showing posts with label Scratch. Show all posts
Showing posts with label Scratch. Show all posts

The Documentation For s2-pi has been updated and can be found here:


To install the demo code either type:

sudo pip3 install s2-pi


Or

Just Released!

Control A SparkFun RedBot

With ScratchX and rb4s


Check out our latest ScratchX extension!

Installation and usage instructions can be found on the wiki.

The s2a_fm Users Guide Has Been Translated to Traditional Chinese.

Cheng Shu-Feng has generously provided the translation. The updated manaul can be found here.

Xi Is Now Available on ScratchX

The Scratch team has released an experimental web site that supports hardware extensions for Scratch and a Xi client is available at:


A French translation is available at:


Xi allows Scratch to simultaneously control mulitple Arduino, Raspberry PI and Beagle Bone Black microcontrollers and allow them to share sensor data.

To use these clients, you will need to install the Xi servers that can be found at:


Futures and Coroutines and Loops! Oh my!


I have just published an updated version of esp4s, the project that uses Scratch to interface to an Arduino Esplora microcontroller board. This latest version uses Python 3.4.3 and its associated asyncio library. The new program is called esp4s-aio and is available on Github.

Going from proof of concept to a finished project was not as simple as I had originally thought. The Python documentation for asyncio is really great for reference once you understand how to use the library, but at least for me, was not very instructive for a first time user.

But once I figured out how to convert Pyserial's readline() and write() to "futures", and was able to instantiate and communicate with an aiohttp HTTP server, I was well on my way to finishing the task at hand.

But those weren't my only educational challenges. I also needed to learn how to unit test the code and came upon pytest-asyncio. After asking the package authors several rookie questions, and receiving quick and accurate answers (without any snark I might add) the last pieces of the educational puzzle were in place.

Now on to the code. I started with the same architectural design I used for the original esp4s. However, working through the code, I quickly realized that I could take a simpler, more sequential code flow approach than I used for the original multi-threaded esp4s project. This not only simplified the design, but the testing and debugging, as well.

One very major design departure from the original project, was to go from having the Esplora pushing out all sensor data every 25 ms. to a polled approach.I was concerned that performance would suffer but that turned out not to be the case. 

Now on to the results. I used a common Scratch script called test.sb2, ( which is provided in the esp4s-aio distribution) to compare esp4s and esp4s-aio. The Scratch script toggles an LED on the Esplora while concurrently displaying status for all 16 Esplora sensors. Scratch polls for status data at a rate of approximately 30 times per second.


It was interesting to find that the esp4s-aio version shows no display lag as sensor data varies, but the original version does (which means that the design of the original was sub-optimal). 

However, more dramatic was the difference in CPU utilization. First, here is  CPU utilization for the original:


And now the CPU utilization for esp4s-aio:


In this graph, the first 20 seconds are before Scratch was started and esp4s-aio is running idle. The increase begins when the Scratch script starts polling for data.

So overall, I am very pleased with the results, and plan to use asyncio coroutines for several future projects.  Since my projects tend to be more I/O intensive than CPU intensive, asyncio and coroutines are definitely in my future.






Italian Translation Has Been Added To 

s2a_fm

For Both Scratch and Snap!


Gianfranco Zuliani has graciously provided an Italian translation for s2a_fm.

You can get this latest translation on Github.

Thank you Gianfranco!!!

s2a_fm Taiwanese Translation Available on Github


Thanks to Hsu Jen-Chieh, s2a_fm blocks have been translated to Taiwanese.

s2a_fm is now contains block translations for 9 different languages supporting both Scratch and Snap!

Xi Status Update 2

The first set of block definitions has been finalized (pictured below)  and all client/server code has been completed. Testing for Arduino, and Raspberry Pi is complete on Linux. 

I just need to complete the BeagleBone Black testing, then retest all micro-controllers on Windows. When the documentation is completed, release v.001 will become available.


Additional Features That Will Be Included With v.001

All the features described in this section have been tested in Linux and are ready to be included in the first release.

1. As you probably know, Xi makes use of the Johnny-Five library. This powerful library provides a consistent, hardware independent micro-controller API.  As result, a single server file supports all 3 micro-controllers. Less code, means less maintenance.

2. Speaking of launching, when the XiDuino server is launched, it will automatically launch your default web browser and set the page to http://scratch.mit.edu/. If your browser is already open, it will open a new tab to Scratch. Place the XiDuino launch command in  a .bat file or shell script, create a shortcut,  and you have "One Button Launching".

3. Another feature that was added is automatic Pin/PWM compatibility checking. If a pin is selected for PWM operation, but does not actually support PWM, an error message is displayed. Below, is a screen shot of the alert message generated when pin 7 on a Leonardo was attempted to be set to PWM mode. The feature works for the Raspberry Pi and BeagleBone Black as well.


Future Release Plans

  1. Support for additional devices. (Servo, Sonar, Piezo, Steppers, etc.)
  2. Support for Snap!
  3. A simplified block language translation scheme.
  4. A one-click install script.


Stay tuned - there is more to come!



Xi

The Next GenerationScratch 2.0 Hardware Interface For Arduino, Raspberry Pi, and BeagleBone Black


              Click here to see the proof of concept results and video demos.



Build your own Talking Tom Toy 

with SCRATCH and Arduino




Ih his latest article, Prof. Aldo von Wangenheim explains how to use Scratch and s2a_fm to create this toy using sensors and bi-directional Scratch-Arduino Communication.