Professional Documents
Culture Documents
FACULTY OF ENGINEERING
DEPARTMENT OF ELECTRICAL AND ELECTRONICS
ENGINEERING
TEEE 3016P MICROCONTROLLERS AND APPLICATIONS
LAB 1: ARDUINO DIGITAL INPUT & OUTPUT
GROUP MEMBERS
NAME REG NO
MANAGER HAMIM BRAN 17/U/252/ETD/GV
ANDEBO HILLARY 17/U/246/ETD/GV
AYIKOBUA GILBERT 17/U/247/ETD/GV
LAB 3. INTRODUCTION TO LIBRARIES
Part 1:
Source Code
//ANDEBO HILLARY 17/U/246/ETD/GV
//AYIKOBUA GILBERT 17/U/247/ETD/GV
//MANAGER HAMIM BRAN 17/U/252/ETD/GV
#include <Servo.h>
Servo myservo; // create servo object to control a servo
// twelve servo objects can be created on most boards
void setup() {
myservo.attach(9); // 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
}
}
Observation
The servo motor rotates from 00 to 1800 in steps of 10 and after an elpase of 15ms it rotates back
from 1800 to 00 in steps of 10
Part 2:
Source Code
//ANDEBO HILLARY 17/U/246/ETD/GV
//AYIKOBUA GILBERT 17/U/247/ETD/GV
//MANAGER HAMIM BRAN 17/U/252/ETD/GV
#include <Servo.h>
Servo myservo1; // create servo object to control a servo
// twelve servo objects can be created on most boards
Servo myservo2;
int push_button = 8;