Update: In element14 communinty says this project is awesome!
This project starts a few months ago. Juan Brito, author of the blog Desafio Ecuador, contacted with me to talk about Scratch and the opportunities that gives this programming enviroment in the world of education. In his own words:
I and Danny Macancela are convinced that increase the quality of education in schools and colleges do not require big budgets by governments. This ideal of change has led us to develop this project to teach children mathematics and programming. Children can learn maths with fables. The aim of this project is the search of the human talent growth, which starts in the classroom. As Fritjof Capra says, ‘Today we have the knowledge, technology and financial resources to build a sustainable future. All we need is the political will and leadership’
From here, I also want to thank Danny Macancela for his illusion in the project and its economic support.
Scratch for Arduino
Scratch for Arduino is a Scratch modification that allows program Arduino platform on a simple way, using a high level interface. It includes specific blocks for managing sensors and actuators connected to Arduino board. In the project webpage you can find all the info and resourcers to start working with it.
At this time, every pin of the Arduino has a specific function, so you must keep this in mind when connect devices to the Arduino board. Here’s a resume of the pins and functions:
- Digital Inputs: Digital pins 2 and 3
- Analog inputs: 6 analog pins
- Digital outputs: Digital pins 10,11 and 13
- Analog outputs (PWM): Digital pins 5, 6 and 9
- Four special outputs to connect continuous rotation servomotors: Digital pins 4, 7, 8 and 12.
To use this mod of Scratch with Arduino, first you must install Arduino environment (including drivers) and upload to the board the firmware that allows the communication between Scratch and the board. Once you make this steps, you will have the system ready to start working with S4A!
The K4S board is oriented for a educational environment, so the hardware is ‘simple’, and has the basic elements to start working with S4A. I develop this breakout board to fit in the Arduino Uno board. Why Arduino Uno? Because from S4A ensures that with this board they test the software and works. I’m working with this board about three months and always works fine! Here you can find the schematic of the board.
The elements I select to include in the breakout board are the following ones:
- Three 10mm diffused leds:
The left one (blue led in the below image) is connected to the analog output 9 (PWM). This allows to vary the intensity of the led, in function of the output value (PWM outputs are not ON/OFF outputs. It values can vary from 0 to 255, so in function of the used value, the led brights more or less).
The middle led (red one) is connected to the digital output 10. Here, only ON/OFF states are allowed.
The right led (yellow one) is connected to the digital output 11. Here, same as red one, only ON/OFF states are allowed.
The buzzer is connected to the digital output 13, through a digital MOSFET transistor (FDV301N) to activate it.
- One linear potentiometer
The potentiometer is connected to the analog input 5, and allows send to Scratch analog values from 0 to 1023.
- Three pushbuttons
As I mentioned previously, S4A has specific pins for specific functions. We want three inputs for read three pushbuttons but S4A only has 2 digital inputs. To solve this, I use the analog inputs for the pushbuttons too. I can configure each pushbutton (by hardware) to read it as an analog input or as digital input:
‘A‘ button can be connected to digital input 2 or to analog input A0. Actually is configured to read as digital input.
‘B‘ button can be connected to digital input 3 or to analog input A1. Actually is configured to read as digital input.
‘C‘ button can be connected to special digital output 4 or to analog input A2. Actually is configured to read as analog input, because digital 4 is set as output. If in the future this output can change into an input, then the pushbutton will be read as a digital input.
The board is designed to fit in the Arduino UNO board. After googling some time looking for the outline Arduino UNO board compatible with Altium Designer and don’t find it, I decide to make my own board using the dimmensions I find here. As a result, here is the board in Protel format, to open with Protel 2.71 / Protel 99 / Altium Designer. The design of the board was easy, I use Top layer to actuators and indicator components and Bottom layer for the rest of the components. I use 1206 parts because space is not a problem and are easy to solder by hand.
Again, I use the Seeed Studio PCB Fusion service to order the boards, in blue color this time!. They’ve the 100% E-Test at free of charge, a plus to continue working with they.
Fitting with Arduino UNO board
After receive the board and mouting the components, the next step is to mount with the Arduino UNO board and see how the board fits. Here’re some photos of the result:
Testing and future improvements
In the design of the board, I make two errors. One is trivial, the silkscreen of the led’s is wrong, the cathode mark is on the anode, so the led’s must be mounted as contrary as the board indicates. The other error is important, but with a easy solution. I change the pins on the power connector in the Arduino board (J1 connector on the scheme). This means that IOREF and RESET pins are connected to Ground and 3V3 voltage of the Arduino board is carried to the 5V of the keyboard power. Fortunately, it’s easy to solve. In the J1 connector, you don’t mount pins 2, 3 and 4 and make a bridge between pins 5 and 4 to carry the 5V power supply. It’s a silly fail and I just correct in the PCB for future versions.
After make this changes, the last step is make a simple program to test all the functionality of the board. Here you can download the code for the test of the board: K4S_DEMO.
The program looks like this:
One important thing is that in the final board, I change the position of blue and red leds (as you can see in the Scratch photo). So, with this change in mind, how this code works? Here’s what I try to do with it:
- When you press the ‘A’ button, the blue and yellow leds turns on
- When you press the ‘B’ button, the blue and yellow leds turn off
- When you press the ‘C’ button, the buzzer sounds for around 300mS and then stops.
- The red led brights in function of the position of the knob. When the knob is on the ‘MIN’ position, the red led is off. And when is in the ‘MAX’ position, the red led lights at the maximum.
Finally, a short video where you can see the board in action!
If you’re interested in this project, you can contact with me using the form or with Juan Brito using the mail: email@example.com
This post is also available in: Spanish