Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: mbed
exam.cpp
- Committer:
- el16ttb
- Date:
- 2019-04-16
- Revision:
- 3:9fd187c3fd38
- Parent:
- 2:f56d6bd8aa25
File content as of revision 3:9fd187c3fd38:
#include "exam.h" // Task 1 // Hold A to turn the Red LED on. Let go to turn off // (3 marks) void Task1(TestAdmin &tester, PwmOut &r_led, DigitalIn &button_a){ // Code here that executed at the start of the task while(tester.testRunning()){ // Run until button D is pressed // Code here that executed continously during the task } } // Task 2 // A - > Red, B -> Green, C -> Blue: Hold to turn on, release to turn off // (3 marks) void Task2(TestAdmin &tester, PwmOut &r_led, PwmOut &g_led, PwmOut &b_led, DigitalIn &button_a, DigitalIn &button_b, DigitalIn &button_c){ // Code here that executed at the start of the task while(tester.testRunning()){ // Run until button D is pressed // Code here that executed continously during the task } } // Task 3 // Blue LED is the XOR of A and B // (i.e. LED is on only when either of the buttons are pressed but not if both) // (3 marks) void Task3(TestAdmin &tester, PwmOut &b_led, DigitalIn &button_a, DigitalIn &button_b){ // Code here that executed at the start of the task while(tester.testRunning()){ // Run until button D is pressed // Code here that executed continously during the task } } // Task 4 // Print the temperature measured with the temperature sensor as an integer over serial (using the following formula: 100 V - 50) // Print every value in a new line // (3 marks) void Task4(TestAdmin &tester, AnalogIn &temp){ // Code here that executed at the start of the task while(tester.testRunning()){ // Run until button D is pressed // Code here that executed continously during the task } } // Task 5 // Green LED if the LDR can see light, Red LED if the LDR is covered // (3 marks) void Task5(TestAdmin &tester, PwmOut &r_led, PwmOut &g_led, AnalogIn &ldr){ // Code here that executed at the start of the task while(tester.testRunning()){ // Run until button D is pressed // Code here that executed continously during the task } } // Task 6 // Pot0 -> Red, Pot1 -> Green, Pot2 -> Blue: use the potentiometers to set the brightness of each LED // between fully off (when turned all the way to the left) and fully on (when turned all the way to the right) // (3 marks) void Task6(TestAdmin &tester, PwmOut &r_led, PwmOut &g_led, PwmOut &b_led, AnalogIn &pot_0, AnalogIn &pot_1, AnalogIn &pot_2){ // Code here that executed at the start of the task while(tester.testRunning()){ // Run until button D is pressed // Code here that executed continously during the task } } // Task 7 // Toggle the Red LED i.e. Press A to turn on, press again to turn off // (4 marks) void Task7(TestAdmin &tester, PwmOut &r_led, DigitalIn &button_a){ // Code here that executed at the start of the task while(tester.testRunning()){ // Run until button D is pressed // Code here that executed continously during the task } } // Task 8 // Display the following pattern on repeat on the LEDs with a 0.5s delay // 0: | O | | | | // 1: | | O | | | // 2: | | | O | | // 3: | | | | O | // 4: | | | O | | // 5: | | O | | | // (4 marks) void Task8(TestAdmin &tester, BusOut &leds){ // Code here that executed at the start of the task while(tester.testRunning()){ // Run until button D is pressed // Code here that executed continously during the task } } // Task 9 // Display the following pattern on the seven segmented display // // | | // |___| // | | // | | // (4 marks) void Task9(TestAdmin &tester, ShiftReg &shift){ // Code here that executed at the start of the task while(tester.testRunning()){ // Run until button D is pressed // Code here that executed continously during the task } } // Task 10 // Use the joystick to set the following patterns on the seven segmented display // (5 marks) void Task10(TestAdmin &tester, ShiftReg &shift, AnalogIn &joy_v, AnalogIn &joy_h){ // Code here that executed at the start of the task while(tester.testRunning()){ // Run until button D is pressed // Code here that executed continously during the task } }