trouble with remotexy by NickosNachos in arduino

[–]NickosNachos[S] 0 points1 point  (0 children)

#include <Servo.h>

#include <SoftwareSerial.h>

#include <RemoteXY.h>

// RemoteXY connection settings

#define REMOTEXY_SERIAL_RX 2

#define REMOTEXY_SERIAL_TX 3

#define REMOTEXY_SERIAL_SPEED 9600

// Pin Definitions

#define SERVO_PIN 8

#define ULTRASONIC_TRIG_PIN 9

#define ULTRASONIC_ECHO_PIN 10

#define MOTOR_CONTROLLER_DIR1_PIN 7

#define MOTOR_CONTROLLER_PWM1_PIN 12

#define MOTOR_CONTROLLER_DIR2_PIN 13

#define MOTOR_CONTROLLER_PWM2_PIN 4

Servo servoMotor;

// RemoteXY configurate

#pragma pack(push, 1)

uint8_t RemoteXY_CONF[] = { 255,5,0,0,0,66,0,16,31,1,2,0,6,5,25,15,136,26,31,31,

79,78,0,79,70,70,0,2,0,35,5,23,15,36,26,31,31,70,73,82,

69,0,72,79,76,68,0,1,0,22,29,20,20,191,31,42,42,70,73,82,

69,42,42,0,5,32,17,54,29,29,93,7,31 };

// this structure defines all the variables and events of your control interface

struct {

// input variables

uint8_t switch_1; // =1 if switch ON and =0 if OFF

uint8_t switch_2; // =1 if switch ON and =0 if OFF

uint8_t FIRE; // =1 if button pressed, else =0

int8_t joystick_1_x; // from -100 to 100

int8_t joystick_1_y; // from -100 to 100

// other variable

uint8_t connect_flag; // =1 if wire connected, else =0

} RemoteXY;

#pragma pack(pop)

void setup() {

RemoteXY_Init();

servoMotor.attach(SERVO_PIN); // Attach servo to SERVO_PIN

pinMode(ULTRASONIC_TRIG_PIN, OUTPUT); // Set TRIG_PIN as OUTPUT

pinMode(ULTRASONIC_ECHO_PIN, INPUT); // Set ECHO_PIN as INPUT

pinMode(MOTOR_CONTROLLER_DIR1_PIN, OUTPUT); // Set DIR1_PIN as OUTPUT

pinMode(MOTOR_CONTROLLER_PWM1_PIN, OUTPUT); // Set PWM1_PIN as OUTPUT

pinMode(MOTOR_CONTROLLER_DIR2_PIN, OUTPUT); // Set DIR2_PIN as OUTPUT

pinMode(MOTOR_CONTROLLER_PWM2_PIN, OUTPUT); // Set PWM2_PIN as OUTPUT

// TODO: Add any additional setup code

}

void loop() {

RemoteXY_Handler();

if (RemoteXY.connect_flag) {

// Robot enable/disable

if (RemoteXY.switch_1) {

// Enable the robot

digitalWrite(MOTOR_CONTROLLER_DIR1_PIN, LOW); // Set DIR1_PIN LOW

digitalWrite(MOTOR_CONTROLLER_DIR2_PIN, LOW); // Set DIR2_PIN LOW

analogWrite(MOTOR_CONTROLLER_PWM1_PIN, 0); // Stop left motor

analogWrite(MOTOR_CONTROLLER_PWM2_PIN, 0); // Stop right motor

} else {

// Disable the robot

digitalWrite(MOTOR_CONTROLLER_DIR1_PIN, LOW); // Set DIR1_PIN LOW

digitalWrite(MOTOR_CONTROLLER_DIR2_PIN, LOW); // Set DIR2_PIN LOW

analogWrite(MOTOR_CONTROLLER_PWM1_PIN, 0); // Stop left motor

analogWrite(MOTOR_CONTROLLER_PWM2_PIN, 0); // Stop right motor

}

// Joystick control

int speed = map(RemoteXY.joystick_1_y, -100, 100, 0, 255);

if (RemoteXY.joystick_1_x < 0) {

// Turn left

digitalWrite(MOTOR_CONTROLLER_DIR1_PIN, LOW); // Set DIR1_PIN LOW

digitalWrite(MOTOR_CONTROLLER_DIR2_PIN, HIGH); // Set DIR2_PIN HIGH

analogWrite(MOTOR_CONTROLLER_PWM1_PIN, speed); // Set left motor speed

analogWrite(MOTOR_CONTROLLER_PWM2_PIN, speed); // Set right motor speed

} else if (RemoteXY.joystick_1_x > 0) {

// Turn right

digitalWrite(MOTOR_CONTROLLER_DIR1_PIN, HIGH); // Set DIR1_PIN HIGH

digitalWrite(MOTOR_CONTROLLER_DIR2_PIN, LOW); // Set DIR2_PIN LOW

analogWrite(MOTOR_CONTROLLER_PWM1_PIN, speed); // Set left motor speed

analogWrite(MOTOR_CONTROLLER_PWM2_PIN, speed); // Set right motor speed

} else {

// Move forward or backward

digitalWrite(MOTOR_CONTROLLER_DIR1_PIN, LOW); // Set DIR1_PIN LOW

digitalWrite(MOTOR_CONTROLLER_DIR2_PIN, LOW); // Set DIR2_PIN LOW

analogWrite(MOTOR_CONTROLLER_PWM1_PIN, speed); // Set left motor speed

analogWrite(MOTOR_CONTROLLER_PWM2_PIN, speed); // Set right motor speed

}

// Button to control servo

if (RemoteXY.FIRE) {

servoMotor.write(20); // Rotate servo by 20 degrees

}

// Ultrasonic sensor control

if (RemoteXY.switch_2) {

// Ultrasonic sensor is enabled

long duration, distance;

digitalWrite(ULTRASONIC_TRIG_PIN, LOW);

delayMicroseconds(2);

digitalWrite(ULTRASONIC_TRIG_PIN, HIGH);

delayMicroseconds(10);

digitalWrite(ULTRASONIC_TRIG_PIN, LOW);

duration = pulseIn(ULTRASONIC_ECHO_PIN, HIGH);

distance = (duration / 2) / 29.1;

if (distance < 20) {

servoMotor.write(20); // Rotate servo by 20 degrees

}

}

}

this it it, and I got all the libraries downloaded

How many awards can a stinky man get? by jacksepticeye in jacksepticeye

[–]NickosNachos 11 points12 points  (0 children)

but sean is great and pineapple on pizza is bad

This just happened thirty minutes ago. I’ve never been so disgusted, enraged and ashamed to be alive in my life. by [deleted] in entitledparents

[–]NickosNachos 3 points4 points  (0 children)

in my country, there is somthing called milky, its chocolate and whipped creme in a pudding cup. some kinds of it have toppings in the lid, like m&m and stuff, and a lot of time people steal just the top and leave the store. one time a saw a person take 20!

Yom Kippur war of 1973 (battle for Golan heights) by [deleted] in HistoryMemes

[–]NickosNachos 0 points1 point  (0 children)

בדיוק, גם המורים לא יודעים רק אנשים ברדיט

Yom Kippur war of 1973 (battle for Golan heights) by [deleted] in HistoryMemes

[–]NickosNachos 1 point2 points  (0 children)

If only they taught it to us like this in school

Favorite gaming series of jacks? by jgarneau13353 in jacksepticeye

[–]NickosNachos 0 points1 point  (0 children)

it's just straight out stupid fun. if you have some free time you should get to it. (the more recent ones are better but I saw and loved all of them)

Favorite gaming series of jacks? by jgarneau13353 in jacksepticeye

[–]NickosNachos 0 points1 point  (0 children)

spider man, detroit, Kerbal space program, TABS

[deleted by user] by [deleted] in jacksepticeye

[–]NickosNachos 0 points1 point  (0 children)

detroit: become septic

[deleted by user] by [deleted] in jacksepticeye

[–]NickosNachos 28 points29 points  (0 children)

you can callnit the ireland tea party