Goal of the Arduino Lab

Joselyn McDonald

You have the option to include Arduino technologies in your final project. Consider how light (via LEDs) or motion (via servo motors) might aid in communicating the effectivness of your Deep Sea Bot! 

Follow the tutorials below if you're new to Arduino, or explore on your own if you're experienced with the technology. Your goal is to consider how to Arduino to enhance your project.

Exercise 1: Turn a Servo Motor

Ryan Ferguson

Arduino Servo Lab

Instructions

1. Follow the diagram above to create your servo circuit.

2. Copy and paste the text below into your Arduino sketch. Run the sketch. 

///////////////////////

#include <Servo.h>


Servo myservo;  // create servo object to control a servo

// twelve servo objects can be created on most boards


int pos = 0;    // variable to store the servo position


void setup() {

  myservo.attach(11);  // attaches the servo on pin 9 to the servo object

}


void loop() {

  for (pos = 0; pos <= 180; pos += 1) { // goes from 0 degrees to 180 degrees

    // in steps of 1 degree

    myservo.write(pos);              // tell servo to go to position in variable 'pos'

    delay(15);                       // waits 15ms for the servo to reach the position

  }

  for (pos = 180; pos >= 0; pos -= 1) { // goes from 180 degrees to 0 degrees

    myservo.write(pos);              // tell servo to go to position in variable 'pos'

    delay(15);                       // waits 15ms for the servo to reach the position

  }

}

Exercise 2: LED Blink

Ryan Ferguson

Arduino Servo Lab

Instructions

1. Follow the diagram above to create your servo circuit.

2. Copy and paste the text below into your Arduino sketch. Run the sketch. 

///////////////////////

// the setup function runs once when you press reset or power the board

void setup() {

  // initialize digital pin LED_BUILTIN as an output.

  pinMode(13, OUTPUT);

}


// the loop function runs over and over again forever

void loop() {

  digitalWrite(13, HIGH);   // turn the LED on (HIGH is the voltage level)

  delay(1000);                       // wait for a second

  digitalWrite(13, LOW);    // turn the LED off by making the voltage LOW

  delay(1000);                       // wait for a second

}

Exercise 3: Fading an LED

Ryan Ferguson

Arduino Servo Lab

Instructions

1. Follow the diagram above to create your servo circuit.

2. Copy and paste the text below into your Arduino sketch. Run the sketch. 

///////////////////////

// the setup routine runs once when you press reset:

void setup() {

}


// the loop routine runs over and over again forever:

void loop() {


  for(int i=0; i<255; i++){

    analogWrite(11, i);

    delay(10);

  }

  for(int i=0; i>0; i--){

    analogWrite(11, i);

    delay(10);

  }

}

Prompt: As a class, we will review the basics of Arduino electronics by looking at this Tutorial together. If you have not downloaded the software yet, make sure to follow the Installation instructions.

Next, we'll test a few core ways to use an Arduino. We'll be looking at three circuit examples (found below and in the File -> Examples folders in the Arduino IDE): 

  1. LED blink
  2. Fading an LED
  3. Servo Sweep

You'll be asked to build the circuit in the diagram and copy and paste the code into your "sketch," which is what Arduino calls the programs that control the Arduino. Don't worry about memorizing any of this, but you should take notes, pay close attention, and HAVE FUN!