Вы находитесь на странице: 1из 4

University of Engineering and Technology, Lahore Spring 2016

PRACTICE PROBLEMS
Name : Date :
Regd-No :
OBJECTIVES:
To practice and learn the programming problems
DESCRIPTION:
For every programming problem, you will be required to do the following:
1. Create a block / flow diagram
2. Make a circuit diagram (only if required)
3. Write the pseudo code
4. Write the code according to any controller you are using (either Assembly or
C language)

Example Problem 1:
Consider an LED attached to pin 10 of the
controller. Write a code to flash the LED for 0.5
seconds after every 1 second.

Solution:
1. Flow Chart:

MCT-223: EMBEDDED SYSTEMS


1
Prac 1
University of Engineering and Technology, Lahore Spring 2016
2. Pseudo Code:
1) Make pin 10 an output pin
2) Make pin 10 HIGH
3) Call delay for 500ms
4) Make pin 10 LOW
5) Call delay for 1000ms

3. Programming Code
int LED = 10;

void setup()
{
pinMode(LED,OUTPUT); // makes pin10 an output pin
}

void loop()
{
digitalWrite(LED,HIGH); // making pin 10 HIGH
delay(500); // delay for 500ms
digitalWrite(LED,LOW); // making pin 10 LOW
delay(1000); // delay for 1000ms
}

Programming Problem 1: Traffic Lights


You are required to program a traffic light that cycles from ember to green with
different delays as given below.
1. EMBER remains ON for 30 seconds.
2. YELLOW turns ON along with EMBER after 25 seconds have passed, and
remains ON for 5 seconds.
3. GREEN turns ON for 20 seconds.
4. YELLOW turns ON after GREEN for 5 seconds.

MCT-223: EMBEDDED SYSTEMS


2
Prac 1
University of Engineering and Technology, Lahore Spring 2016
Programming Problem 2: Light Control
A room light is controlled by two switches (switchA and switchB) such that:
1. When only switchA is pressed, the light turns ON.
2. When only switchB is pressed, the light turns OFF.
3. When both switches are pressed together, the light turns ON for 10 seconds.

Programming Problem 3: LED Chaser


Eight LEDS are connected to the microcontroller. The LEDs should be switched ON
and OFF in a pattern such that they turn ON and OFF one after another after a delay of
500ms.

Programming Problem 4: Reading a Sensor Value


A light sensor is attached with the analog pin of your microcontroller.
1. Read the value from the sensor
2. Save the value in a variable named sensor_value
3. If the sensor value increases beyond 2.5V, indicate by turning ON a buzzer
attached to a digital pin of the microcontroller.

Programming Problem 5: Motor Speed Control


A motor is connected to a PWM pin of the microcontroller via a transistor (for
isolation). You are required to control the speed of the motor using PWM such that:
1. The speed is directly proportional to the analog output (0 5V) coming from a
potentiometer attached with an analog pin of the microcontroller.

Programming Problem 6: Binary UP/DOWN Counter


Two push buttons are connected in pull-up configuration to the digital pins of the
microcontroller. Eight LEDs are also connected to form a binary counter. The counter
works such that:
1. When button A is pressed, the counter increases its binary value by 1.
2. When button B is pressed, the counter decreases its binary value by 2.

Programming Problem 7: Servo Motor Control


You are required to control the angle of a servo motor such that the angle of the servo
horn is directly proportional to the position of a potentiometer connected to an analog
pin of the microcontroller.

MCT-223: EMBEDDED SYSTEMS


3
Prac 1
University of Engineering and Technology, Lahore Spring 2016
Programming Problem 8: LCD Control
A temperature sensor is connected to an analog pin of the microcontroller. Assume the
range of the sensor to be -100 to +100 oC, with the output ranging from 0 2V
proportional to the temperature.
You are required to interface an LCD showing the current value of temperature from
the sensor.

Programming Problem 9: Serial Communication


Two controllers are connected with each other over USART (serial communication).
Write the code for controller 1, which waits for receiving an ASCII character A from
controller 2, and then proceeds to reply (transmit) digits from 0 to 9 serially with a
delay of 1 seconds between successive transmissions.

Programming Problem 10: Glucose Diffusion System


You have been asked to design an embedded system to regulate glucose levels in the
body of someone with diabetes by continuously measuring the level of glucose and
dispensing doses of insulin based on those measurements. The chemical glucose sensor
generates 4-bit digital signal. The insulin infusion pump is controlled by a PWM signal.
The system has ON/OFF switch, RESET switch, alarm speaker and LCD for blood
glucose monitoring.

1. Show the general layout of the required system based on Arduino Uno Board?
2. Draw a flow chart for the desired operation of the system.
3. What type of C instructions suggested to be used to implement such system?

Pinout for LCD

MCT-223: EMBEDDED SYSTEMS


4
Prac 1

Вам также может понравиться