Pong Battle

Hello everyone

We are currently working on an IoT project in our studies. We are all rookies in this field. The goal of the project is to make the game “Pong Battle” (two player game) run on an Arduino. For this we also have a PHPoC Wifi Shield. The game itself is programmed on this Wifi Shield and the control runs over the Arduino UNO. At the moment we have two breadbords connected with two buttons each. This works fine. But now we want to make the control via an app possible. The app only has to have two buttons to move the goalkeepers to the left or right. Now our question: Is it possible to make this app via Blynk? We’re getting to know Blynk and can’t get any further. Does anyone have a hint on how to proceed?

Any help is appreciated.

This is the code for the control on the Arduino Uno.

#include "SPI.h"
#include "Phpoc.h"

PhpocServer server(80);
boolean alreadyConnected = false; 

void setup() {
    Serial.begin(9600);
    while(!Serial)
        ;

    Phpoc.begin(PF_LOG_SPI | PF_LOG_NET);

    server.beginWebSocket("game");

    Serial.print("WebSocket server address : ");
    Serial.println(Phpoc.localIP());
    
    pinMode(6, INPUT); 
    pinMode(7, INPUT); 
    pinMode(8, INPUT); 
    pinMode(9, INPUT); 
    
}

int value_6 = digitalRead(6);
int value_7 = digitalRead(7);
int value_8 = digitalRead(8);
int value_9 = digitalRead(9);
int pre_dir_1 = 0;
int pre_dir_2 = 0;
int dir_1 = 0;
int dir_2 = 0;

void loop() {
    // when the client sends the first byte, say hello:
    PhpocClient client = server.available();
    if (client) {
        value_6 = digitalRead(6);
        value_7 = digitalRead(7);
        value_8 = digitalRead(8);
        value_9 = digitalRead(9);
        dir_1 = value_7 - value_6;
        dir_2 = value_9 - value_8;

        if(dir_1 != pre_dir_1 || dir_2 != pre_dir_2)
        {
            pre_dir_1 = dir_1;
            pre_dir_2 = dir_2;
            
            String txtMsg = "[" + String(dir_1) + ", " + String(dir_2) + "]\r\n";  
            char buf[txtMsg.length()+ 1];
            txtMsg.toCharArray(buf, txtMsg.length() + 1);
            server.write(buf, txtMsg.length());
        }         
    }
}

So far, you’ve copied this project without acknowledging the source of your code:


and spent less than one minute researching Blynk via the forum:

Personally, I’m not inclined to help you succeed in your studies unless you’re prepared to put more effort into the project yourselves.

Pete.

Hello, Pete.

Of course you’re right, we got the code and the project from here (not mentioning that was wrong):

As already mentioned, we are very new in this area. It is our first Project ever. It’s about making a first experience with IoT technologies. We are not looking for a complete guide on how to do this. We just wanted helpful tips on how to approach this project and the app. Maybe I should mention that this is a voluntary project. Even though it may not look like it, we have already invested a lot of effort in this project. We will continue to work on it. Anyway, thank you for your answer.