senseBox Blockly
senseBox-Logo
  1. ›
  2. Galerie

  3. ›
  4. Pong - Hauptspieler (für den Mehrspielermodus)

Pong - Hauptspieler (für den Mehrspielermodus)

Sensors
WIFI
ESPNOW
Ethernet
SD
LED
LED Matrix
Display
openSenseMap
LoRa
Aktivierung
Lora Message
TTN Mapper
Cayenne LPP
Bluetooth
Phyphox
Webserver
MQTT
Logic
Loops
Text
Time
Time control
RTC
NTP
Math
Audio
Variables
Functions
Advanced
Serial
Input/Output
Motors
Watchdog
1174-1-1Stringmessage ▾1= ▾floatplayer_2 ▾1+ ▾-15constrainlowhighsetfloatplayer_2 ▾toStringmessage ▾-1= ▾floatplayer_2 ▾1- ▾-15constrainlowhighsetfloatplayer_2 ▾toifdoifdoWhen messagemessage ▾received frommac_address ▾doCalldrawsetfloatball_dir_y ▾tosetfloatball_dir_x ▾tosetfloatball_y ▾tosetfloatball_x ▾tosetfloatplayer_2 ▾tosetfloatplayer_1 ▾toInitialise LED-MatrixPort:A ▾Brightness: 20Initialise ESP-NowESP32-S2 MPU6050Value:X ▾-1< ▾floatplayer_1 ▾1- ▾-15constrainlowhighsetfloatplayer_1 ▾toESP32-S2 MPU6050Value:X ▾1> ▾floatplayer_1 ▾1+ ▾-15constrainlowhighsetfloatplayer_1 ▾toCalldrawifdoifdofloatball_x ▾floatball_dir_x ▾+ ▾floatball_y ▾floatball_dir_y ▾+ ▾Callcheck_positionCalldrawsetfloatball_y ▾tosetfloatball_x ▾toInterval: ball_movement200msInterval: player_movement100msArduino run first:Arduino loop forever:0floatplayer_1 ▾0+ ▾0floatplayer_1 ▾1+ ▾0floatplayer_1 ▾2+ ▾0floatplayer_1 ▾3+ ▾11floatplayer_2 ▾0+ ▾11floatplayer_2 ▾1+ ▾11floatplayer_2 ▾2+ ▾11floatplayer_2 ▾3+ ▾floatball_x ▾floatball_y ▾Set pixelsPort:A ▾Draw immediatly✓XYColorSet pixelsPort:A ▾Draw immediatly✓XYColorSet pixelsPort:A ▾Draw immediatly✓XYColorSet pixelsPort:A ▾Draw immediatly✓XYColorSet pixelsPort:A ▾Draw immediatly✓XYColorSet pixelsPort:A ▾Draw immediatly✓XYColorSet pixelsPort:A ▾Draw immediatly✓XYColorSet pixelsPort:A ▾Draw immediatly✓XYColorSet pixelsPort:A ▾Draw immediatly✓XYColorClear matrixPort:A ▾Create Functiondraw floatball_y ▾0≤ ▾floatball_y ▾7≥ ▾or ▾0floatball_dir_y ▾- ▾setfloatball_dir_y ▾tofloatball_dir_x ▾0< ▾floatball_x ▾1≤ ▾floatball_x ▾0≥ ▾and ▾floatplayer_1 ▾3+ ▾floatball_y ▾≥ ▾floatplayer_1 ▾floatball_y ▾≤ ▾and ▾0floatball_dir_x ▾- ▾setfloatball_dir_x ▾toifdoifdofloatball_x ▾10≥ ▾floatball_x ▾11≤ ▾and ▾floatplayer_2 ▾3+ ▾floatball_y ▾≥ ▾floatplayer_2 ▾floatball_y ▾≤ ▾and ▾0floatball_dir_x ▾- ▾setfloatball_dir_x ▾toifdoifdofloatball_x ▾-1< ▾Motivesad ▾20008setfloatball_x ▾towaitmillisecondsDraw bitmapPort:A ▾Motivefloatball_x ▾11> ▾Motivehappy ▾20003setfloatball_x ▾towaitmillisecondsDraw bitmapPort:A ▾MotiveifdoifdoifdoelseifdoCreate Functioncheck_position 
1113000100500100500100TitleUnitTitleUnit01505050150000000latitudelongitudealtitudepDOPfixType10110110001000000000101197011100110022010090
{ }
Arduino Source Code
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
// Code generated by senseBox Blockly on Wed May 28 2025 09:28:58 GMT+0000 (Coordinated Universal Time)
#include <esp_now.h>
#include <WiFi.h>
#include <Adafruit_NeoPixel.h>
#include <Adafruit_NeoMatrix.h>
#include <Adafruit_GFX.h> // http://librarymanager/All#Adafruit_GFX_Library
#include <Adafruit_MPU6050.h>
#include <Adafruit_Sensor.h>
#include <Wire.h>
float player_1;
float player_2;
float ball_x;
float ball_y;
float ball_dir_x;
float ball_dir_y;
String message;
String mac_address;
<>
XML Blocks
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
<xml xmlns="https://developers.google.com/blockly/xml" board="null">
  <variables>
    <variable type="float" id="p,w,}+G:-A#~_U(^JxUg">ball_dir_y</variable>
    <variable type="float" id="Usx1:Y[QP,3{$`9}haKT">player_1</variable>
    <variable type="float" id="devtxdV5ouZ=/fr]tV|Z">ball_x</variable>
    <variable type="float" id="j}oLejzJ2d::jb,|.zS9">player_2</variable>
    <variable type="float" id="|Cv|G]bo9dPb,g}LWRs]">ball_y</variable>
    <variable type="float" id="d42u.!r[x4c_}$ozJAP*">ball_dir_x</variable>
    <variable type="String" id="EeCzkaS!8hNkWC9~ob^d">message</variable>
    <variable type="String" id="5dv{Nn~dhkrW}v++Hiu:">mac_address</variable>
  </variables>
  <block type="arduino_functions" id="QWW|$jB8+*EL;}|#uA" deletable="false" x="-610" y="99">
    <data>esp32</data>
    <statement name="SETUP_FUNC">
      <block type="sensebox_esp_now" id="IdD28P[7KQHv*.v}#q;H">
        <next>
          <block type="sensebox_ws2812_matrix_init" id="9Ud8OTQqzGyXSWO+=ep|">
            <field name="Port">2</field>
            <field name="BRIGHTNESS">20</field>
            <next>
              <block type="variables_set_dynamic" id="q4@Bu4Q+?Hjknyv(n7{Q">
                <field name="VAR" id="Usx1:Y[QP,3{$`9}haKT" variabletype="float">player_1</field>
                <value name="VALUE">
                  <block type="math_number" id="##hX2C{|V/9U`t8tB_A{">
                    <field name="NUM">1</field>
                  </block>
                </value>
                <next>
                  <block type="variables_set_dynamic" id="_dVwdH#L)dN0`BSZv7Hn">
                    <field name="VAR" id="j}oLejzJ2d::jb,|.zS9" variabletype="float">player_2</field>
                    <value name="VALUE">

Information about the Block

Select a Block to show the hint

This website uses cookies to enhance the user experience.
Impressum

|

Privacy

|

News

|

sensebox.de
Menu
    Blockly
    Tutorials
    Gallery
    Code Editor

    Login
    FAQ
    Settings

Which board are you using?

senseBox MCU

senseBox MCU-S2

senseBox MCU:mini

Here you can access the old blockly Version for the Arduino UNO or the senseBox MCU