I'm new in programming and I don't understand the error


code: [select]
#include <newping.h>
#include <afmotor.h>
 
#define trigger_pin  13
#define echo_pin     11
#define max_distance 200
af_dcmotor motor(2, motor12_64khz); // create motor #2, 64khz pwm

 
newping sonar(trigger_pin, echo_pin, max_distance);
 
void setup() {
  serial.begin(115200);
  serial.begin(9600);           // set serial library @ 9600 bps
  serial.println("motor test!");
 
  motor.setspeed(255);     // set speed 200/255
}
 
void loop() {
  delay(50);
  unsigned int distanceincms = sonar.ping() / us_roundtrip_cm; // send ping, ping time in microseconds (us) , convert centimeters (cm)
  serial.println("distance: " + string(distanceincms) + "cm");
 
  if(distanceincms < 50) {
    motor.run(forward);
  } else {
    motor.run(release);
  }
}


could explain me error? want make dc motor move when distance less 50cm.

please give details of problem you're experiencing.

is error when compile sketch?

is error when upload sketch?

or code compiling , uploading correctly not working expect?

when encounter error you'll see button on right side of orange bar "copy error messages". click button. paste error in message here using code tags.


Arduino Forum > Using Arduino > Programming Questions > I'm new in programming and I don't understand the error


arduino

Comments

Popular posts from this blog

Flip address is out of range arduino uno r3

Arduino Uno not uploading

Indesign and MathType fonts