Dec50122 Embedded Robotics - Pw1 (Procedure)
Dec50122 Embedded Robotics - Pw1 (Procedure)
SESSION 1 2023/2024
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
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
2
b) Then, write the following code and compile and observe the result.
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
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);
}
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);
}
}