K4S, a Keyboard for Arduino to use with Scratch

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 Hardware

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.

  • One buzzer

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.

PCB Design

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: brito.grandes@gmail.com

  • Twitter
  • del.icio.us
  • Digg
  • Facebook
  • Technorati
  • Reddit
  • Yahoo Buzz
  • StumbleUpon

This post is also available in: Spanish

20 thoughts on “K4S, a Keyboard for Arduino to use with Scratch

  1. Shefali

    Hi, I liked your idea and would like to implement it myself. Could you please tell me the ,list of parts you used to build the keyboard.

    regards
    Shefali

    Reply
    1. jechavarria

      Hi! Thanks for your interest in the board! If you see the schematic, you can find the components I use. For your reference: resistors and capacitors are 1206. Transistor is FDV301N. Led’s are 10mm diameter (I buy in eBay). Buzzer is 5V and 12mm diameter (also buy in eBay). Potentiometer: http://es.mouser.com/Search/ProductDetail.aspx?R=PTV09A-4015F-B103virtualkey65210000virtualkey652-PTV09A-4015FB103 and Knob: http://es.mouser.com/Search/ProductDetail.aspx?R=450-BA761virtualkey56100000virtualkey450-BA761 . And finally, the pushbuttons: http://es.mouser.com/Search/ProductDetail.aspx?R=D6R00_F1_LFSvirtualkey61170000virtualkey611-D6R00F1LFS . Hope this info will helpful for you. And if have any other question, please tell me!

      Reply
  2. Shefali

    Hi I just want to add I am a newbie at arduino. I liked your keyboard and am not so good with electronics and reading electronic schematic diagrams.
    I have successfully completed many arduino projects but have followed the fritzing layouts.
    I teach school children scratch and scratch with arduino. I think it is superb, the learning possibilities are endless.

    The children will really enjoy playing with the keyboard

    Thanks
    Shefali

    Reply
    1. jechavarria

      Hi! That’s the idea of this board, bring close the technology to children on a easy way in places where access to the technology are difficult. At this time, I’ve a few boards in stock, maybe if you are interested I can sell you one of it, mounted and ready to use. If you want more info, please send me a email and we can talk about it. Thanks again for your interest in the board!!

      Reply
  3. Pingback: K4S, a Keyboard for Arduino to use with Scratch -Use Arduino for Projects

  4. Antonio Contreras

    Hi,
    I’ll use my UNO this summer to teach my children. I find your ideas are very awesome. So, I’ve decided to build my own version, maybe with some mods: I could connect more leds if I use multiplexing and/or charlieplexing, and I could connect more push buttons the same way (using one or two analogs inputs along with them).
    Whatever I finally do, It seems surprising to me that you are ordering your boards to SeedStudio. I wonder how much can be the price, as no info is given directly on the pages. Other similar services that I have found before have a cost quite higher than I expected. I’ve always build my boards at home. I usually need no more than one. Even with my secondary pupils, we have etched our own boards in the workshop -I find it interesting and fun-. Should I change my mind on that matter?

    Reply
    1. jechavarria Post author

      Hi Antonio!
      Thanks for your comment and sorry for the late in the answer, these days are holidays in Spain and I was out. About your question: for me, in theses days, prices of manufacturing PCB’s are very low, and I always prefer to send out. Etched boards are good for teach the process, and you need the materials, tools and a good place to make the process. It’s a good method to make ‘fast’ prototypes, but in small quantities, at the end you’re making every board manually. I used Seeedstudio (and other manufacturers) to do this work, because quality is very high for the prototypes and the price isn’t high. In this web: http://www.seeedstudio.com/service/index.php?r=site/pcbService from Seeedstudio, you can configure your board and have a quote. For example, an arduino shield will cost 20,90$ + shipping costs for 5 boards with green solder. If you order 10 boards, then the price will be 24,90$ + shipping for the 10 boards (2.49$ each board!). As I tell you, I think this price is not very high. In my next project, I’ll use another web to test it, and the prices are cheaper: http://dirtypcbs.com/ . In this place, 10 boards with a maximum dimmensions of 10 x 10 cm will be cost 25$, any colour and including shipping costs. In my case, for these prices, I prefer order the boards rather than manufacturing myself.

      If you want more info or continuing with this conversation in Spanish, please send me a mail to the address: jesech1978@hotmail.com. Also, at this time, I’ve two boards mounted, tested and ready to send it. If you’re interesting, please also tell me!.

      Thanks for your comment and I hope help you in your question!!

      Reply
  5. Antonio Contreras

    Holidays? What hollidays? I must be living in another Spain.
    Well, I’ve choosen English after a look to the “less” populated spanish section. If we need to move other people to conversation, I think it will be more usefull here.
    Yes, I see, indeed, the cost of those services is really afordable, and maybe I’ll use them when I’m in need of five or ten.
    Thanks for your answer.

    Reply
  6. Pingback: RPi Board, a board to learn Python with the Raspberry Pi - Designing Electronics in Spain

  7. Pingback: Tarjeta RPi, una placa para aprender Python con Raspberry Pi

  8. Pingback: Leonardo 101 | Tarjeta RPi, una placa para aprender Python con la Raspberry Pi

  9. Pingback: RPi Board, a board to learn Python with the Raspberry Pi -Use Arduino for Projects

  10. Pingback: 21 proyectos makers con Arduino y Raspberri Pi que puedes plantearte estas vacaciones de Navidad | Nuevo Titulo |

  11. Pingback: 21 proyectos makers con Arduino y Raspberri Pi que puedes plantearte estas vacaciones de Navidad | TecnologiaDigital

  12. Pingback: 21 proyectos makers con Arduino y Raspberri Pi que puedes plantearte estas vacaciones de Navidad - ChatNews

  13. Pingback: 21 proyectos makers con Arduino y Raspberri Pi que puedes plantearte estas vacaciones de Navidad | Agro Radio

  14. Pingback: 21 proyectos makers con Arduino y Raspberri Pi que puedes plantearte estas vacaciones de Navidad | Radio News Balcarce

  15. Pingback: 21 proyectos makers con Arduino y Raspberri Pi que puedes plantearte estas vacaciones de Navidad | Noticias Las Varillas

  16. Pingback: 21 proyectos makers con Arduino y Raspberri Pi que puedes plantearte estas vacaciones de Navidad | RadioGUS.com

  17. Pingback: Actualidad: 21 proyectos makers con Arduino y Raspberri Pi que puedes plantearte estas vacaciones de Navidad | Revista Nueva Era

Leave a Reply

Your email address will not be published. Required fields are marked *