SC1000 Open Source Pocket size Portable Scratch Digital instrument you can build by yourself and impress your friends

[rasteri] released small pocket size digital scratch instrument and the video above explains how to assembly one. A13-SOM256 is used inside with small PIC to sense the rotating plate position and potentiometers.

Looks like a fun project! We are very tempted to build one for ourselves 🙂

A13-OLinuXino-WIFI running SCRATCH + OPEN-CV demonstration

Image

Now when we know how to interface new blocks in Scratch IDE with python and having OpenCV library up and running on OLinuXino it was matter of time to make the new project.

There is already nice project written in Scratch with eyes tracking your mouse pointer: http://scratch.mit.edu/projects/Doody/269924

Also we show you OpenCV object tracking http://www.youtube.com/watch?v=CigGvt3DXIw

Now we decided to combine both in single project:

1. Install scratchpy

# git clone git://github.com/pilliq/scratchpy.git
# cd scratchpy

    !!!IMPORTANT: Make sure that you date is set:
# date -s "3 APR 2013"
# python setup.py install

2. Install OpenCV

# apt-get install libopencv-dev python-opencv

3. Install Scratch

# apt-get install scratch

4. Open Scratch and open the demo project Eyes.sb

5. A message should appear that remote sensor connection is enabled.

If doesn’t click on “Sensing”, right click on sensor value and click “Enable remote sensor connection”.

6. Open terminal and start the tracking program

# python track.py

7. This will track yellow ball and the eyes will look at this direction

8. If you want to use some other object with different color use config.py.

Start the config:

# python config.py
Move the sliders until only the desired color is white and everything else is black.

Open track.py and edit the following line:
cv.InRangeS(imgHSV,
 cv.Scalar(0, 100, 255),
 cv.Scalar(40, 255, 256),
 imgThreshed)

Write your values, for example:

cv.InRangeS(imgHSV,
 cv.Scalar(110, 98, 100),
 cv.Scalar(131, 255, 256),
 imgThreshed)

Then just start the file:

# python track.py

If you wonder what does line 77 k = cv.WaitKey(70) this is delay as OpenCV track the object very fast and send coordinates faster than Scratchpy + Scratch can handle which leads to buffer overflow, with this delay the object tracking is artifically delaed to may Scratch have time to update the animation properly.

Here is video of this project: http://www.youtube.com/watch?v=Pyidx-zOsm4

Note that the camera is put on the top of the monitor and displays mirrored object i.e. when you move the heart right the animation moves the eyes to the right but on the camera you see mirrored image 🙂

And the GitHub sources are HERE

Next OpenCV project – Face tracking is in progress, stay tuned 🙂

SCRATCH control for MOD-IO

Image

Controlling Relays, Switching ON/OFF of 220V appliances and home automation is possible now with Scratch + MOD-IO.

1. Install python-smbus:

#apt-get install python-smbus
2. Install scratchpy

#git clone https://github.com/pilliq/scratchpy.git
#cd scratchpy
#make install

3. Run SCRATCH and open MOD-IO.sb

4. Go to ‘Sensing’. Right click ‘… sensor value’ hit: ‘Enable
remote sensor connections’ (if it not enabled).

5. Run terminal and start the python script
#python IO.py -a 0x58 -i 2 --host=xxx.xxx.xxx.xxx --port=xxxx --verbose
-i - I2C bus that you're using
-a - Address of MOD-IO (default 0x58)
--host - IP if you're connecting remote computer
--port - Port number
--verbose - Print some debug information.
For example:
#python IO.py -a 0x58 -i 2 --verbose --host=192.168.0.100 --port=40000

You should see message that the program is connected.

6. Run the Scratch block

7. Press ‘1’, ‘2’, ‘3’ or ‘4’ to toggle relays

the project is uploaded on GitHub: https://github.com/OLIMEX/OLINUXINO/tree/master/SOFTWARE/A13/A13%2BSCRATCH%2BMOD-IO

Scratch + A13-OLinuXino-WIFI Physical Computing

Image

Scratch is great visual environment very easy to understand by children.

I already blogged that Scratch is running fine on OLinuXino here https://olimex.wordpress.com/2013/03/12/a13-olinuxino-wifi-running-scratch-ide-perfect-platform-for-kids-programming-education/

What bothered us though was that we can’t use all GPIOs and hardware resource which OLinuXino offers and Scratch basic installation can only play music and make cool animations.

So we start searching info how to implement this.

Soon we found SNAP http://snap.berkeley.edu/ which is based BYOB (Build your own Blocks) which is based on Scratch but adds ability to make your own blocks, recursion etc new features.

SNAP is implemented with JavaScript so even better it runs on your Browser without need of installation. Based on SNAP there are few cool projects made by Technoboy10 (https://github.com/Technoboy10) interfacing Wii Nunchuk , Arduino and NXT-Lego robots.

I asked Technoboy10 is there documentation how to connect Hardware to SNAP and soon he published this info in the Wiki: https://github.com/Technoboy10/snap-server/wiki/How-to-create-a-Snap!-Extension which is very detailed.

So How cool is this? Kids are able to program robots with visual IDE!

Looking at Technoboy10 GitHub repository we figured out how to do this, but SNAP basic installation have no such great choice of sprites and animation examples, so I decided for the beginning to try to implement OLinuXino hardware features to SCratch.

So I posted question on Scratch forum and start to wait for reply http://scratch.mit.edu/forums/viewtopic.php?id=115821 . After few days waiting, 30+ views and none reply I did what I had to do at the beginning: searched github for “scratch c” then for “scratch python” and found what we needed:
https://github.com/pilliq/scratchpy.

This is cool python client for Scratch. When you enable remote sensors in Scratch it creates server, then with scratchpy you can pool for given variables and take their values or change them, this way you can connect sensors or actuators.

As opposite to SNAP (where SNAP i client and snap-server is made with pyton, so SNAP connects to the server) here Scratch makes server and the scratchpy client connects to it and interact through variables.

So here is our first “Hello World” blinking LED with Scratch: http://www.youtube.com/watch?v=qbTNWTa5tXQ

Instruction how to install the OLinuXino GPIO interface to Scratch is on GitHub: https://github.com/OLIMEX/OLINUXINO/tree/master/SOFTWARE/A13/A13-GPIO%2BSCRATCH

Our second project animate GPIO connector with Scratch based on real buttons inputs and LED outputs:

Image

Here is video on the GPIO interaction with SCRATCH http://www.youtube.com/watch?v=DzmvqlQodac

Now when we have this powerful tool: scratchpy to interface Scratch to anything via python, just imagine what would happend if we connect Scratch to … OpenCV 🙂

From my previous blog I show you some videos which demonstrate the power of OpenCV: face recognition, face expression recognition, color objects tracking.  You can make SCRATCH script for instance which recognize the face of the person in the fron of the web cam and run some animation to welcome it by name.

Or you can program your robot to chase this yellow pong ball which is in the front of it.

Or you can make different animations depend on the face expression of the person in the front of the camera… the applications and the fun will be endless!

A13-OLinuXino-WIFI running Scratch IDE perfect platform for kids programming education

Image

Scratch is a programming language that makes it easy to create your own interactive stories, animations, games, music, and art — and share your creations on the web.

As young people create and share Scratch projects, they learn important mathematical and computational ideas, while also learning to think creatively, reason systematically, and work collaboratively.

Scratch supports Linux and it’s easy to install it on A13-OLinuXino, on A13 the IDE runs at same speed as on desktop computer.

To install Scratch you will need to have 2G or 4GB SD card with installed X environment and 100MB free space at least because scratch installing requires around 80MB.

Also you need to configure internet access using WIFI or USB ethernet adapter. The settings are in /etc/network/interfaces.(see https://olimex.wordpress.com/2012/11/23/running-debian-with-xfce4-on-a13-olinuxino/ for details).

1. Update the Package Index with:

# apt-get update

2. Install the scratch with:

# apt-get install scratch

3. Note that by default scratch is set with oss audio driver and you have to change it to alsa sound driver.

  • type # vi /usr/bin/scratch
  • search for the following code:
if pulseaudio - - check 2>/dev/null ; then
    VMOPTIONS="$VMOPTIONS -vm-sound-oss"
    if padsp true 2>/dev/null ; then
       WRAPPER=padsp
    fi
fi
  • Comment the above lines
   #if pulseaudio - - check 2>/dev/null ; then
   # VMOPTIONS="$VMOPTIONS -vm-sound-oss"
   # if padsp true 2>/dev/null ; then
   # WRAPPER=padsp
   # fi
   #fi
 and add
   VMOPTIONS="$VMOPTIONS -vm-sound-alsa" 
 after commented lines.

4. Start X environment(for example use: startxfce4 &). The scratch is located in Application Menu>Education>Scratch

Here is video of A13-OLinuXino-WIFI running scratch animations http://www.youtube.com/watch?v=LEnpu7PBHs4&feature=youtu.be

Now we have to figure out only how to make custom A13 blocks which allow control of the GPIOs, SPI, UART and I2C via Scratch, then this may become some great platform for small robot control.