Jump to content
Search In
  • More options...
Find results that contain...
Find results in...
  • 0

Lwclone On Arduino Mega 2560


Here comes the LWClone on Arduino MEGA 2560


How to Compile

Windows Prerequisites

On Windows, you will need a copy of the latest Atmel Toolchain, either downloaded 
and installed as a standalone package, or installed as part of Atmel Studio. 
You will need to ensure that the "bin" directory of the toolchain is available 
in your system's PATH environment variable.

In addition, you will need to install a ported version of the ZSH or BASH *nix shells, 
and a standard set of *nix utilities such as cut, find and sed. 
These can be found in the "basic" system package of the of the MinGW installer (http://www.mingw.org). 
Once installed, add the "msys\1.0\bin" of the MinGW installation folder is added 
to your system's PATH environment variable.

The bootloaders currently also require the "bc" application, 
which can be installed from http://gnuwin32.sourceforge.net/downlinks/bc.php. 
Once installed add the "GnuWin32\bin" path of the GnuWin32 installation folder 
to your system's PATH environment variable.

Linux Prerequisites

On Linux systems you will need to install the latest Linux distribution 
of the standalone Atmel Toolchain from the Atmel website for general development, 
or use the latest avr-libc and avr-gcc packages for your chosen distribution's package 
manager. For full device support, the Atmel standalone package is recommended.

How 2 Flash

Connect your Arduino to USB and look witch comport it has
Start Flash Main Chip Arduino Mega to LW.bat
enter your Comport e.g com2 or com32 what ever
Remove USB
Connect your USBASP to the ISP header behind the USB port
Start Flash 8u2 - 16u2 Arduino Mega - with USBASP Dongle to LW.bat
Connect The USB port wait for reorgination the Device 
Start Change ArduLW ID.bat
Enter your LEDWIZ ID e.g. 1 or 2 up to 16
That is it test it with Visualpinball an Pinmame/DOF

 have make New packages 23.01.2016




one package with inverted LED ports so that High ist normal and low is on ( for the Relaisboards from ebay)



For Boards that say it gives problems with The STK500 Timeout Error Here ist a Short way to fix it !?!?



1. Connect the USBASP to the ISP connector behind the USB Port.

2.Start the  "0. Flash 8u2 - 16u2 Arduino Mega - with USBASP Dongle to Arduino.bat"


3. Connect the USBASP to the Second ISP port

4. Start the "Flash m2560 Unlock fuses, erase, verify - with USBASP Dongle.bat"

5. Start the "Flash m2560 Write the bootloader, set the lock fuse, verify  - with USBASP Dongle.bat"



Now you can flash it normaly


when the flash with the USB ASP didnt work test to bridge the GND point on the 10->6 Pole Converter





So have make a little Video tutorial don`t say anything about my english have do my best.






  • Upvote 3

Share this post

Link to post
Share on other sites

Recommended Posts

  • 0

@Aetios ,

Thank you for helping.

I got ledwiz dof configured. It's working now. And I'm going to try Doflinx with tables that I've download from TerryRed.

I'll post results soon.

Share this post

Link to post
Share on other sites
  • 0


I follow no problem your video-tutorial, and others tutorials too.

I have an arduino mega 2560 rev3  and the flash operations seems to be perfect on windows 10 (test mode and no drivers signation mode). 

Just the same like i have seen on your video-tutorial, but at the end...,  i have see  only 3 devices called "ultimate pincab controller" on usb devices, but no com-port , no joystick ,  no ledwiz ID and no controller detected on ledblinky simpletest

(i didn´t tried regedit clean yet for the windows-joysticks problem,like you said on the third page of this thread) (i can´t see the regedit cleaning photos)

If i run .bat file called "changeID"  I got no ledwiz detected.

I´ve missed something?  


EDIT:After trying one week.. i got ledwiz and ultimatepincontrol runnin on my computer windows 7/10.

what i did? easy..  making all the procedure on windows7. (windows 10 was not good for me).

Maybe you´ll find, after one flash attempt, you cannot more open usb-communication on the "flip atmel"program, but you don´t have to worry, you don´t need this program,i will explain my experience installing ledwiz....what i did..

1 enter windows 7 on test mode

2 and  disable driver signature on windows 7, same as step one, but this time you must type this on the cmd screen (you must execute cmd as administrator) : 


 bcdedit -set TESTSIGNING ON 

  when we will  finish the ultimatepincontrol and ledwiz installation.. , you will must remember to re-enable  the driver signature for windows.


bcdedit -set TESTSIGNING OFF

Now we can make the whole flash process.

1Install zadig and the connect via usb your usb-asp on your computer (on zadig first you must list all devices, then select usb-asp and install libusb-win32).

NOTE: I f you have avrdude errors while flashing, you must know you mustn´t launch .bat files as administrator, simply double-click. if you get error like avrdude it´s not an recognised command try install winavr



For a good start on flashing, we willstart from the beginning (assuming that you don´t have a comport assigned to arduino at this moment)(.All the proccess it´s made with the pinpack downloaded from this tutorial.)

1connect your usb asp to the usb chip of your arduino (the 16u2 usb-chip)and flash it, running this file


0. Flash 8u2 - 16u2 Arduino Mega - with USBASP Dongle to Arduino.bat


At the end of flashing ,press a button for close the  window and then you must disconnect from the usb-chip and connect to the 2560 iscp-chip of your arduino, and run this two files in this order


Flash m2560 Unlock fuses, erase, verify - with USBASP Dongle.bat

Flash m2560 Write the bootloader, set the lock fuse, verify  - with USBASP Dongle.bat

five minutes later, when finished, we can start the real flashing process.

1 Disconnect your usb-asp and connect your arduino via usb. and install arduino ide.

2Now double click on this file(you must enter your comport, com3, for example)


 Flash Main chip arduino mega  to LW.bat

3 at the end of the step, disconnect from the usb and connect your usb-asp to the 16u2 usb-chip of your arduino and double click on this file


2. Flash 8u2 - 16u2 Arduino Mega - with USBASP Dongle to LW.bat

At the end, all you must do its connect your arduino to the usb and windows will install ultimate pincab controller.

Now You can see a usb game device called the same (ultimate pincab controller)and if you run changearduLW.bat and type enter, you can change your ledwiz into id number one,for example.


My problem was windows 10 , i was not able to make a good flash and installation on windows 10, but now..after the installation and flashing goes well on windows 7.. now i´ve only connect to windows 10 and it´s perfectly installed.

Now i must teach more things in here.

Cyclemat and Aetios.Thank you very much for your tutorial. 

Share this post

Link to post
Share on other sites
  • 0

I am trying to compile the lwclone master.

¿why? not lagging... simply i don´t have usb gamepad controller working, you can see the buttons and axis there on gamepad properties (ultimatepincabcontroller), but no response, no works, i don´t know how make it works at all.

This tutorial it´s simply very hard to me, i can´t do it. (it´s my second week trying to make it working),  anyway.. i have tried it over..so if anyone could help me will be so much aprecciated, i will help others too, i hope so


First i installed the avrtoolchain, then gnuwin and last mingw. TOOLS:                mingw          avrtoolchain   

Note: you will need  the lufa,  and you must extract on this folder (c:/lwclone-master/firmware/lufa) let me show you my lufa folder,on the lwclone source .

lufa folder.png

Configuring the path environment i got problems , i don´t have windows apps folder, so i typed the path this way:

wrong path.png

When i typed "make clean" i´ve  found it´s out of bounds making the 2560.sys and error,error etc, here you see the error

make clean.png

if i type "make all" there´s the same problem, so there´s no files. any help?




Share this post

Link to post
Share on other sites
  • 0

I´ve downloaded  the correct version of gnuwin  and i´ve installed.

So..this time i put the right variables on the path environment (........./GnuWin32/bin and ..../.MinGW/msys/1.0/bin)

and this time i got this



Share this post

Link to post
Share on other sites
  • 0

Hello flicki,


I'm so happy to see another member who keep interest with this project !!!

first of all, I'm glad you make your flashing process work, that's the first way to the next level ;) 

I began to make my own change with the mapping process and I tried to compile the code different way to make joypad buttons  work... but that don't.  For your information, i couldn't compile in windows, so I installed linux on another HDD and I compile under Ubuntu, much easier.

For me the code isn't finished and we need a super-coder to make it works correctly (@kakou).

I've got another problem with many arduinos clone... lag/freeze with buttons (flips don't move or keep in high level, you have to push another time). 


Please continue to share your experience. ;) thx





  • Like 1

Share this post

Link to post
Share on other sites
  • 0


On 20.1.2016 at 3:31 AM, Baronimg said:



avrdude: stk500v2_command(): command failed








I have the same error.....

Share this post

Link to post
Share on other sites
  • 0


Which Arduino Mega did you buy ? 

Do you use an USBASP as described in cyclemat tutorial ? 

which type of USBASP ?

Are you sure your MEGA have a 16U2 chip ?  (and not a china clone with CH340)


There is so many reason to have this message, you have to give us more precision ;)



Share this post

Link to post
Share on other sites
  • 0
On 2017-10-25 at 10:12 AM, Aetios said:

@UncleSash  Good Job !


Here is the last Firwmare, I've remapped some buttons, changed the hotkey attribution and switched buttons.

I've made a double pack for two type of Arduinos MEGA2560 :

- those which have a DFU mode 

- and without DFU, so the same way that cyclemat explain here (with USBASP etc...)


Last Firmware Pack : https://mega.nz/#!t8c3wChI!HYkTybykeWW-CSzzqDcPaVBNcBk8ujmkHTz8YxxihqQ

For the DFU mode method, you need also FLIP 3.4.7 to flash the 16U2 chipset  https://mega.nz/#!o0NCSARJ!HEXEutTiIVyjaiv-57tuFtO3e1_MweD84-XJ6YPpmyg


I will write another How To if necessary, I wrote one but it's in french in Pincab Passion.


For those who wants to try, I recommand to buy a Funduino MEGA2560, it has the DFU mode (no need for an USBASP) and works perfectly  with this new firmware



Hi. I have tried to get my genuine Arduino mega 2560 R3 to work for a many days now.

I have tried on Windows 10 and Windows 7.

My Arduino have DFU mode so this is what I have done.

* 1. Run this file -----> Flash Main Chip Arduino Mega to LW.bat

* 2. Then I put Arduino in DFU mode and flash with the file ----->  arduino_mega2560__m16u2.hex with Flip software.

* 3. Unplugged the Arduino and plug back in to computers usb port, the computer installs the Ultimatepincab board.

I can change the ledwiz id of the board, I can open ledblinky without error, ledblinky recognize the ledwiz id.

But I can not get any led to light or blink, it is completly black

Joystick or keyboard buttons do not work at all.

Have I done something wrong? Please help med someone.

Share this post

Link to post
Share on other sites
  • 0

Friends , when hold flipper button solenoid keep activated .. have risk to burn it?

Share this post

Link to post
Share on other sites
  • 0

@sneaksneak If you don't connect an accelerometer (MMA8451) on SDA and SCL ports (20 et 21), the Arduino is still waiting for the connection with the chip and it can't react with buttons ou ledwiz commands. 

@vinw : Yes ! solenoid are more risky than contactors but you have to hold a long time (I didn't try more longer than 1 minute ), I prefer using contactors for flippers, safer ! 


Share this post

Link to post
Share on other sites
  • 0

Hi to all i have tried everything with no result at all.

My arduino mega china clone have (really stange) DFU so first time i am able to flash it with FLIP and all seems ok and it is recongnized from SimpleLEDTest.exe (id 4????) but signal from port are wrong and it is impossible to use. 

I have tried to reflash with flip with the result that it is no more recognized by SimpleLEDTest (No led controller detected)

I have USBASP and 10 to 6 pin adapter so i started back from zero and i have no error at all and i ended all part with perfect result i have reattached mega with usb and i have 3 device (ultimate ....) with libusb driver but  SimpleLEDTest  or Change ArduLW ID give me no device (No led controller detected)

I have used zadig to change usb driver to winusb and i have 3 device called UltimaPincontroll  but  SimpleLEDTest  or Change ArduLW ID give me no device (No led controller detected)

I am using win 10 and for me it is difficoulkt to find a win7 pc to try over it is possibile to use a virtual machine?

I have tried more then 10 times. 

Please help me to figure out the problem


Ledwiz device.png

Ledwiz error.png

Ledwiz device_1.png

Ledwiz error_1.png

Share this post

Link to post
Share on other sites
  • 0

@ above: Did you use the right ledwiz.dll file?


For the PCB board (with wemos?) is there a schematic (and partlist) available? I like to build one with kicad, will share result.


ps. latest builds has no pinmap.h anymore?


Share this post

Link to post
Share on other sites
  • 0

Finally i manage to complete the procedere with succes i do not know what is the problem but now i have a recognized ledwiz clone.

I have fixed dll access violation error with new dll and I have an original working  ledwiz so i know how it should work but now i have 5v when led is off and it only shot down led when i put britness to 0.

Essentially on off button in test led NewLedTester.exe do not work for me. I took 5V from arduino mega pin 22 and connect small RGB LED to pin 24,26,28


Share this post

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Create New...