0% found this document useful (0 votes)
111 views5 pages

Dec50122 Embedded Robotics - Pw1 (Procedure)

Dec50122,Embedded Robotics pw1,Politeknik Seberang Perai (PSP)

Uploaded by

JustShareIt
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
0% found this document useful (0 votes)
111 views5 pages

Dec50122 Embedded Robotics - Pw1 (Procedure)

Dec50122,Embedded Robotics pw1,Politeknik Seberang Perai (PSP)

Uploaded by

JustShareIt
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
You are on page 1/ 5

ELECTRICAL ENGINEERING DEPARTMENT

SESSION 1 2023/2024

DEC50122 – EMBEDDED ROBOTIC

PRACTICAL WORK 1 : INTRODUCTION TO CONTROLLER

PRACTICAL WORK DATE :

LECTURER’S NAME:

GROUP NO. :
1 LEARNING OUTCOMES (LO):

a) CLO3: manipulate the application of sensor and actuator, robot identification and
communication during practical work based on land mobile robot design (P4, PLO5)

2 OBJECTIVE

At the ends of this session, students should able to

a) Describe the basic function of standard Arduino Microcontroller board


b) Configure the Arduino IDE to communicate with hardware
c) Write and execute the Arduino program
d) Know how to interface and control simple digital input/output devices such as an LED,
potentiometer and push button

3 THEORY

The Arduino UNO is the best board to get started with electronics and coding. If this is your first
experience tinkering with the platform, the UNO is the most robust board you can start playing
with. The UNO is the most used and documented board of the whole Arduino family. Arduino
Uno is a microcontroller board based on the ATmega328P (datasheet). It has 14 digital
input/output pins (of which 6 can be used as PWM outputs), 6 analog inputs, a 16 MHz ceramic
resonator (CSTCE16M0V53-R0), a USB connection, a power jack, an ICSP header and a reset
button. It contains everything needed to support the microcontroller; simply connect it to a
computer with a USB cable or power it with a AC-to-DC adapter or battery to get started.

1
LED

LEDs are small, powerful lights that are used in many different applications. It is as simple as
turning a light on and off. Establishing this important baseline will give you a solid foundation
as we work towards experiments that are more complex. To find out the polarity of an LED,
look at it closely. The shorter of the two legs, towards the flat edge of the bulb indicates the
negative terminal.

4 PROCEDURE

TASK 1: LED BLINKING

a) Connect the circuit as shown below.

2
b) Then, write the following code and compile and observe the result.

int red = 13;


int yellow =12;
int green =11;

void setup()
{
pinMode (red, OUTPUT);
pinMode (yellow, OUTPUT);
pinMode (green, OUTPUT);
}

void loop()
{
digitalWrite(red, HIGH);
delay(2000);
digitalWrite(red, LOW);
digitalWrite(yellow, HIGH);
delay(1000);
digitalWrite(yellow, LOW);
digitalWrite(green, HIGH);
delay(1000);
digitalWrite(green, LOW);
}

TASK 2 : BASIC VR

a) Build the circuit according to the schematic diagram, which can control the brightness of
the LED light by reading input voltage values through a potentiometer.

b) Connect the positive pole of the LED lamp to the current limiting resistor, connect the
other end of the resistor to the 10th pin of the development board, and connect the
negative pole of the LED lamp to the GND of the development board. Pin 1 and pin 3 of
the potentiometer are connected to the development board 5V and GND respectively,
and pin 2 is connected to the A0 pin of the development board.

3
c) Write the code, compile and observe the result

int ledPin = 10;


int readValue=0;
int ledValue=0;

void setup( )
{
pinMode(ledPin,OUTPUT);
Serial.begin(9600);
}
void loop()
{
readValue= analogRead(A0);
ledValue=map(readValue,0,1024,0,255);
Serial.println(readValue,DEC);//print the value to serial
analogWrite(ledPin, readvalue)
delay(100);
}

TASK 3 : PUSH BUTTON

a) Build the circuit according to the schematic diagram, which can set LED light
up when the button is pressed.

4
b) Write the code, compile and observe the result.
const int BUTTON = 2;
const int LED = 3;
int BUTTONstate = 0;

void setup()
{
pinMode(BUTTON, INPUT);
pinMode(LED, OUTPUT);
}

void loop()
{
BUTTONstate = digitalRead(BUTTON);
if (BUTTONstate == HIGH)
{
digitalWrite(LED, HIGH);
}
else{
digitalWrite(LED, LOW);
}
}

You might also like