Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- -- New project --
- This source code of graphical user interface
- has been generated automatically by RemoteXY editor.
- To compile this code using RemoteXY library 3.1.13 or later version
- download by link http://remotexy.com/en/library/
- To connect using RemoteXY mobile app by link http://remotexy.com/en/download/
- - for ANDROID 4.13.13 or later version;
- - for iOS 1.10.3 or later version;
- This source code is free software; you can redistribute it and/or
- modify it under the terms of the GNU Lesser General Public
- License as published by the Free Software Foundation; either
- version 2.1 of the License, or (at your option) any later version.
- */
- //////////////////////////////////////////////
- // RemoteXY include library //
- //////////////////////////////////////////////
- // you can enable debug logging to Serial at 115200
- //#define REMOTEXY__DEBUGLOG
- // RemoteXY select connection mode and include library
- #define REMOTEXY_MODE__ESP32CORE_BLE
- #include <BLEDevice.h>
- // RemoteXY connection settings
- #define REMOTEXY_BLUETOOTH_NAME "dΓΌpr"
- #define REMOTEXY_ACCESS_PASSWORD "esp"
- #include <RemoteXY.h>
- // RemoteXY GUI configuration
- #pragma pack(push, 1)
- uint8_t RemoteXY_CONF[] = // 92 bytes
- { 255, 6, 0, 4, 0, 85, 0, 17, 0, 0, 0, 31, 2, 106, 200, 200, 84, 1, 1, 5,
- 0, 5, 201, 21, 143, 143, 2, 18, 54, 54, 32, 190, 28, 31, 5, 28, 21, 129, 129, 144,
- 17, 54, 54, 32, 190, 28, 31, 4, 44, 232, 7, 86, 25, 2, 154, 14, 128, 190, 28, 2,
- 52, 74, 23, 52, 112, 30, 30, 11, 0, 190, 28, 31, 31, 79, 78, 0, 79, 70, 70, 0,
- 68, 45, 112, 21, 95, 55, 53, 90, 31, 17, 28, 190 };
- // this structure defines all the variables and events of your control interface
- struct {
- // input variables
- int8_t joystick_links_x; // from -100 to 100
- int8_t joystick_links_y; // from -100 to 100
- int8_t joystick_rechts_x; // from -100 to 100
- int8_t joystick_rechts_y; // from -100 to 100
- int8_t servo; // from 0 to 100
- uint8_t switch_main; // =1 if switch ON and =0 if OFF
- // output variables
- float onlineGraph_01_var1;
- // other variable
- uint8_t connect_flag; // =1 if wire connected, else =0
- } RemoteXY;
- #pragma pack(pop)
- /////////////////////////////////////////////
- // END RemoteXY include //
- /////////////////////////////////////////////
- #include <ESP32Servo.h>
- Servo myServo;
- void setup() {
- int A = 4;
- int B = 5;
- int l;
- int L;
- l = RemoteXY.joystick_links_y;
- L = l / 100 * 255;
- if (l > 0) {
- L = L;
- digitalWrite(A, 0);
- analogWrite(B, L);
- } else if (l < 0) {
- L = -L;
- digitalWrite(B, 0);
- analogWrite(A, L);
- } else {
- L = 0;
- digitalWrite(A, 0);
- analogWrite(B, 0);
- }
- int C = 6;
- int D = 7;
- int r;
- int R;
- r = RemoteXY.joystick_rechts_y;
- R = r / 100 * 255;
- if (r > 0) {
- R = R;
- digitalWrite(C, 0);
- analogWrite(D, R);
- } else if (r < 0) {
- R = -R;
- digitalWrite(D, 0);
- analogWrite(C, R);
- } else {
- R = 0;
- digitalWrite(C, 0);
- analogWrite(D, 0);
- }
- RemoteXY_Init();
- myServo.attach(1);
- RemoteXY.servo = 0;
- // TODO your setup code
- }
- void loop() {
- RemoteXY_Handler();
- int ms = RemoteXY.servo * 20 + 500;
- myServo.writeMicroseconds(ms);
- drive();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement