Asked — Edited
Resolved Resolved by Rich!

L298n Motor Sheild Scripting

Rich and Friends,

Got a new l298n H bridge and it works great but I have a few questions.

  1. I need to know how to call a script using a button push

  2. I know there are some examples of the scripts out there but can some one point me in the right direction :0

I was also wondering if any one has seen the e-zb respond in weird fashoins like this example.

I got my serial Sabretooth Movement Panel and 4 digital on/off

I can turn the digitals on and off and use the Movement Panel but when I go back to setting the digitals on and off the wheels (Controled by the sabretooth) start moving the bot in circles.

Also when I power my bot on one of the arms will go up on its own.

Before I am even conected to the blue tooth.

I am going to try and redo the firmware but if anyone has any other ideals I would appreciate it.

Thanks again,



Upgrade to ARC Pro

Join the ARC Pro community and gain access to a wealth of resources and support, ensuring your robot's success.

United Kingdom

How much does the arm move on it's own? There will always be a jolt when you first power on, this was described and discussed in detail recently.

To call a script using a push button switch you just need to monitor the digital port the switch is connected to. Use an if to check the status but before that a waitforchange to only proceed with the script if the status of the switch changes (to save processing power etc.)

IF(GetDigital(d0) = 1)

Something like that anyway - doing this from memory.

Also check my cloud files, I have done a few projects with H-Bridge scripts in. Also check my H-Bridge tutorial, it should tell you what you need to know about how a H-Bridge works.



Thanks as alway s for the quick and great info.

Here is where I stand right now.

Got the bot back up and running with the Sabretooth connected via serial.

Got my Numbers straightened out and it is running jsut fine. I dumbed down my voltage to 12 instead of 24 and its running at a way better speed.

So now I ordered the L298N bridge that you suggested and you were right it worked on the very first try.

I am just using the init pins and no PWM. I have the jumpers in place and the arms go up and down.

There are built in limit switches in my actuators so when it reaches the upper and lower limits they shut off but you can see on the controler that the signal is still on.

How ever here is whats been going on with the arms.

If I leave the L298 connected with a 4 wire connector and its connected to the EZB with consectutive D pins (EX, D14-D18) when I turn the bot on one arm will go all the way up and you can see that the Digital on is on. It stays on untill I connect the Laptop and tunr it on and off again. (This seems to reset the port).

Then if I move the bot around and then try to raise and lower an arm the bot will then start to run in circles and is un responsive. I have to use the kill switch.

So here is my next step.

  1. I am going to try and use non consecutive Digital Pins (I.E. 2,4,6,8 or something like that)

  2. Once thats Done I will try and do several on / offs and make sure I dont get any more wierd spontatious movements.

  3. I would like to use my joystick which has 4 buttons to control the arms.

  4. I have a A and a B button and I would like to have them so that they each control an arm. Having them set to execute arms down on button up and arms up on button press. (So the arms will always come back down if I let go of the button) I need some help on this so any advice will always be appreciated. I am assuming I can write a script but I need some examples and I will look in EZ bits tonight.

  5. I have a USB to TTL Adapter Board that I am going to use to connect to the EZB this way I have no chance for Outside interfearance.

Well Rich your advice was spot on. After several blown boards I now know which controler to get and it does work straight away. Thanks again for this and any more advice you can give.

Also if you have any advice on the Arms that would be great but it does seem to be related to the digital on ports because if I move my 4 wire connector down then the arm moves in a different direction. So hopefully changing the ports works.

I will keep you posted.

Also I dont want to leave anyone else out so any advice from anyone is apreciated.

The EZ B community is great and I am glad I picked this controler and the platform for my bot.

Later and good day to everyone.



United Kingdom

I scanned over that quickly so I apologise if I missed something (I'll re-read later).

All Digital signal pins should be low when you turn on the EZ-B and will go low when disconnected, at least all I checked when I added the fault light on Jarvis (LED across VCC and Signal, therefore illuminates when disconnected). I didn't check all ports though so it may be normal that one (or more) are high.

I have a similar problem with Melvin's H-Bridge where he will sometimes spin on the spot when powered up but not connected, I guess this may be something to do with the digital pins, I'll have to check all 20 to see if they are low on powering on.

Joystick button scripts should be simple. You just need to use the Set(D0,On) (or whichever port/status) for each arm for up or down. For instance, if Motor 1 is controlled by D0 and D1, D0 being high for up and D1 being high for down.

On Button Down Script

Set(D0, On)
Set(D1, Off)

On Button Up Script

Set(D0, Off)
Set(D1, On)

So when you press the button the motor moves the arm up. On release it moves down. This relies on cut outs in the motors as they will forever be moving otherwise.


Ok rich thanks but how do I use the button to call the script ?

Also I still have some random movement issues.

I am trying very different ports some are even showing as kind of inactive.

What about cross talk ? Could the close proximaty of wires be causing some issues with cross talk ?

Could close volatages cause issues with the serial from the Sabretooth ?

I am just throwing some stuff out there. I am going to find out which ports are working by testing tonight.



United Kingdom

Really, nobody jumped in here to answer it? I had hoped someone would but never mind.

You can add the script directly to the button.

Open up the config and move to buttons. Click in the relevant box and look for the symbol of the pencil User-inserted image

Click it and it opens the EZ-Script dialogue. Paste in or type in the commands you want to use for that button.

However, if you wanted to run a script on a button push you could also just use the ControlCommand() command to start the script. Easy way for that to ensure correct syntax, click the pencil to open EZ-Script dialogue, choose the Cheat Sheet tab and click the relevant control, it'll automatically paste it in the script dialogue for you.

User-inserted image



Thanks as always.

The issue is I am not using a joystick object. I am using a Zeemote an =d I just have mapped the buttons too the arrow keys.

However the new issue which is more important is that I have got the Digital ports to stabalize.

it looked as if some of my digital ports were starting up on.

I just found 4 ports that are starting up off and that worked.

How ever what happens is that I can move my bot and as soon as I us any digital on port to move the arms the bot goes in circles.

Looks as if its just one motor that turns full on at the sabretooth.

Any suggestions ?

United Kingdom

Map the buttons to key presses and use the keyboard control. The arrow keys are assigned to the Movement Panel so cannot be used in the keyboard control. Although you could just use a custom control panel and have the scripts run for forwards, reverse, left and right that way.



Any Ideals on the whole going in circles after you activate a Digital on/off port ?


Thanks Rich we are all working


Hola buenos días, por este medio me gustaría obtener mas información acerca de la tarjeta Arduino, quisiera saber todo con respecto a ello, todas su características, en si todo... de ante mano Gracias Feliz dia



You wouldn't mind using "Google translate" to translate your post next time?:) We do have a very diverse user group that speak a number of different languages but english is the common language that we try to use as a community to communicate with eachother. Thanks!

Where you inquiring about an arduino interface board that connects onto the EZ-B or just a general Arduino board like the UNO?