After you explore the Mauville Gym and battle Wally's Ralts, you can go into the Mauville Gym and challenge Wattson.
The Mauville Gym is an Electric-type gym. Electric-type pokémon are weak to Ground moves. Also, Ground-type pokémon are immune to Electric attacks, making them a good choice to bring to this gym.
Nincada is part Ground-type, as is Geodude, which you can catch in Granite Cave (but it's rare there). Nincada doesn't learn any Ground attacks until level 31, so it's best if you can catch a Geodude to use in this gym because it learns a Ground attack, Magnitude, at level 12. Also, if you chose Mudkip and it has evolved to Marshtomp, it is now a Water/Ground pokémon, making it immune to Electric attacks.
One of the trainers here has Meditite, which is weak to Flying, Ghost, and Fairy moves, so be prepared for that.
Grass, Electric, and Dragon-type pokémon are strong against Electric attacks, so you might want to bring those types with you as well, if you have them.
Flying and Water pokémon are weak to Electric attacks, but Flying/Ground and Water/Ground are immune.
Some of the trainers here have Magnemite and Magneton, which are Electric/Steel, so they are weak to Ground, Fighting, and Fire attacks. If you have pokémon that know Fighting or Fire attacks, such as Makuhita or Torchic/Combusken, you might want to bring them, too.
If you got Cosplay Pikachu by participating in a Contest in Slateport City, you can have her wear the Cuteness costume to learn Draining Kiss, which works well against the Meditite in this gym. However, although Cosplay Pikachu can learn Flying Press from the Toughness costume, the move is a Fighting/Flying move, not a pure Fighting move, so it doesn't work well against Magnemite and Magneton.
If you have 10,000 Pokédollars, go to the Poké Mart in Mauville City and buy TM78 Bulldoze. It is a Ground-type attack that works very well in this gym. Geodude learns this move at level 22.
If possible, bring a lot of Paralyze Heals with you, and if you have Cheri Berries, you might want to give them to your pokémon to hold. Many of the pokémon in this gym can cause paralysis. But keep in mind that you can leave the gym any time between battles and heal up your pokémon before you continue.
Battle the Trainers
In the first floor of the gym, go to the left to battle Guitarist Kirk, who has Magnemite and Electrike.
After the battle with Kirk, step on the red switch near him, then step on the blue switch to the right. This opens the path to the north. Go north and go up the stairs to the second floor of the gym.
On this floor, to reach the top of the room, you have to step on a blue switch, then a red switch, then a blue switch. In other words, first you have to step on a switch on the right side of the room, then a switch on the left side, then a switch on the right side.
Go to the right and battle Youngster Ben, who has Electrike.
After battling the youngster, step on the blue switch near him, then go up and battle Battle Girl Vivian, who has a Meditite. Or you can step on the northeast blue switch, but you will still have to battle Vivian.
After the battle with the Battle Girl, step on the red switch near her. Then go to the northeast and step on the blue switch there. Then go south, and you will be able to go north between the electric barriers.
On the way, you have to battle Guitarist Shawn, who has two Voltorbs.
After that, go north to battle Wattson.
Wattson has Magnemite, Voltorb, and Magneton. He has a Super Potion that he might use during the battle to heal his pokémon. Also, all of his pokémon know Volt Switch, which causes the attacker to switch with a different pokémon afterward. In addition, Wattson's Magneton knows Supersonic, which can cause your pokémon to become confused.
After you Win the Dynamo Badge
With the Dynamo badge, traded pokémon up to level 40 will obey you, and you will be able to use Rock Smash outside of battle.
Wattson also gives you TM72 Volt Switch.
Be sure to go to the Pokémon Center in Mauville City and talk to the old guy. This is the Hipster, who gives you another O-Power: Befriending Power Lv. 1.
There are some optional things you can do now. For example, if you haven't already, you can go west to check out Route 117, which contains the Pokémon Day Care, where you can breed pokémon. Route 117 leads to Verdanturf Town to the west. From Verdanturf, you can reach Rusturf Tunnel, where you can now use Rock Smash to break the rocks that block the path there. This gives you a shortcut to Rustboro City.
If you are ready to continue with the story, go north from Mauville City. You will see a short cut scene with some Team Magma/Aqua Grunts. Then you can go north to the south part of Route 111.