FF10 lightning dodge easy mode

FF10 lightning dodge easy mode

There is an optional quest/side mission thing in Final Fantasy 10 in which you can dodge 200 lightning strikes in the lightning plains.  The reward is the best weapon in the game for one of the characters, Lulu.  There are other rewards for dodging 50, 100, and 150 strikes, but 200 is maximum and really the main goal.  

To dodge you press the x button.  

BUT MAN IT'S HARD.  Even just dodging 1 strike is difficult and takes very precise timing.  SO FUCK THAT.  I rigged up a RPI 2040 board to my ps2 controller with a relay and light sensor instead C:

I used a 3rd party board that utilizes the RPI 2040 package running micropython.  It's this tiny little seed board, isn't he cute C:

For the PS2 controller I soldered a wire directly to the x button input pad (yellow wire) and a wire to ground connection (black wire).  

These wires will be connected to a relay and will be shorted together when the light sensor triggers.

There is a really useful aspect of these lightning strikes in ff10.  Right before a strike, the entire screen flashes white.  The plan is to place a light detecting sensor pointed at the screen and detect that flash.  When the flash is detected by the sensor, it will trigger a relay to short the x button input of the controller to ground (causing the controller to register an x button input).  The reason I wanted to use a relay instead of just wiring it directly to the 2040 was to learn more about relays.  I have never worked with relays before and I wanted some experience.  

Here are some professional schematics:

Professional

I have the 5v pin going to the relay for power, the 3.3v pin going to power the light sensor, the A0 (27 on GPIO) analog pin connected to the analog output pin on the light sensor, and then the number 2 pin going to the relay to trigger it to switch.

The light sensor I have supports both digital read and analog read.  There is a potentiometer on the sensor to adjust sensitivity so maybe you could make it work with the digital input, but it would be much easier to work with the analog read.  The Tiny board luckily has a couple of analog capable pins, they just need to be configured in code.  

The LightProbeTest function reads the light input and prints out the analog value.  With this function I can figure out the value the sensor outputs when a lightning strike happens.  It happens to be a value of around 21000 when lightning strikes.

I set the threshold variable to be 23000 just to make sure it triggers when the screen flashes.  

Here is the main function o.o

Inside the infinite while loop:

The light probe analog value is read, if the value is less than the 23000 threshold, then sleep for 0.15 seconds (DODGE_DELAY).  You have to delay before hitting the x button of course since the computer is so fast it would hit the x button almost on the same frame that the light sensor detects the flash of light.  After the 0.15 second delay, it sends a signal to the relay to switch on.  This will short the ground pin and x button pad together within the controller, causing it to register an x button input into the game.  AND THUS, causing the character to successfully dodge a lightning strike.  

Oh yeah, and I used a rubber band to hold the joystick to make him run to the right.  You need to be running against a wall so that when he dodges he goes back to the same position.  Otherwise he would just move around the map with dodges and may dodge himself into a load screen or something.  

No github link cuz the code is all there and there isn't much to it.  

Hey if you made it this far, cool, thanks for checking this out c:  

A Final Fantasy 10 full playthrough with me and Eric will be up on the channel in a couple months or so.