Introduction: Scratch 4 Arduino and Cybot Control (Rover Basics)

Picture of Scratch 4 Arduino and Cybot Control (Rover Basics)

I've had a couple of Cybots as well as the Tom robots for a number of years - every so often they get dragged out and tinkered with. Now is this years turn. I have decided to try my hand at Arduino control of the Bots motors.

There seems to be a large number of You tube Videos that say "yes we did it", but not many on how to get there, so I'm going to start from what I think should be the beginning. Assumptions these can be the mother of all mess ups, but I'm going to make one now that is that if you want to copy this guide you already have an Arduino and the IDE pack from the Arduino site and that you have had a play and know how to install a sketch onto the Arduino board. My eventual aim is to move onto something like the Android application development and control the Bot by bluetooth and possibly WiFi - again lots of Videos but not much else, but for now that will wait as the parts have not yet arrived.

this instructable will tell you how to get to this:

And as soon as my parts come I will create an additional one for Bluetooth and hopefully WiFi Control

I have also created an instructable covering the bar code interface at

https://www.instructables.com/id/Direction-display-...

Please read on

Step 1: Arduino Preparation

Picture of Arduino Preparation

Once you have your Arduino set up to communicate with your computer you should have the Arduino icon on your desk top which once opened will display a screen similar to the second image.

For the board to work with Scratch for Arduino (S4A) you need to install the Scratch firmware sketch using the Arduino SDE (see the firmware file) this is the same file available from S4A and is totally free. Once installed that's it for the Arduino software you now have to obtain the S4A application (again free to download from the following location. Scratch for Arduino (S4A) available from http://s4a.cat/ Go to the web page link above and scroll down to the "download and install" section and grab yourself the version that's right for your operating system (I'm using windows). Once installed you have an additional icon which when opened will look something like the last image on this step. note that the application will start looking for your Arduino and the message will only disappear when it has found it so please connect up. Once connected the Arduino Port monitor will start cycling a series of numbers - this is just the information being monitored from the board by the application

Step 2: Connecting Cybot and Arduino

Picture of Connecting Cybot and Arduino

Personally I read from left to right, but the people that manufactured the Cybot motor board went the other way (this was my first mistake when working out the motor directions) once I realised I was fine and all numbering on this instructable for the Cybot board goes right to left now.

So there are 7 connections (the black block to the top of the first picture)

PinDescription of function
1Right Motor - Forward
2Right Motor - Reverse
3Left Motor - Forward
4Left Motor - Reverse
5+ 5 volt Output
6+ 6 volt Output
7Zero Volts

I have at present only connected up to the motor pins and the 6 volt pin so that's pins 1,2,3,4 and 6 of the cybot board.

S4A has a number of predefined digital lines for the Arduino board, which are header connections 10,11,12 and 13 - connect one to each of the Cybot pins the last pin connected is the ARef pin of the Arduino to +6 volt pin of the motor board.

so the pin connections that I used are as follows

Cybot PinArduino Pin
1 - RM ForwardTo~10
2 - RM ReverseTo~11
3 - LM ForwardTo~12
4 - LM ReverseTo~13
6 - + 6 volt OutputToARef

As at present there is no bluetooth available I have a 5 m USB cable connected to the Arduino to all the bot to move around.

Step 3: Scratch Programming Basic Movement

Picture of Scratch Programming Basic Movement

I have created a specific Instructable that covers the design and function of the navigation interface used in the SCRATCH application. You can find it at:

https://www.instructables.com/id/Direction-display-for-Arduino-Robot/

The first thing to get sorted as far as the programming is concerned is to get the motors moving forward and backwards - as each motor is controlled indigently there needs to be a command for both of them for each movement. for example for forward the Arduino needs to have digitial pins 10 and 12 set to on.

Note its important to have all other pins set to off. The best way to do this is to set all pins to off and then turn the pins on required for a specific direction. If you look at the image for the S4A code you will see that I have included a block for each direction using the arrow keys on the keyboard and an extra block using the space bar to stop all activity.

I have included a link to the Scratch Code as well (for this program there are no additional variables required)

Turning left or right

There are two possibilities for turning in either direction. The first is to have one motor on and one off so with the left on and the right motor off the cybot will turn right and vice verse - however if you have laminate floors this will mark them, it will also be a slow turn.

A faster way is to alternate the motors meaning that both contribute to the turn.

Key board control:

Note when you download the Scratch files you may get an error this will be because you computer is trying to open it - you need to save the file (say to your desk top) then open Scratch 4 Adruino and then open the downloaded file

Step 4: Scratch Programming Direction Using Bar Codes

Picture of Scratch Programming Direction Using Bar Codes

This section is an example of using Scratch and an alternative input method to control the motion.

Fist of all I generated a few graphics to hep with the programming:

  1. Barcodes -for these I used www.barcodesinc.com/geerator/index.php you don't need to I have attached a PDF with them on.
  2. Direction skins for use in Scratch - for this I generated a "direction Key Pad" using Sketchup then took a screen shot of it. Once I had one image I copied it and for each of the buttons changed one to green. These images where then imported into Scratch as Costumes - if you download the Scratch file attached to this section and open it in Scratch you can see them in the costumes tab. see below - if you want the model - then right click and select open in new tab as the option then download from the 3D warehouse at https://3dwarehouse.sketchup.com/model.html?id=u2d...

Video of bar-code control :

Thanks for looking

If you want anything adding or have suggestions please do so in the comments and I will try to help and add to the details.


If you like this please take a look at my other instructable's or at my web page: http://handycrafted.jimdo.com/

Comments

nlewkowitz (author)2015-03-04

This is very helpful. Thanks!

D6equj5 (author)nlewkowitz2015-12-10

Very helpful and interesting - my crate of old Cybots and Toms are about to see daylight again !

RobertH16 (author)2014-12-16

Hi, I am a middle school shop teacher, working on a low cost robot project. I see you are using a long USB cable, is there any way upload a scratch program into the arduino board so it could run a maze? I want to use Scratch or another GUI. I know they use different file types. Any ideas? Thanks Bob H

HUKBMBEAR (author)RobertH162014-12-17

Hi thanks for the question.... A couple of ideas first use timed Motor duration, but the code woul be very messy and only give a single route. Better add sensor , sonar, or maybe micro switch front and rear make the bot turn a fraction as the sensor is activated. Possibility .. Take a look at my guide for spectrometer it might be possible to store the responses in excell then use that as a memory for the bot.

Sorry its not a specific answer to the problem but its the kind that really does need a bit of thought. Scratch 4 arduino should be able to handle it

xsalvador (author)2014-11-30

hello,

Very very interesting.

I did my own arduibot with sonars and light sensors, usin motor driver original board. By now, i wanted to use my arduino motirshield. All was ok till i unplugged usb poser cable using the 12V battery case: one motor connected, ok ; two, nothing.

Did you understand if there is something special with cybot dc brush motor and power supplying ?

Ty ;- cybotly yours

HUKBMBEAR (author)xsalvador2014-12-01

Hi glad you liked the guide.

No I don't think there is anything special about the cybot motors. I did work out that but connecting direct to the ref pin their was a short which made the board get warm. Corrected this by using the zero volt pin on the cybot board see my new guide for simple Bluetooth control of the cybot it might help step 4

https://www.instructables.com/id/Bluetooth-Cybot-on...

technician (author)2014-06-01

wow saw this and was drawn to it because the bot looks like on I assembled many years ago with my then toddler son and came fortnightly in a magazine, my son is now 22yrs old and just about to finish unit and is not interested in science and technology, where did I go wrong? Ps the bot is in the back of the cupboard with the techno Lego lol

HUKBMBEAR (author)technician2014-06-01

Thanks yes this is based on the chassis of cybot from that magazine. At present my kids are still young so I can use that as an excuse to play with the lego

HUKBMBEAR (author)2014-03-21

Thanks again for the support, its always great to hear that others think what you are doing is worthy of comment. would be nice to see what you think of my others (if youve not already visited) just off to yours now

About This Instructable

13,858views

97favorites

License:

Bio: Hi I like to have a go at anything that's interesting, from CNC to toy making, recently I have been dismantling an old Cybot ... More »
More by HUKBMBEAR:Rescue Automation and Security Alarm System the  Crumble Bot 3d Print Your Own RoverEasy Planting
Add instructable to: