I have a code and it cannot compile but I do not know what the problem is. I would love some help please.
3.23.pdf (64.8 KB)
For those that don't want to download the pdf, here's the code....
#include <Wire.h>
#include <PS4USB.h>
#include <Servo.h>
#include <ezButton.h>
USB Usb;
PS4USB PS4(&Usb);
Servo Lift;
Servo Grip;
Servo Left;
Servo Right;
void setup() {
// put your setup code here, to run once:
Serial.begin(9600);
if (Usb.Init() == -1) {
while (1);
}
PS4.setLed(Green);
Lift.attach(0);
Grip.attach(1);
Left.attach(2);
Right.attach(3);
ezButton limitSwitch(4);
ezButton Button(5);
Lift.write(90);
Grip.write(180);
Left.write(90);
Right.write(90);
}
void handleHeight() {
// handle movement
if (PS4.getButtonPress(R1)) {
Lift.write(180);
}
//LIMIT SWITCH
if (PS4.getButtonPress(L1)) {
Lift.write(0);
}
}
//The left analog stick in the Y-direction will handle the left drive servo, up for forward, back for backwards
void handleLeft() {
int LY;
LY = map(PS4.getAnalogHat(LeftHatY), 0, 255, -90, 90);
Left.write(LY + 90);
}
//The right trigger opens the gripper and the left trigger closes
the gripper
void handleGrip() {
// handle movement
if (PS4.getButtonPress(L2)) {
Grip.write(180);
}
if (PS4.getButtonPress(R2)) {
Grip.write(0);
}
}
//The right analog stick in the Y-direction will handle the right drive servo, up for forward, back for backwards
void handleRight() {
int RY;
RY = map(PS4.getAnalogHat(RightHatY), 0, 255, -90, 90);
Right.write(RY + 90);
}
Read the forum guidelines to see how to properly post code and some information on how to get the most from this forum.
Use the IDE autoformat tool (ctrl-t or Tools, Auto format) before posting code in code tags.
Please include the entire error message. It is easy to do. There is a button (lower right of the IDE window) called "copy error message". Copy the error and paste into a post in code tags. Paraphrasing the error message leaves out important information.
What is the message you get when you try to compile it?
You have no loop()
What is the purpose of these ezButton defines in setup()?
ezButton limitSwitch(4);
ezButton Button(5);
Where is the loop() function?
In the Arduino IDE you will want to have a function called loop that starts off like ```void loop()`` and may or may not contain code.
This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.