Main Restorations Software Audio/Jukebox/MP3 Everything Else Buy/Sell/Trade
Project Announcements Monitor/Video GroovyMAME Merit/JVL Touchscreen Meet Up Retail Vendors
Driving & Racing Woodworking Software Support Forums Consoles Project Arcade Reviews
Automated Projects Artwork Frontend Support Forums Pinball Forum Discussion Old Boards
Raspberry Pi & Dev Board controls.dat Linux Miscellaneous Arcade Wiki Discussion Old Archives
Lightguns Arcade1Up Try the site in https mode Site News

Unread posts | New Replies | Recent posts | Rules | Chatroom | Wiki | File Repository | RSS | Submit news

  

Author Topic: Adding Race Leader lights - advice needed  (Read 12566 times)

0 Members and 1 Guest are viewing this topic.

buttersoft

  • Trade Count: (+1)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 1782
  • Last login:November 10, 2024, 06:13:40 pm
  • Is running at 15kHz
Re: Adding Race Leader lights - advice needed
« Reply #40 on: April 21, 2023, 07:10:07 am »
i have both P1 and P2 lights working for Daytona - or the leader light is, anyway. All i did was drop the lua and pat files over the top.

But no other model 2 games seem to work. Well, Sega Rally and STCC don't, anyway.

jorgenjl2

  • Trade Count: (0)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 132
  • Last login:November 16, 2024, 03:49:38 pm
  • I want to build my own arcade controls!
Re: Adding Race Leader lights - advice needed
« Reply #41 on: April 21, 2023, 03:51:48 pm »
i have both P1 and P2 lights working for Daytona - or the leader light is, anyway. All i did was drop the lua and pat files over the top.

But no other model 2 games seem to work. Well, Sega Rally and STCC don't, anyway.
Thanks for this. Since yours worked I realized I was missing a dinput8 dll file from the ffb files in my 2 player emu2 folder that I had in my one player version. All works great now! The person who is in first constantly blinks the race leader light on and off but that must be how the race leader light just works on the Daytona arcade. This is pretty cool. Once I get through the remaining games that support this I will throw together a walkthrough.

jorgenjl2

  • Trade Count: (0)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 132
  • Last login:November 16, 2024, 03:49:38 pm
  • I want to build my own arcade controls!
Re: Adding Race Leader lights - advice needed
« Reply #42 on: October 18, 2023, 07:42:19 pm »
Go to my website and follow along with the tutorials.

Hey Howard - I am in the process of posting a how to on creating a Race Leader light without any soldering from start to finish (info seems to be scarce and very little on how to make the device itself). I am looking into enabling custom race leader outputs for games that do not support it. I am thinking of starting with Crusn USA and World. I will then move on to Teknoparrot (therefore Output Blaster app) for Mario Kart/Outrun SPDX/Fast and Furious. For Mame, I plan to try to use the Mame cheat menu to try to find the memory address of the current race position (1st, 2nd, 5th place, etc) and then output when in first place for Mame games. My understanding is I need to create a lua script like below (changing memory address once I find the race position memory address) and place that lua in the Mame directory and startup Mame and Crusn with a command to point to the lua file (mame.exe crusnusa -autoboot_script path_to_script/crusnusa_leader.lua). Then in my mamehooker ini directory I change the crusnusa ini file to have a line like below where I pass the same com port (3,1,x in my case to turn on race leader light assuming Arduino is showing as com port 5 below) which works perfectly for all games I have tried that support outputs for my ws2812b led strip. Have you seen anyone do this or have any tips? 

—Crusnusa mamehooker ini file add:
race_leader= cmw 5 3., cmw 5 %s%, cmw 5 x


-- crusnusa_leader.lua
local baseAddress = 0x?????? -- Replace with the memory address identified

while true do
    local position = memory.readbyte(baseAddress) -- Adjust read method based on data type (byte, word, etc.)

    if position == 1 then
        outputs.setvalue("race_leader", 1) -- Turn on the leader light
    else
        outputs.setvalue("race_leader", 0) -- Turn off the leader light
    end

    emu.frameadvance() -- Continue to the next frame
end
« Last Edit: October 20, 2023, 06:51:32 am by jorgenjl2 »

jorgenjl2

  • Trade Count: (0)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 132
  • Last login:November 16, 2024, 03:49:38 pm
  • I want to build my own arcade controls!
Re: Adding Race Leader lights - advice needed
« Reply #43 on: October 30, 2023, 05:13:21 pm »
I have found the memory address for CrusnUSA and World and I have my Lua script printing leader on and leader off correctly. I just need to update to send a 0 or 1 to crusnusa.ini mamehooker file and it should work. I will post all of the code and details when I get it finalized. I should be able to get California Speed to work now that I know how to use the Mame debugger. I spent too much time trying to get Cheat Engine to work which was super simple to find the dynamic (changing) address but it never survives Mame.exe restarts and required Mame debug instead. I wish I knew CE would not ultimately work for Mame emulators. 

Anyone know how to find the memory address of Fast and furious super cars or Mario Kart or outrun 2 spdx for Teknoparrot? I tried one (FnF) with Cheat Engine real quick but I didn’t see what I was looking for off hand. Anyone know how to find the racer position memory spot?

jorgenjl2

  • Trade Count: (0)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 132
  • Last login:November 16, 2024, 03:49:38 pm
  • I want to build my own arcade controls!
Re: Adding Race Leader lights - advice needed
« Reply #44 on: October 31, 2023, 11:56:54 pm »
For California Speed, I have it isolated to address 804B0EEE via the cheatinit steps below. The issue is that when I run "dump memorydumpcali.txt,804B0EEE,100", it is all 0's. Yet if I go to new memory window and select the MIPS R5000 (little) maincpu option, that addres shows the data changing based on the racers position (although the last two digits of the 8 digits are the users position). So for some reason I have a wrong memory space or something but otherwise I can find it every time and also see it in the memory viewer but not the default memory viewer. Hopefully someone who knows mame can speak to this.




--California speed
1) Start the game in debug mode with windowed mode
mame.exe calispeed -debug -window

2) Type "g" into the debug window and hit enter and wait for the game to start after a minute or so
g


3) Start race in 10th place and go for a little bit

4) Scan range
cheatinit ub,0x80000000,0x1000000

5) Get into 9th place and then scan for -1
cheatnext decrease, 1

6) Get into 8th place and the scan for -1
cheatnext decrease, 1

7) Keep repeating changing spots and decrease or increase that spot

8) Send results to screen once lower number
cheatlist

--For example
Address=8031448C Start=0A Current=06
Address=803D8D50 Start=0A Current=06
Address=804B0EEE Start=0A Current=06   --This shows it.


EDIT: For some reason for California speed I had to run "map 804B0EEE" from the mame debug window to see that physical address maps to logical address 04B0EEE and then use dumpd instead of dump with the pci 00.0 memory region. Crusnusa and Crusn world did not need any of this.

dumpd test.txt,04B0EEE:pci:00.0,1 

« Last Edit: November 06, 2023, 09:57:06 pm by jorgenjl2 »

jorgenjl2

  • Trade Count: (0)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 132
  • Last login:November 16, 2024, 03:49:38 pm
  • I want to build my own arcade controls!
Re: Adding Race Leader lights - advice needed
« Reply #45 on: November 06, 2023, 09:51:11 pm »
Got it!!!  :cheers:  I still need to put together a walk through of the race leader light setup (completely solderless and uses a full color led strip unlike how I always see individual leds shown in code). But for now, here is the code to get custom race leader lights working for mame games that dont support it. This is Crusn USA, Crusn world, and California Speed so far. This assumes you have mamehooker already working and games that support race leader lights (Daytona USA, Rush the Rock, etc.) working but I will show those steps for the other walkthrough.

1) Create a text file with code below and rename to <game>raceleader.lua for example crusnwldraceleader.lua and place in mame folder

2) Add a line to your mamehooker ini files at the end of the ini file like below for the mamehooker games ini 
raceleader=cmw 4 3, cmw 4 %s%, cmw 4 x

NOTE: This assumes your com port is 4 and you want to send 3,1,x to turn on the light (other arduino code will do this and I will provide later). It also assumes you are updating a mamehooker fiile called C:\mamehooker5.1\ini\MAME\crusnwld.ini

3) Startup mame with the lua file from command prompt (or add to Launchbox/etc. flag)
cd C:\Users\JLJ\Downloads\Mame\
mame crusnwld -autoboot_script crusnwldraceleader.lua -window

--NOTE: Take away the -window flag once you test. That just makes it easy to see your mamehooker debug window to make sure you see the raceleader output turning to 1 when in first place.

That is it! Now get in first place and your race leader light will light up!!!


Code: [Select]
--crusnwldraceleader.lua
local mem = manager.machine.devices.maincpu.spaces["program"]

function check(offset, value)
    return mem:read_i8(offset) == value
end

local baseAddress = 0xEBBA
local output = manager.machine.output

-- Function to handle the Leader Light situation
function handleLeaderLightOn()
    output:set_value("raceleader",1)
end

function handleLeaderLightOff()
    output:set_value("raceleader",0)
end

-- Register a function that gets called every frame
emu.register_frame(function()
    if check(baseAddress, 1) then
        -- If the value at the memory address is 1
        handleLeaderLightOn()
    else
        -- If the value at the memory address is not 1
        handleLeaderLightOff()
    end
end)

Code: [Select]
--crusnusaraceleader.lua
local mem = manager.machine.devices.maincpu.spaces["program"]

function check(offset, value)
    return mem:read_i8(offset) == value
end

local baseAddress = 0xE637
local output = manager.machine.output

-- Function to handle the Leader Light situation
function handleLeaderLightOn()
    output:set_value("raceleader",1)
end

function handleLeaderLightOff()
    output:set_value("raceleader",0)
end

-- Register a function that gets called every frame
emu.register_frame(function()
    if check(baseAddress, 1) then
        -- If the value at the memory address is 1
        handleLeaderLightOn()
    else
        -- If the value at the memory address is not 1
        handleLeaderLightOff()
    end
end)

Code: [Select]
--californiaspeedraceleader.lua (change 9 in script below to 1 once you want to try to get in 1st place. 9th is for testing)
local mem = manager.machine.devices['pci:00.0'].spaces['memory_space']

function checkPosition()
    -- Assuming the racer's position is stored in the last byte at the given address
    local data = mem:read_u8(0x04B0EEE)
    -- Extract the last byte which indicates the position
    local position = data & 0xFF -- This masks out all but the last byte

    return position -- Return the extracted position
end

local output = manager.machine.output

function handleLeaderLightOn()
    output:set_value("raceleader", 1)
end

function handleLeaderLightOff()
    output:set_value("raceleader", 0)
end

emu.register_frame(function()
    -- Check if the racer's position is 1st
    if checkPosition() == 9 then
        handleLeaderLightOn()
    else
        handleLeaderLightOff()
    end
end)
« Last Edit: November 06, 2023, 10:02:54 pm by jorgenjl2 »

buttersoft

  • Trade Count: (+1)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 1782
  • Last login:November 10, 2024, 06:13:40 pm
  • Is running at 15kHz
Re: Adding Race Leader lights - advice needed
« Reply #46 on: November 07, 2023, 05:51:21 am »
ok, i keep forgetting to post up but i've certainly been watching :)

This is great stuff. I haven't gone through the system in detail, but... will you take requests? I'd like to add leader lights to F1 Super Lap, certainly :)

jorgenjl2

  • Trade Count: (0)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 132
  • Last login:November 16, 2024, 03:49:38 pm
  • I want to build my own arcade controls!
Re: Adding Race Leader lights - advice needed
« Reply #47 on: November 07, 2023, 07:13:40 am »
 ::)
ok, i keep forgetting to post up but i've certainly been watching :)

This is great stuff. I haven't gone through the system in detail, but... will you take requests? I'd like to add leader lights to F1 Super Lap, certainly :)
Yes now that I know how to find the memory addresses with Mame debug (at least for a few games) I can try to get others pretty easily for other Mame games. One thing I should have mentioned is that we can also cheat a little and download the Mame Cheats file from here (Pugsys Cheats - http://www.mamecheat.co.uk/ ) and extract the cheats file and find the xml for the game which sometimes has the memory address listed already for us. For example Crusn USA and World had it listed whereas California Speed only had a couple unrelated to the racers position. It could still help with knowing the rough memory address range though. The file name of the xml corresponds to the rom version so crusnusa20.xml (if I recall) is rom 2.0 of crusn USA or crusnusa44.xml is 4.4 rom. Luckily the address listed still worked for crusn 4.5 Mame.

What I really want is someone who knows how to find the memory address for Teknoparrot (Mario Kart Arcade GP DX, Outrun 2 SP SDX, and FnF Supercars). Although I saw a video of a four player Outrun 2 special with 8 wheels and physical cars that had race leader positions so I need to check if outputblaster shows that data already.

buttersoft

  • Trade Count: (+1)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 1782
  • Last login:November 10, 2024, 06:13:40 pm
  • Is running at 15kHz
Re: Adding Race Leader lights - advice needed
« Reply #48 on: November 07, 2023, 07:50:50 pm »
What I really want is someone who knows how to find the memory address for Teknoparrot (Mario Kart Arcade GP DX, Outrun 2 SP SDX, and FnF Supercars). Although I saw a video of a four player Outrun 2 special with 8 wheels and physical cars that had race leader positions so I need to check if outputblaster shows that data already.

Boomslangnz, and all the TP devs, are on the discord pretty often. Boom's FFB and output plugin channels are quieter, so you could try leaving a message in there.

jorgenjl2

  • Trade Count: (0)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 132
  • Last login:November 16, 2024, 03:49:38 pm
  • I want to build my own arcade controls!
Re: Adding Race Leader lights - advice needed
« Reply #49 on: November 08, 2023, 02:49:19 pm »
What I really want is someone who knows how to find the memory address for Teknoparrot (Mario Kart Arcade GP DX, Outrun 2 SP SDX, and FnF Supercars). Although I saw a video of a four player Outrun 2 special with 8 wheels and physical cars that had race leader positions so I need to check if outputblaster shows that data already.

Boomslangnz, and all the TP devs, are on the discord pretty often. Boom's FFB and output plugin channels are quieter, so you could try leaving a message in there.

It sounds like Boomslangz is going to find the address for some Teknoparrot games (Mario Kart/Outrun2SPDX/FnFSupercars) so that is awesome. I still am not clear if Teknoparrot and Outputblaster supports lua scripts but hopefully Boomslangz knows how to do from a high level if not. You would think we could mimic the way we are doing it with mame though.

Here is F1 Super Lap for you.

Code: [Select]
--f1lapraceleader.lua
-- Assuming ':mainpcb:maincpu' is the correct device tag based on your dump command
local cpu_tag = ':mainpcb:maincpu'
local mem = manager.machine.devices[cpu_tag].spaces['program']

function check(offset)
    -- Reading signed byte (8-bit) value from memory
    return mem:read_i8(offset)
end

local baseAddress = 0x201048
local output = manager.machine.output

-- Function to handle the Leader Light situation
function handleLeaderLightOn()
    output:set_value("raceleader", 1)
end

function handleLeaderLightOff()
    output:set_value("raceleader", 0)
end

-- Register a function that gets called every frame
emu.register_frame(function()
    -- Check the current value at baseAddress
    local racePosition = check(baseAddress)
    -- Assuming 0 is the value for the 1st place
    if racePosition == 0 then
        -- If the value at the memory address is 0 (1st place)
        handleLeaderLightOn()
    else
        -- If the value at the memory address is not 0 (not 1st place)
        handleLeaderLightOff()
    end
end)

buttersoft

  • Trade Count: (+1)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 1782
  • Last login:November 10, 2024, 06:13:40 pm
  • Is running at 15kHz
Re: Adding Race Leader lights - advice needed
« Reply #50 on: November 08, 2023, 05:05:07 pm »
Hah, awesome, thanks! Now i just need to figure out how to make the light work with the output i have, but then flash for leader, and then go back to the first output. My previous attempts at this in other games just locked the light on or blinking, can't remember which. I'll try to work exactly what i want and post up.

But we're a week out from a kitchen reno here and haven't started cleaning up. So i'm out for like a month and will try to get time after that :)

jorgenjl2

  • Trade Count: (0)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 132
  • Last login:November 16, 2024, 03:49:38 pm
  • I want to build my own arcade controls!
Re: Adding Race Leader lights - advice needed
« Reply #51 on: November 10, 2023, 12:56:47 pm »
Hah, awesome, thanks! Now i just need to figure out how to make the light work with the output i have, but then flash for leader, and then go back to the first output. My previous attempts at this in other games just locked the light on or blinking, can't remember which. I'll try to work exactly what i want and post up.

But we're a week out from a kitchen reno here and haven't started cleaning up. So i'm out for like a month and will try to get time after that :)

What do you mean go back to the first output? I am only using the race leader light and no vr lights or other outputs but I want to say the Daytona USA race leader light constantly flashes on and off (if I recall) whereas I want to say San Francisco Rush/the Rock/Rush2049 stay on. I have it so the Rush games have flashing green lights to match closer to the arcade and all the rest of the games have flashing rainbow colored effects so I don’t really notice the difference.

buttersoft

  • Trade Count: (+1)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 1782
  • Last login:November 10, 2024, 06:13:40 pm
  • Is running at 15kHz
Re: Adding Race Leader lights - advice needed
« Reply #52 on: November 10, 2023, 04:37:37 pm »
Well, a game like Outrunners has two lights i really want, leader and checkpoint. My setup is very minimal though, so i've added a single physical light. So both outputs would need to be linked to that one light. What i wanted to do, ideally, was have the leader light displaying, but when someone goes through a checkpoint, the same light flashes a few times, then goes back to displaying whatever the leader status is. However, it's not working. I guess it might need a goldfish algorithm, but i haven't looked at it for a while.

jorgenjl2

  • Trade Count: (0)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 132
  • Last login:November 16, 2024, 03:49:38 pm
  • I want to build my own arcade controls!
Re: Adding Race Leader lights - advice needed
« Reply #53 on: November 11, 2023, 06:54:17 pm »
Ah yeah that will require more testing and may depend on the game with whether it flashes on and off constantly or not.

Overall, here are the games that should work for Race Leader lights as far as I know. Some of these I just googled for “race leader arcade” and they showed up. If you know of any others let me know.

Daytona USA
Daytona USA 2
San Francisco Rush
Rush the Rock
Rush 2049
Scud Race (SuperGT)
Indy 500
Sega Rally
Sonic Sega All stars
Grid I think
Manx TT
Outrunners
Motogp I think
Need for Speed Underground maybe?

Added so far
Crusn USA
Crusn World
F1 Super Lap
California Speed

In process of adding
Mario Kart GPDX
Outrun 2 SPDX
Fast and Furious Supercars

jorgenjl2

  • Trade Count: (0)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 132
  • Last login:November 16, 2024, 03:49:38 pm
  • I want to build my own arcade controls!
Re: Adding Race Leader lights - advice needed
« Reply #54 on: November 11, 2023, 07:00:03 pm »
I didn’t expect to see this CrusnUSA leader marquee. I can’t tell if it was functional or not.

jorgenjl2

  • Trade Count: (0)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 132
  • Last login:November 16, 2024, 03:49:38 pm
  • I want to build my own arcade controls!
Re: Adding Race Leader lights - advice needed
« Reply #55 on: May 10, 2024, 11:36:02 pm »
For those interested, on Discord there has been updates to latest output blaster fork to get Outrun2 race leader lights working which I confirmed does work (after upgrading to latest Teknoparrot version and enabling output checkbox in TP after copying output blaster needed dll to the lower level game folder). They are also working on FnF Supercars (they have the memory region now) and possibly Mario Kart. Crusn Blast has a code snippet about race leader so not sure if that already works or will need to be created. So some great progress is being made!

jorgenjl2

  • Trade Count: (0)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 132
  • Last login:November 16, 2024, 03:49:38 pm
  • I want to build my own arcade controls!
Re: Adding Race Leader lights - advice needed
« Reply #56 on: May 10, 2024, 11:50:29 pm »
I have been meaning to write a step by step of how to do this without soldering. This is not the best description but at least it can help someone. I still need to get on one of my cabs and copy up the full Arduino code. The previous Arduino code was for lighting up a single led but for my steps below, it lights up a full ws2812b strip when in first place.


No soldering needed at all. Code is mostly ready to go except you may need to change the number of leds or what led to start the lights at (since some of the leds are outside of the marquee and I don’t want them to light up). Using an arduino with pre soldered connectors, wires that connect directly to the arduino, and using a barrel connector that has screw terminals also helps make this solderless.


1) Unwind the whole ws2812b led strip (since we want the end of the strip wound up the most on the inside)
If you look at the strip, in between each led has an arrow pointing a single direction. This arrow should point up away from the bottom of the cable. In other words, the arrows will end up pointing from the Arduino toward the marquee end (data flows from Arduino toward the end of the led strip or from “RA in RAce leadER to the “ER” at the end of the leader word)
2) Insert a (male) wire into the bottom of the cable into the black piece so one wire goes into the hole where the white cable is and insert another (male) wire where the green cable is and then add on a female to female adapter at the end of both of those (so it can then plug into the Arduino).
3) Put the cable you added that continues the white cable and plug this into the gnd on the Arduino 
4) Put the cable you added that continues the green cable and plug this into D3 on the Arduino
5) Strip the ends of the white and red wires that dangle out of the end of the led strip
6) Put the white striped wire into the negative side of the barrel connector and insert the red wire into the positive side of the barrel connector (screw terminals)
7) Count out 40 leds (or a different number if desired) from the led strip cutting half way beteeen the copper pads after the 40th.
8) Connect a mini usb cable to the Arduino and plug this into your pc
9) Plug in the electrical outlet (connected to the barrel cable that has the red and white wires in it).
10) Download Arduino Ide, start it up, on top menu go to tools >  board > change to Arduino nano
11) Go to tools > port > change com port to your com port for the usb you just plugged in. (If unsure, unplug the usb and see which com number goes away in the menu and which one comes back after plugging back in). Note If you get an error about port conflict when uploading or later on in future steps, right click mamehooker (assuming you already installed it before step below) in your bottom right tray icon and close. Mamehooker takes over your com port.
12) Paste in the code below (code to be uploaded soon hopefully)
13) Click the checkbox near top left to compile and then click the right arrow icon to the right of that to load the program (sketch) onto the Arduino
14) In the ide, Go to tools > serial monitor > type in “3,1,x” without the quotes and hit enter. And then type in 3,1,x again and hit enter key . It should light up. If it does not, review the steps and verify you are on the correct com port in the Arduino ide and the Arduino sketch was uploaded to the Arduino. Also try turning the barrel connector slightly (one time I had to twist it slightly for some reason)

15) Download mamehooker by going to here (http://dragonking.arcadecontrols.com/static.php?page=aboutmamehooker) and hit control-f and find “mamehooker” and there is a download link on the right side of the web page
16) Install it (i installed to c:\mamehooker\*) and then right click mamehooker.exe and choose run as admin (MUST DO THIS FIRST ONCE! Ignore errors if any!)
AFTER YOU HAVE RUN AS ADMIN ONCE, go to bottom right system tray in windows and right click and close mamehooker and ignore any errors if any (first time run as admin is necessary for permissions).
17) Now open up mamehooker.exe again from bottom right Windows system tray WITHOUT running as admin option (from now on no admin needed as long as ran once)
Click options and allow auto find of parameters.
18) Go to your Mame folder that you have Mame.exe installed in and find the Mame.ini file (IF YOU HAVE <game>.ini files named as the game, you have to do change those ini files. as well) and update the ini so the line that says “output” is set to “windows”.
19) Open up Mame and open up a game that has outputs like sfrush and let mamehooker find the outputs. It should auto create a sfrush ini file
Change the mamehooker sfrush.ini to look like below (need to upload this as example as well but earlier posts may have it). I will also attach other mamehooker ini settings that I have.
20) Change the number 4 (4?) in these mamehooker ini files to the com port your Arduino took.
If desired, change the 3,1,x to start with another number (2,1,x for green. 4,1,x for blue, etc)
21) If desired, Download the non-commercial license Arcade1Up marquee 3D print and edit in 3D print software (I use Cura) to be 35% on the height and width (I kept length the same) and 3D print it.
22) Purchase a see through RACE LEADER marquee print from ArcadeGraphix if desired
23) Purchase the black see through plexi glass from Tap Plastics here (https://www.tapplastics.com/product/plastics/cut_to_size_plastic/black_led_sheet/668?gad_source=1&gclid=Cj0KCQiAgK2qBhCHARIsAGACuzmFTLacS1j_ct4d6jj8vSLcML676miM_Vqhu0mv0N58fzFFmexLrvcaAlp4EALw_wcB ) if desired for blacked out look when not on. Size info for my particular size marquee was “Chemcast Black LED Acrylic - Black 1/8 (.118)" Thick, 1-1/2 inches Wide, 17-9/16 inches Long, Color: Black
24) Get in 1st place and Enjoy!!

If you want to add custom race leader lights to games that don’t support it out of the box, see posts above.

jorgenjl2

  • Trade Count: (0)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 132
  • Last login:November 16, 2024, 03:49:38 pm
  • I want to build my own arcade controls!
Re: Adding Race Leader lights - advice needed
« Reply #57 on: June 14, 2024, 04:24:03 pm »
Here is the race leader arduno code for anyone interested in lighting up a whole led strip instead of individual led's. Replace NUM_LEDS with however many you have on your strip (40 in my example) and this assumes pin 3 for data. I will be creating two more race leader lights so hopefully I can take pics of the process.


Code: [Select]
#include <FastLED.h>

// Configuration
#define NUM_LEDS 40          // Set the number of LEDs in the strip
#define DATA_PIN 3           // Set the data pin connected to the LED strip
#define COLOR_ORDER GRB      // Set the color order of the strip
#define LED_TYPE WS2812B     // Set the LED strip type
#define BRIGHTNESS 150       // Set the brightness level (0-255)
#define FRAMES_PER_SECOND  120
unsigned long lastGlitterUpdate = 0;
uint8_t gHue = 0; // rotating "base color" used by many of the patterns
CRGB leds[NUM_LEDS];

enum State {
  STATE_OFF,
  STATE_GREEN,
  STATE_BLUE,
  STATE_RED,
  STATE_RAINBOW,
  STATE_JUGGLE_GREEN,
  STATE_GREENWITHGLITTER
};

State currentState = STATE_OFF;
typedef void (*UpdateFunction)();
UpdateFunction updateFunc = nullptr;

void setup() {
  delay(3000); // 3 second delay for recovery
  FastLED.addLeds<LED_TYPE,DATA_PIN,COLOR_ORDER>(leds, NUM_LEDS).setCorrection(TypicalLEDStrip);
  FastLED.setBrightness(BRIGHTNESS);
  Serial.begin(9600);
  Serial.setTimeout(100); //Setting this prevents the juggleGreen pattern from waiting 2 seconds to start dancing the lights
}

void juggleGreen() {
  // eight colored dots, weaving in and out of sync with each other
  fadeToBlackBy(leds, NUM_LEDS, 20);
  uint8_t dothue = 0;
  for (int i = 0; i < 8; i++) {
    leds[beatsin16(i + 7, 0, NUM_LEDS - 1)] |= CRGB(0, 255, 0);
    dothue += 32;
  }
  FastLED.show();
  FastLED.delay(30);
}

void updateGreen() {
  fill_solid(leds, NUM_LEDS, CRGB::Green);
  FastLED.show();
}

void updateBlue() {
  fill_solid(leds, NUM_LEDS, CRGB::Blue);
  FastLED.show();
}

void updateRed() {
  fill_solid(leds, NUM_LEDS, CRGB::Red);
  FastLED.show();
}

void updateRainbow() {
  fill_rainbow(leds, NUM_LEDS, gHue, 7);
  FastLED.show();
}

void addGlitter( fract8 chanceOfGlitter)
{
  if( random8() < chanceOfGlitter) {
    leds[ random16(NUM_LEDS) ] += CRGB(255, 255, 255); // Full intensity white
  }
}

void greenWithGlitter()
{
  // built-in FastLED green, plus some random sparkly glitter
  fill_solid(leds, NUM_LEDS, CRGB::Green);
  unsigned long currentTime = millis();
  if (currentTime - lastGlitterUpdate >= 50) { // 50 milliseconds interval between glitter updates
    addGlitter(80);
    lastGlitterUpdate = currentTime;
  }
  FastLED.show();
}





void setUpdateFunction() {
  switch (currentState) {
    case STATE_OFF:
      updateFunc = nullptr;
      break;
    case STATE_GREEN:
      updateFunc = updateGreen;
      break;
    case STATE_BLUE:
      updateFunc = updateBlue;
      break;
    case STATE_RED:
      updateFunc = updateRed;
      break;
    case STATE_RAINBOW:
      updateFunc = updateRainbow;
      break;
    case STATE_JUGGLE_GREEN:
      updateFunc = juggleGreen;
      break;
    case STATE_GREENWITHGLITTER:
      updateFunc = greenWithGlitter;
      break;
  }
}

void loop() {
  if (Serial.available() > 0) {
    String input = Serial.readStringUntil('x');
    int pin = input.substring(0, 1).toInt();
    int value = input.substring(1, 2).toInt();

    switch (pin) {
      case 6:
        currentState = value == HIGH ? STATE_GREEN : STATE_OFF;
        break;
      case 5:
        currentState = value == HIGH ? STATE_BLUE : STATE_OFF;
        break;
      case 4:
        currentState = value == HIGH ? STATE_RED : STATE_OFF;
        break;
      case 3:
        currentState = value == HIGH ? STATE_RAINBOW : STATE_OFF;
        break;
      case 2:
        currentState = value == HIGH ? STATE_JUGGLE_GREEN : STATE_OFF;
        break;
       case 1:
        currentState = value == HIGH ? STATE_GREENWITHGLITTER : STATE_OFF;
        break;
    }

    setUpdateFunction();
  }

  if (updateFunc != nullptr) {
    updateFunc();
  } else {
    FastLED.clear();
    FastLED.show();
  }

  gHue++; // Increment the hue value for some animations
}