0

I am trying to design a laser tag system using multiple NodeMCUs in the guns. I am trying to figure out how to connect and control them over WiFi. I also need a computer connected that will control the game. I was origionally just thinking I could use the PC as a server that tells all the guns what to do. Im sure this is possible, but it looks very complicated and I dont know a whole lot about theese types of things. So then I was thinking it might be better to have another NodeMCU connected to the computer with USB. That NodeMCU would then act as a WiFi server for the clients(Guns). That way, the PC would only have a GUI for that MCU, and once started the MCU would actually control the game. Is that the best option or is there some easier and simpler way? That seems like the best solution to me. I am just making sure this will work. Are there any other solutions or tips? Here is a basic idea of what would happen when someone shoots someone else.

Gun 1 will send IR signal (Shoot) gun 2.

Gun 1 will tell the server that it tried to shoot gun 2.

Gun 2 tells server it got IR signal from gun 1.

Server will first make sure no other guns were shot accidentally at the same time. If they were, it will determine which gun received the IR signal stronger. That gun will be the one actually shot.

Server will add points to gun 1 score and remove points from gun 2 score on both PC monitor and small screens on guns themselves.

Thanks!

4
  • there is no reason why the server would have to decide who shot a target (gun 2 in your example) ... the decision should be made by the target ... determining an IR signal strength can be a problem ... it would be easiest to award the kill to the first shot and award a kill to each of the shots if received simultaneously .... also, it is pointless to count that gun1 tried to shoot gun2 ... how would you determine that if gun1 misses the target?
    – jsotola
    May 11 '20 at 2:38
  • @jstola At this point I have tried so many things and researched so many ways of making this work that I cant think right. What I said is more complicated than it would really be. I am just looking to connect 5 or 6 MCUs together in a network, along with a PC. The MCUs will control almost everything by themselves.
    – Randomaker
    May 11 '20 at 19:26
  • All the PC will do is change settings, keep track of score and tell MCUs when to start and stop the game. My main questions are 1, How to connect 5-6 MCUs and a PC together over WiFi and send information between them, and 2, how to make a simple PC program that keeps track of score, tells MCUs when to start and stop, and changes settings. Also, all of the ways Ive seen people communicate over WiFi use a server that broadcasts out WiFi. How can I just use my existing router now that I arent using a server?
    – Randomaker
    May 11 '20 at 19:27
  • Plz tell me how I can do this.
    – Randomaker
    May 11 '20 at 19:27
-1

I would not consider it easier to connect a NodeMCU to the PC just to act as a Wifi interface. Most computers already have means of connecting to a network. Wether it is via Wifi or LAN is not important. Every PC has a LAN port on it's mainboard. You could connect it directly to your Wifi router.

Using a NodeMCU as you proposed would mean, that you have to program for 2 platforms: The main logic on the PC and the Wifi communication on the NodeMCU. That does not really make it easier.

The communication depends on your wanted topology. I would build the PC as Server and the NodeMCUs as clients. You can easily create a webserver programmatically with python, for example with Flask, as I have done it once. Though there even might be better webserver modules for python. It is really not that difficult and you already need to write a program for the game logic on the PC,so why not using python. Though of course you could choose any language, that you like. Python is just an easy choice, that I already did.

6
  • So i guess my question then is more how to make that game logic on the PC. How exactly do I do this? Could you maybe point me towards a totorial? Thanks!
    – Randomaker
    May 10 '20 at 22:01
  • 1
    There is no tutorial, that explains how to write the game logic for your specific project, because it is specific to your project. Choose a fitting programming language and learn the basics of it. Variables, arrays, conditions, loops,... Them write down the game logic as text, convert that into pseudo code and then into real code. We cannot explain more, since the question is so broad
    – chrisl
    May 10 '20 at 22:06
  • Ok thx, I will check out some languages.
    – Randomaker
    May 10 '20 at 22:25
  • web server? what for? sorry @chrisl, but this answers shows that you shouldn't write an answer to this question
    – Juraj
    May 11 '20 at 9:34
  • @Juraj Please be a bit more specific about what is wrong with the answer. That would help both the OP and me
    – chrisl
    May 11 '20 at 10:05

Not the answer you're looking for? Browse other questions tagged or ask your own question.