A
Arduino•2mo ago
welden lebe

guys i cant do my beetle bot 3 in 1 it says 'servopulse' was not declared in this scope

hers the code
No description
4 Replies
welden lebe
welden lebeOP•2mo ago
oh i will put the code int servoPin = 9; //Define the pins of the steering gear void setup() { pinMode(servoPin, OUTPUT); //steering pin is set to output servopulse(servoPin, 90); //Turn it to 90 degrees delay(300); //delay 0.3S } void loop(){ void servopulse(int pin, int myangle) { //Impulse function int pulsewidth = map(myangle, 0, 180, 500, 2500); //Map Angle to pulse width for (int i = 0; i < 5; i++) { //Output a few more pulses digitalWrite(pin, HIGH);//Set the steering gear interface level to high delayMicroseconds(pulsewidth);//Number of microseconds of delayed pulse width value digitalWrite(pin, LOW);//Lower the level of steering gear interface delay(20 - pulsewidth / 1000);
digitalWrite(pin, LOW);//Lower the level of steering gear interface delay(20 - pulsewidth / 1000); }
} here so can you fi xit?
Coder_DO_As_Impossible
:PostOnlyInOneChannel:
welden lebe
welden lebeOP•2mo ago
oh so can i dm them oh ok šŸ˜„ so its good? the board is a keyestudio nano oh ok ty so much
AnonEngineering
AnonEngineering•2mo ago
I have no idea what you are trying to do but as nis said you have syntax errors. This code will at least compile:
c++
int servoPin = 9; //Define the pins of the steering gear

void servopulse(int pin, int myangle) { //Impulse function
int pulsewidth = map(myangle, 0, 180, 500, 2500); //Map Angle to pulse width
for (int i = 0; i < 5; i++) { //Output a few more pulses
digitalWrite(pin, HIGH);//Set the steering gear interface level to high
delayMicroseconds(pulsewidth);//Number of microseconds of delayed pulse width value
digitalWrite(pin, LOW);//Lower the level of steering gear interface
delay(20 - pulsewidth / 1000);
digitalWrite(pin, LOW);//Lower the level of steering gear interface
delay(20 - pulsewidth / 1000);
}
}

void setup() {
pinMode(servoPin, OUTPUT); //steering pin is set to output
servopulse(servoPin, 90); //Turn it to 90 degrees
delay(300); //delay 0.3S
}
void loop() {

}
c++
int servoPin = 9; //Define the pins of the steering gear

void servopulse(int pin, int myangle) { //Impulse function
int pulsewidth = map(myangle, 0, 180, 500, 2500); //Map Angle to pulse width
for (int i = 0; i < 5; i++) { //Output a few more pulses
digitalWrite(pin, HIGH);//Set the steering gear interface level to high
delayMicroseconds(pulsewidth);//Number of microseconds of delayed pulse width value
digitalWrite(pin, LOW);//Lower the level of steering gear interface
delay(20 - pulsewidth / 1000);
digitalWrite(pin, LOW);//Lower the level of steering gear interface
delay(20 - pulsewidth / 1000);
}
}

void setup() {
pinMode(servoPin, OUTPUT); //steering pin is set to output
servopulse(servoPin, 90); //Turn it to 90 degrees
delay(300); //delay 0.3S
}
void loop() {

}

Did you find this page helpful?