Task 1: Familiarisation.
In this task, you are requested to familiarise yourself with the Arduino environment.
Requirements:
- Obtain an Arduino Mega or Uno Board and connect it to the PC.
- From the computing, programmes select Arduino program.
- Activate the Arduino environment.
- From the drop, menu select, the Arduino board type from the Tools drop-down menu. (The Board used is Arduino Mega)
- From the same drop-down Menu select the COM port that communicates with the board.
- From File drop menu choose the “Example” and choose the “Digital” and choose the programme “Blink”
- Upload the program and go through the compilation process
- Upload the program and run it on the Arduino Board.
- You should see an LED Blinking on the Board.
- You can also use a Breadboard and link it up with the board and use an LED to see it Flashing
- Increase the number of lights to three and switch them serially. You need to modify the program to do this.
Task 2: Traffic light Simulation using ‘C’ language
In this lab activity, you are requested to simulate a real traffic light environment using the procedural language ‘C’.
Take the following steps to implement the required task:
- Obtain an Arduino Uno or Mega Board and connect it to the PC.
- From the computing, programmes select Arduino program.
- Using a graphical package, develop and draw a flowchart of a simple four-phase traffic light.
Part 1
Create a programme in “C” to simulate the four-phase traffic light and test its functionality.
Write a function to control each of the traffic lights E.g. void TrafficLight1 (int red, int amber, int green);
I. Use the serial port to simulate the pedestrian pressing the button
II. Both sets of traffic lights should be red for pedestrians to cross safely.
III. The pedestrian green LED should flash as a warning that the main lights are about to start up
IV. The main lights should sequence to and from pedestrian crossing mode in a safe and tidy sequence.
V. The state of the lights should be written to the serial port: E.g. L1 = ON, ON, OFF L2 = OFF, ON, OFF PED = ON, OFF means traffic light 1 is RED/AMBER, traffic light 2 is AMBER, a pedestrian crossing is RED
Part 2
- Modify the developed algorithm and produce a new flowchart to provide a solution for the operation of a junction with four ‘four-phase’ traffic lights.
- Implement the modified algorithm and a program in “C” to show its operation.
Part 3
- Modify the flowchart for the Junction and provide a new flowchart which provides a pedestrian crossing by using two LED red and green for each junction on either side of the road.
- Write a “C” program to implement the flowchart.
Task 3: Implementing Sorting algorithm using ‘C’
In this lab activity, you are requested to develop and apply two different sort algorithms to an array of fifty random numbers to sort them in ascending or descending order by writing a program using the procedural language ‘C’ to implement the algorithm. Comment on the efficiency of the algorithm used in terms of execution time.
Requirements:
- Obtain an Arduino Uno or Mega Board and connect it to the PC.
- From the computing, programmes select Arduino program.
- Draw a flowchart of an algorithm which sorts the array in ascending or descending order. The numbers are in the range of 0 to 255.
- The highest and the lowest numbers in the array should be displayed using eight L.E.Ds.
- The sorted array should be displayed on the serial monitor using a pointer.
- The sorting function should be triggered by keyboard input from the serial monitor.
- The numbers should be randomly generated.
|