Error within Bubble Machine coding

hello! :slight_smile:

I am currently working on a project for uni where I am making a bubble machine;
I have found the coding online and I am using an Arduino Uno board but when I try using the coding, I get the following error:

"Error compiling for board Arduino/Genuino Uno."

Any ideas as to what the issue could be? :confused:

Here is the code:

#include <AFMotor.h>

#include <Servo.h>


Servo panServo;
Servo tiltServo;
AF_DCMotor motor(4, MOTOR12_1KHZ); // create motor #4, 1 KHZ

byte pos = 0; // variable to store starting servo position

void setup() {
  panServo.attach(9); //pan servo on pin 9
  tiltServo.attach(10); //tilt servo on pin 10
  panServo.write(90); //added this for second sketch 
  tiltServo.write(90); // hoping to halt wild start up swing
  motor.setSpeed(230); // set dc motor speed to 254 of 0-255 range
}

void loop() {
  for(pos = 0; pos < 180; pos += 1) { //servo moves 0 degrees to 180 degrees in steps of 1 degree
    panServo.write(pos); // tell servo to go to position in variable 'pos'
    delay(15); 
  }
  for(pos = 0; pos < 90; pos += 1) { //tilt servo moves 45 degrees down
    tiltServo.write(pos);
    delay(15); // waits 15ms for servo to reach 90 degrees
    //delay(500); // holds in bubble solution half second
  }
  for(pos = 90; pos >= 1; pos -= 1) { // tilt servo raises and levels off
    tiltServo.write(pos);
    delay(15);
  }
  for(pos = 180; pos >=1; pos -= 1) { // pan servo swings wand around towards fan
    panServo.write(pos);
    delay(15);
  }

  motor.run(FORWARD); //turn on dc motor

  delay(3000); // pan servo hold at fan for a couple of seconds

  Servo refresh(); //refresh and begin again

  motor.run(RELEASE); // dc motor to stop
}

There is absolutely no way we can help you based on such an incredibly vague description. Do you see that black console window at the bottom of the Arduino IDE window? Scroll all the way to the top of that window and read the actual error messages you will find there. That's the important information for troubleshooting.

When you encounter an error you'll see a button on the right side of the orange bar "Copy error messages". Click that button. Paste the error in a message here USING CODE TAGS (</> button on the toolbar).

Sorry, its the first time I am posting on this forum so I am unsure how it works..

Here is the error:

Arduino: 1.8.5 (Windows Store 1.8.10.0) (Windows 10), Board: "Arduino/Genuino Uno"

C:\Users\laure\Documents\Arduino\sketch_mar30a\sketch_mar30a.ino:1:21: fatal error: AFMotor.h: No such file or directory

 #include <AFMotor.h>

                     ^

compilation terminated.

exit status 1
Error compiling for board Arduino/Genuino Uno.

This report would have more information with
"Show verbose output during compilation"
option enabled in File -> Preferences.

That error means you didn't install the AFMotor library:

You should note the documentation says:

This library is old and deprecated - and the hardware disconinued years ago. V2 of the shield uses i2c only and works with anything that has I2C support (e.g. all arduinos) without endless incompatibilities and porting requirements! :slight_smile:
-> Adafruit Motor/Stepper/Servo Shield for Arduino v2 Kit [v2.3] : ID 1438 : $19.95 : Adafruit Industries, Unique & fun DIY electronics and kits

Thanks for the help, I will give it a go and see if it works.

It is somewhat working but there is no movement with regards to the fan - any ideas?

Now the next step is normally to provide some details of exactly what components you are using and a circuit diagram showing how they are connected and particularly how everything is powered.

But first...are you definitely using the (ancient) Adafruit Motor Shield Version 1, which is what that particular library is intended for?

Steve

This is the motor shield we purchased via amazon

We are basing this project off of a tutorial from youtube as well as information from this website, which is where we got the code from.

this is an image of our set up:

If you're trying to run everything from that weedy little 9V battery then that's your problem. They can't supply enough current for a motor. And the motor and servos should be powered separately never from the Arduino power pin.

The 9V battery may just run the Arduino on it's own. Rechargeable AA batteries work a lot better for motors and servos.

Steve