Vous êtes sur la page 1sur 5

1.

Objectives:
a. Learn to use the Arduino Integrated Development Environment (IDE).
b. Write and download the programs to the Arduino UNO R3 boards.
c. Calibrate and test the continuous rotation servomotors.
2. Equipment List
Equipment
Arduino UNO R3 Board
BOE - Robotics Shield
Kit (for Arduino)
Piezo Buzzer

Quantity
01

Description
Mcu Atmel 328P

01

Includes continuous rotation servo motor

01

3. Procedure and Design

Figure 1 Flow Chart for lab requirement 1

Figure 2 - Flow Chart for lab requirement 2

Figure 3 - Flow Chart for lab requirement 4

4. Circuit Diagram

Figure 4 Schematic Diagram for laboratory requirement 4

5. Program code
/*
**file name: blink_long_long_short_short_short.ino
**author: Danien Lopes
**version: 1.2
**Description: this program make the led blinks according to a following pattern long : for 1 sec per 2 sec|short: for 0.5 sec per
1 sec.
*/
//variable declaration
int led = 13;
void setup()
{
pinMode(led, OUTPUT);// configure pin 13 as a output
}
//main code
void loop()
{
int i=0, k=0; //initialize variables
//loop to blink twice
for(i=0; i<2;i++){
blink_long(1000,2000);
}
//loop to blink 3 short times
for(k=0;k<3;k++){
blink_short(500,1000);
}
}

//function to make led blink long time 1 sec per 2 sec


void blink_long(int t1, int t2)
{
digitalWrite(led,HIGH);
delay(t1);
digitalWrite(led,LOW);
delay(t2);
}
//function to make led blink short time 0.5 sec per 1 sec
void blink_short(int t3, int t4)
{
digitalWrite(led,HIGH);
delay(t3);
digitalWrite(led,LOW);
delay(t4);
}

Code for Lab requirement 1 long, long, short, short, short


/*
**file name: serial_print.ino
**author: Danien Lopes
**version: 1.0
**Description: this code prints in the serial monitor of arduino
the messagem "Hello World" with one second delay
between the messages.
*/
#define MESSAGE_MAX_LEN 20
//setup function- configure serial monitor to start
void setup ()
{
Serial.begin(9600); //opens serial port, sets data
//rate to 9600 bps
}
//loop function
void loop(){
char message[MESSAGE_MAX_LEN]; // define variable message as
//an array with 20 characters long
sprintf(message, "Hello World\n");
Serial.write(message);//print the message
delay(1000);//wait 1 second
}

Code for Lab requirement 2 Serial Monitor Hello World


/*
**file name: basic_navegation_foward_backward.ino
**author: Danien Lopes
**version: 1.1
**Description: This code make the robot goes foward at full-speed for 10 second an after goes backward at full-speed for 10
seconds
pin11: control signal to left servo
pin12: control signal to left servo
pin10: tone to the pieze buzzer
*/
// libraries
#include <Servo.h>
//auxiliary functions
void foward(unsigned int time);
void backward(unsigned int time);
void disableServos();
//variable
Servo servo_left;
Servo servo_right;

//setup function
void setup()
{
servo_left.attach(11);//attribute servo motor left to pin 11
servo_right.attach(12);// attribute servo motor right to pin 12

foward(10000);//full-speed forward function call with 10 seg argument


backward(10000);// full-speed backward function call with 10 seg argument
disableServos();// stop robot call funtion
}
void loop(){ //no repetition needed in this code
}
//full-speed foward function
void foward(unsigned int time)
{
servo_left.writeMicroseconds(1700);
servo_right.writeMicroseconds(1300);
delay(time);
}
//full-speed backward function
void backward(unsigned int time)
{
servo_left.writeMicroseconds(1300);
servo_right.writeMicroseconds(1700);
}
//hold position still
void disableServos()
{
servo_left.detach();//detach servo motor left from pin 11
servo_right.detach();//detach servo motor left from pin 12
}

Code for lab requirement 4 Basic Navigation

6. Observations and Results


During this laboratory, besides the fact that I already used the AVR mcu for other
applications in my University in Brazil. I had a chance to work with new proprieties
from Arduino IDE, such as serial monitor and servo library. Although we use the
Arduino-syntax to write the code, the logic used will be important in further
applications. Additionally, all expected outcomes were achieved in this first
laboratory.
7. Conclusion

As a conclusion, I would like to mention that, despite a certain prior knowledge, all
new concepts and different approach given the MCU during lessons were observed
during the practices proposed in laborario.
I would also like to point out that the entire facility expected to make use of the
Arduino platform was easily perceived, since the Arduino was designed to facilitate
the use of microcontrollers for not experts in the area.

Vous aimerez peut-être aussi