Git Product home page Git Product logo

bromagosa / snap4arduino Goto Github PK

View Code? Open in Web Editor NEW
134.0 37.0 89.0 352.49 MB

Binding Snap! and Arduino together

Home Page: http://snap4arduino.rocks

License: GNU Affero General Public License v3.0

JavaScript 77.18% HTML 2.55% Shell 2.77% Inno Setup 0.20% C++ 17.29%
snap4arduino blocks arduino dynamic-programming live-programming visual-programming-language visual-programming snap scratch education

snap4arduino's Introduction

Snap4Arduino Logo

Snap4Arduino binds Snap! and Arduino together and is available in several flavors:

  • A desktop application for GNU/Linux, MacOSX and MS Windows.
  • A Chrome App for Chromebooks and any other device that can run the Chromium browser or Google Chrome.
  • A web application that makes use of a special Chrome extension.
  • A command line interpreter for embedded GNU/Linux machines.
  • A websockets-powered version for Linino boards.
  • A mobile app for Android. 💥 EXPERIMENTAL! BARELY USABLE! 💥

Please check out our official website for further info:

snap4arduino.rocks

Downloads

You can get the latest pre-built versions for all platforms at:

snap4arduino.rocks/#download

Documentation

The Wiki holds a bunch of tutorials on different topics. You can also find a collection of examples in the official website.

To learn more about Snap!, take a look at its official manual and its additional annex chapters.

There are also a few example projects here. To load one of them into Snap4Arduino:

  1. Click on the project name: Project name.xml
  2. Click on the Raw button: Raw
  3. Right click on the text and select Save As (or just press Control+S) to save the file into your computer.
  4. Drag and drop the file you've just downloaded into Snap4Arduino

Acknowledgements

Of course, this project wouldn't exist without:

To build installers for Microsoft Windows OSes, we are making use of Inno Setup, ran headless under Wine.

The mobile version is powered by Cordova.

Developers, read this

Before trying to build Snap4Arduino, make sure you have node, npm, sed, git, wget, zip and unzip installed in your system.

This project is built by a single shell script that takes care of everything, but it takes for granted you have first prepared your local setup.

If you haven't, please first run the prepare script with the --all parameter:

./prepare --all

The command line parameters for the prepare script are:

Usage: ./prepare [options]

    --snap              Pulls the latest Snap! version.
    --nwjs              Pulls the latest nwjs.io stable version.
    --desktop           Pulls all NodeJS modules needed for desktop versions.
    --chromeos          Pulls all NodeJS modules needed for the ChromeOS app.
    --chromium          Pulls all NodeJS modules needed for the web extension.
    --cli               Pulls all NodeJS modules needed for command-line version.
    --all               Does all of the above.
    --inno              Attempts to install Inno Setup under Wine, required to
                        build an installer for the Microsoft Windows versions.

Once your local setup is ready, you can use the build script as follows:

Usage: ./build [OPTIONS]

    --platform=TARGET   Selects a platform. Accepts both generic platform names
                        (all, mobile, desktop, desktop/gnu) and specific names
                        (desktop/gnu/64). See --help=platform for details.

    --run               Builds and runs Snap4Arduino for the specified architecture.
                        Only for desktop GNU/Linux and Android.

    --makeinstaller     Attempts to create an installer for the Microsoft Windows
                        versions. Needs Inno Setup, check prepare script for info.

    --rerun             Runs the last built version of Snap4Arduino, if it exists.
                        Only for desktop GNU/Linux.

    --keeptmp           Do not remove the temporary build directory afterwards.

    --pack              Compresses the resulting files into a properly named
                        package.

    --deploy=URL        Tries to deploy the built version(s) to a server.
                        Implicitly runs --pack.

                        --username=USERNAME Specifies a username for the deploy
                                            server.
                        --password=PASSWD   Specifies a password for that user.

To find out which platforms are supported by the build script, just run ./build --help=platform.

Usage: ./build --platform=TARGET [--run] [--deploy=URL --username=USERNAME [--dir=PATH]]

Available platforms are:
embedded/cli
desktop/win/32
desktop/win/64
desktop/osx/32
desktop/osx/64
desktop/gnu/32
desktop/gnu/64
desktop/chromeos
web/chromium
mobile/android

Generic names are also accepted, such as:
desktop
desktop/gnu
mobile
this
all

Embedded Command Line Version

See the wiki section on installing and using the command line version.

Third party NodeJS packages:

  • node-canvas (only with --canvas flag active)
  • firmata (if you need Snap4Arduino compatibility)

Old Repository

This repository contains only source files. The old, huge (2Gb+!) repository that contained all binaries can still be found for archaeologic purposes at: https://github.com/edutec/Snap4Arduino-old-huge

History

Snap4Arduino was started in 2013 as a side project in the Edutec research group from Citilab (Cornellà, Barcelona), but was soon turned into a full fledged project when it began to gain user base and became clear that it had potential. Since then, it has been used in primary schools, high schools, universities, code clubs, artistic installations and individuals from all around the world. It has received localization contributions for 13 different languages, and projects such as Phiro (India), SmartBlock (Turkey), First Makers (Chile) or ROKIT Brick (South Korea) have based their software solutions in modified versions of Snap4Arduino. From June 2016 until August 2017 it was supported and developed at Arduino.org. Nowadays it is being independently developed by Bernat Romagosa, Joan Guillén and several contributors.

Contributing

Please read CONTRIBUTING.md before sending us any pull requests. Thank you!

snap4arduino's People

Contributors

aldatsa avatar bromagosa avatar edutec avatar hasso avatar jguille2 avatar kkubicki avatar kseryj avatar ljb7977 avatar mbouzada avatar mmsequeira avatar pierre-rouanet avatar segertongh avatar triyanwn avatar yildizhuseyin avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

snap4arduino's Issues

Bluetooth Connectivity

Hi,

Just posting a quick question. I want to remotely program my Arduino UNO. Can I simply connect a bluetooth module via the Arduino's tx and rx pins, pair to the module and use Snap4Andruino with the appropriate COM port? Do I need to modify the Firmata sketch to exclude pins 1&2 from the digital inputs? Sorry for the newbie question.

pulseIn / pulseOut support

From @bromagosa on July 31, 2014 8:48

When (if) Firmata decides to go ahead with this proposal and firmatajs embraces it too, we should add support to the pulseIn/pulseOut functions.

Copied from original issue: edutec/Snap4Arduino-old-huge#16

Unplugging board fires error

Error message when unplugging cable:

events.js:160
      throw er; // Unhandled 'error' event
      ^
Error: Serialport not open.
    at SerialPort.write (/tmp/.io.nwjs.kwF3qG/node_modules/browser-serialport/index.js:234:15)
    at Board.reportVersion (/tmp/.io.nwjs.kwF3qG/node_modules/firmata/lib/firmata.js:712:18)
Error: Serialport not open.
    at SerialPort.close (/tmp/.io.nwjs.kwF3qG/node_modules/browser-serialport/index.js:262:15)

Communication problems with Arduino on MacOS when there are other bluetooth devices

From @maprzybylla on October 28, 2014 12:53

With the beta release I'm no longer able to connect my Arduino Uno to Snap4Arduino. I tried it with different Unos, using both the OldStandardFirmata and the current one. I can communicate with the Board in alpha version 1.0.6. and in Windows and also tested with the firmata_test program provided by firmata.org
screen shot 2014-10-28 at 11 45 38
screen shot 2014-10-28 at 11 45 59

Copied from original issue: edutec/Snap4Arduino-old-huge#39

Cloud signup doesn't work

From @maprzybylla on January 21, 2016 10:1

When I try to sign up I get a message:
"No such file - SnapCloudLocalSignUp.
An e-mail with your password has been sent to the address provided."
errormsg

Copied from original issue: edutec/Snap4Arduino-old-huge#74

Name installers and tar files with platform and version

From @fhunleth on January 5, 2015 23:3

The problem is that the installers and tar files either have the same or very similar names (Snap4Arduino.tar.gz or Snap4Arduino.zip) and people sometimes grab the wrong one and don't know it. I renamed the files manually when I copied them locally for our use, but would it be possible to add the platform and version number to the names on GitHub and the S4A site. E.g. Snap4Arduino-1.0-beta-win32.zip, Snap4Arduino-1.0-beta-osx.zip, Snap4Arduino-1.0-beta-linux-x64.tar.gz, etc.. It would also be nice to have more granularity in the version strings since it looks like 1.0-beta has been 1.0-beta through a few changes, but the different filenames per platform is the big thing that would help me.

I don't mind sending the pull request if you're ok with this, but let me know your preferences on naming.

Copied from original issue: edutec/Snap4Arduino-old-huge#49

4 or more servos crash (reported by Steven Vester)

Project / setup background
I'm trying to create a circuit & S4A-script in which the Arduino Uno can make 1 of 8 attached servos do a small movement, with the press of 1 of 8 linked buttons on my keyboard. My current test setup only connects 4 servos/buttons, see attached screenshot and photo. A 5v adaptor powers a breadboard which powers the 4 servos. Ground is connected to ground of adaptor AND to Arduino ground. The servos are connected to channels 4, 7, 9 and 13. Photos of my physical and my S4A setup are attached, and the S4A script file.

Bug
When I only use 3 (random) blocks of my Snap4A script, connected to 3 servos and keys, it works fine and almost never crashes. It doesn't matter to which pins and keyboard keys I assign the 3 servos. However, adding the 4th block causes the whole thing to crash often. Basically if I execute each of the 4 blocks one time in a row, then within the next 5 buttons I press, it will crash. Again this behavior does not occur when I only execute 3 out of my 4 blocks - I can happily spam any 3 out of 4 as long as I don't activate a 4th block.

I've experimented with assigning different buttons of my keyboard, as well as with different pin setups - no consistent pattern between keys/pins and the crashes. I don't think that I'm causing overlapping servo signals because (1) I press the buttons slowly and (2) there is a small safety mechanism with a timer to force some time (.2 sec) between the commands.

However I've noticed that, when I start to use any 4th block, it usually crashes with activating the 1st block (leftmost) a couple of times in a row - less so with the other ones. This makes me suspect some software error or bug...

setup 1
setup 2
setup 3
screen shot 2016-01-24 at 11 37 03

Snap4Arduino icon app shows nw.js standard icon

Hi,

Package.json defines "icon": "s4a.ico" but node supports only png/jpg formats.

We can use the existing s4a_logo_sm.png file. Then, editing package.json with "icon": "s4a_logo_sm.png" it will show our icon.

Thanks

Bluetooth port shows up in MacOSX but cannot be used

@maprzybylla wrote:

if I try to connect to the BT-device attached to Arduino Uno (which as a user I'd assume is possible given the drop-dwon menu) I get this message:
Could not talk to Arduino in port /dev/cu.HC-06-DevB
Check if firmata is loaded.

45999ba4-feaa-11e5-8932-255fe3d71857

And one more thing: if I then click ok and try to connect again, nothing happens :(

SpriteMorph.prototype.arduino.showMessage should be refactored

From @bromagosa on October 15, 2014 9:50

showMessage doesn't belong here, this should be a GUI function.

Maybe we should also rename it into showModalMessage, and prevent any other action to happen while the box is up.

This would also prevent behaviour like clicking on connect and then on disconnect while the connection dialog is still open, thus helping on #32.

Copied from original issue: edutec/Snap4Arduino-old-huge#34

Servo issues

4 comments/suggestions about Servos

1. I suggest to change angle mapping

  • Default mapping is 0-180 degrees to 544-2400 microseconds
  • Then 90º are 1472µs. Best value is 1500µs.
  • Proposed change:
    • /snap/s4a/threads.js, after line 69
    • Add board.servoConfig(pin,600,2400);
  • Then 90º will be 1500 µs

2. Fix same speed for clockwise and counter-clockwise operation

  • Regardless the mapping change proposed for angles operation, 1500 is the right value for stopped state.
  • Then, clockwise and counter-clockwise must have the same increment (the same speed).
  • Proposed change:
    • /snap/s4a/threads.js, line 77
    • We can change 1700 to 1800 value

3. Add block info to change servo speed

  • We can add more options to block (fast, slow...)

  • But maybe it's easier add info like angle option: 'angle (0-180)' : 90,

  • Proposed change:

    • /snap/s4a/blocks.js, lines 12-16
    'angle (0-180)' : 90,
    'stopped' : ['stopped'], 
    'clockwise (1500-1000)' : ['clockwise'],
    'counter-clockwise (1500-2000)' : ['counter-clockwise'],
    'disconnected' : ['disconnected']
    
  • Note: I've tested that values greater than 2000 and smaller than 1000 don't increase speed (almost in some servos)

4. Disconnecting servos does not enable pwm in 9 and 10 pins.

  • Disconnect must detach servo.
  • Proposed change:
    • /snap/s4a/threads.js
    • Change
      this.digitalWrite(pin, false);
    • to
      board.pinMode(pin, board.MODES.OUTPUT);
  • Unfortunately, this change does'nt fix de problem, because there is a bug in Servos library. We can see the missing code. We must wait. We can implement a Firmata hack to enable timer ending (see Arduino issue) but that does not run in every board (manage only one 16 bit timer).

Thanks!!

Joan

what should be done to make the s4a support some basic functions of software serial?

From @Davis4Create on December 18, 2015 7:30

I would like to modify the s4a to make it support the functions of software serial, so that more serial ports could be used when Arduino UNO being connected. Can anyone gives me some instructions to achieve this?
Here is a tutorial about expansion, but I don't really think this is enough, the work might be more complex.
http://blog.s4a.cat/2015/03/13/Extending-Firmata-for-Snap4Arduino.html

Give my high appreciation to someone who may help!

Copied from original issue: edutec/Snap4Arduino-old-huge#70

Cannot play mp3.

I've tried the latest release in Arch Linux 64bits and Windows XP. Both cannot play mp3 sound.

Poor Bluetooth connection

Hey all!

I've been working on a little robot with x2 DC motors connected via bluetooth. I've can have it working just fine as a remote controlled car but as soon as I pop a few IR sensors and try to get it following lines the bluetooth signal is really unstable.

Has anyone else had unstable connections with Bluetooth... I'm pulling my hair out as I'm feeling I've tried every hardware issue so wonder if it's related to Snap4arduino..?

Help please :/

Some help to start diving in the code?

Hi!

My apologies in advance if this is not the right place for this request -I'm a newb here.

I'm working in educational tech projects for kids. We use Makeblock for primary students and bare Arduino for secondary. The thing is that we are looking for a graphic programming environment that suits both, but none seems to fit: too limited, too dull for kids, incomplete sets of blocks,...

I wold love to make my own blocks for programming Makeblock, but not just build them in the Snap! BYOB fashion. I want to make it your way, a sort of "Snap4Makeblock".

My problems is that after looking at your repo here and trying to figure out how your blocks are programmed, I just don't know where to start. The time I can dedicate to this project is limited and I would really appreciate some hints on how to start with this. Then maybe I could write a sort of starter's guide for messing around with Snap/S4A and add it to your repo, that would be cool.

Thanks in advance and I hope we talk again soon,

Héctor

PS: you can write back in spanish, and if you prefer you can email me at [email protected].

Network port connection option

Hi,
I know you're working in a network connection to the board.

Beyond the development of this functionality, I wondered about the appropriateness that always appear in the connection dialog.
Many people (and especially newcomers) work with a single board and may not have a great knowledge about computer ports. Then, direct connection (without asking a port) is a good implementation.

My suggestion: Add a menu item (a checkbox) to enable this 'network connection' function. Then, it will only appears in the connection dialog if it's enabled.

Thanks,

Joan

Libraries and tools are not running (they don't load)

  • Snap4Arduino doesn't load libraries and tools.
  • Snap! offline has tools and libraries (xml files) downloaded on the local machine. This is an option. We can discuss here what is the best solution.
    -Meanwhile I try to point this two problems... and I'll make a PR to fix actual mode operation: opening tools and libraries from snap.berkeley.edu

Libraries

Tools

  • Code try to load a local file. This call is wrong (it's not running) by we'll try to load berkeley file

Show only the serial ports where an Arduino board is connected

From @bromagosa on July 31, 2014 9:4

At s4aBlocks.js, change this function:

function(){ serialport.list(function (err, ports) { if(ports){ ports.forEach(function(each) { portList[each.comName] = each.comName })}})}

So that it filters out only the ports with an Arduino plugged in. It is pretty trivial to do, each serialport object has an attribute that can help with that (can't remember which one but it's easy to find out again).

Copied from original issue: edutec/Snap4Arduino-old-huge#17

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.