Fermeture de l'Amic
En raison des travaux au local
nous fermons du 7/4 au 4/9
Cette adresse e-mail est protégée contre les robots spammeurs. Vous devez activer le JavaScript pour la visualiser.

Inscriptions à Yves-Renault
Samedi 2 septembre 2017
Portes ouvertes Amic à Godefroy
Mercredi 6 septembre 2017
Programme de l'année 2016-2017
Présentation rapide des différents cours proposés cette année.
Accès au PDF
Calendrier des activités 2017-2018
Aligné sur le calendrier scolaire local
Susceptible de modifications.
Accès au PDF



Permanences ouvertes à tous,  les jeudis (périodes scolaires) de 17h à 19h dans notre local 4, rue de la Mairie.


Lun Mar Mer Jeu Ven Sam Dim


En ligne

Nous avons 35 invités et aucun membre en ligne

Broadcast Commands:
Command Alt Command Result
pinXon pinXhigh Turns pin X ON
pinXoff pinXlow Turns pin X OFF
allon allhigh Turns all pins ON
alloff allow Turns all pins OFF
pinpattern1010111   Sets each pin ON or OFF depending on 1 or 0 [21,18,16,15,13,12,11]
Other commands:

You will need to see SimpleSi’s blog post for more information.

Command Result
motorX Runs motor X (A = pin11, B = pin12)
sonarX Trigger input on pin23, X = echo output on an input pin

To use the input pins, see the blog pages for more information.

Using with the RGB-LED Education Kit

Connecting to the GPIO

The pins which are allocated to outputs are slightly different to the ones we’ve previously used with python.  Below shows the GPIO connections we will use for Scratch (currently only 7 outputs are available so LED05 will need to be connected to 3V3 Pin1 – to keep it disabled).

RGB-LED Kit Pin Setup for Scratch GPIO

RGB-LED Kit Pin Setup for Scratch GPIO

Explaining the Control

When we have used the kit with python, we use the following defines to provide easy access and control of the pins:

<br />#Setup Active states<br />#Common Cathode RGB-LEDs (Cathode=Active Low)<br />LED_ENABLE = 0<br />LED_DISABLE = 1<br />RGB_ENABLE = 1<br />RGB_DISABLE = 0<br />

This reminds us what state each pin should be to ENABLE and DISABLE the LEDs.

The key aspect here is that to light up a specific LED we need both the required RGB pin(s) enabled (switched ON) and the specific LED pin enabled (switched OFF).  So if we are using the broadcast block in Scratch we shall need to say “pin18off pin11on” to light up LED3 with RGB_RED.

Of course we shall also need to put the pins into a default state (i.e. all disabled).  We can use the “pinpattern” broadcast to set all the pins as we require.  The above wiring means that the first 3 “bits” are our RGB pins, and the last 4 are our LED1-4 pins.

WARNING – Take note of the order of the pins when controlling using the pinpattern broadcast.

The Pins are ordered as follows:  21,18,16,15,13,12,11.

We have wired the kit so that the LED pins are in the following order: RGB1234

We set the RGB pins LOW and the LED pins HIGH to switch all the LEDs off:

Switch All RGB LEDs ON

Switch All RGB LEDs OFF

Similarly, to turn them all on:

Switch All RGB LEDs OFF

Switch All RGB LEDs ON

While you are free to command pins individually using the pinXon/pinXoff  commands, I find it easier to use the pin-patterns to ensure all the pins are in the state I am expecting (it also makes it easier if you start swapping blocks around).

Next Time – Some Simple Steps:

Quick Scratch script for testing the RGB Kit

Quick Scratch script for testing the RGB Kit

Using the above script, we can make Scratch move by moving the mouse, and change the colours shown on the RGB-LED kit to match Red, Green and Blue as Scratch moves over the background colours.

Detailed steps for building this script are given in Lesson 3 (Scratch GPIO) – Some Simple Steps (if you are confident with using Scratch already and are able to produce the above without help, you may skip it).

Taking things further:

Using the bit patterns may be confusing at first (in particular enabling the LEDs by switching the pins OFF), and long term this is not a friendly way to control the RGB-LED kit.  Fortunately, we can do a little work behind the scenes and help Scratch out by providing some RGB friendly commands for him to shout about!

I shall cover that in another lesson soon.