You are on page 1of 22

ELEC0002 – Microcontrollers and Embedded Programming Workshop November 2019

(previously referred to as ELEC101P)

Getting Started
This workshop will teach you the fundamentals of programming the Texas Instruments (TI) MSP432-
P401R launchpad (from this point onwards we shall refer to it as MSP432 for simplicity) using TI’s
Code Composer Studio (CCS) integrated development environment (IDE).

Note: This module was previously referred to as ELEC101P.

To get started, download the lab script from the ELEC002 Moodle page (scroll down to the topic
Microcontrollers and Embedded Programming):
https://moodle.ucl.ac.uk/course/view.php?id=2377

ADVICE: There are supporting documents for this workshop on Moodle. Please read them!
Table of Content

TASK 1 – BASICS............................................................................................................................................ 2
DIGITAL OUTPUTS.....................................................................................................................................................2
SERIAL COMMUNICATION...........................................................................................................................................4
DIGITAL INPUTS........................................................................................................................................................6
TASK 2 – ANALOGUE TO DIGITAL CONVERSION (ADC)...................................................................................8
ADDITIONAL HARDWARE............................................................................................................................................8
CONNECTING THE POT TO THE MSP432......................................................................................................................8
CONVERT AN ANALOGUE INPUT TO A DIGITAL SAMPLE.....................................................................................................9
TASK 3 – PULSE WIDTH MODULATION (PWM)............................................................................................. 11
USING LEDS TO DEMONSTRATE THE PWM CONCEPT...................................................................................................11
ADVANCED (OPTIONAL) EXERCISES.............................................................................................................................13
TASK 4 – DRIVING A HIGH-CURRENT LOAD (A MOTOR)................................................................................14
ADDITIONAL HARDWARE..........................................................................................................................................14
SYSTEM SETUP.......................................................................................................................................................15
PROGRAMMING THE MSP432 TO DRIVE THE MOTOR...................................................................................................20

R C Grammenos Page 1
ELEC0002 – Microcontrollers and Embedded Programming Workshop November 2019
(previously referred to as ELEC101P)

Task 1 – Basics
This task will teach you the basics of using the digital inputs and outputs on the MSP432, in
particular the use of LEDs and push buttons. It will also teach you how to use the serial
communication port to print data to the Serial Terminal in CCS.

Digital Outputs

Blink an LED

Learning outcome: Learn how to program your MSP432 to toggle an LED between ON/OFF states.

 During the setup procedure, you managed to blink the red colour of the RGB LED (LED2) on the
MSP432. If you have not completed this procedure, then please refer to the document called
“Setting up CCS and workspace”.
 For a detailed explanation of the Energia sketch used in the setup procedure (“Blink.ino”), please
refer to the document called “Read Me_ELEC0002_Microcontrollers”.

EXERCISES

1. Swap LEDs.

 Click on the CCS Simple icon located in the top-right corner of the CCS environment to
return to the main CCS workspace page.
 Close the sketch Blink.ino (which should be currently open if you followed the setup procedure
properly).
 Click on Project -> New Energia Sketch. Call the new project “Blink_SwapLEDs”. Select the
Blink.ino sketch from the Built-in examples. Click Finish.
 Modify the code to blink LED1 (red LED on the left) instead of LED2. Make sure you pay attention
to the header file.

 Build the project and download the program to the MSP432. Refer to the setup procedure
document if you are not sure how to do this.
 If you are successful, then you should see LED1 toggling on and off at a rate of approximately
once per second.

2. Toggle LEDs.

 Following the same procedure as above, close the current sketch and create a new sketch called
"Blink_ToggleLEDs".
 Modify the code to toggle both LEDs (LED1 and LED2) with a one second delay. In other words,
every second, the Launchpad should turn one LED on (for example, LED1) while turning the
other LED off (for example, LED2).
 Hint: You will need to change the name definitions and modify the setup routine to enable both
LEDs.

R C Grammenos Page 2
ELEC0002 – Microcontrollers and Embedded Programming Workshop November 2019
(previously referred to as ELEC101P)

3. Use pin numbers.

 Create a new sketch called "Blink_UsePinAliases".


 Modify the code to carry out the same operation as in exercise (2) – Toggling both LEDs – but
this time using physical pins. Comment out both #define lines (to disable these commands)
and operate the LED1 using the physical pin number (pin 78) and the green colour on LED2 using
the pin number 76.

QUESTION

 Why would you not use this approach in practice (in other words, using the physical pin or alias
rather than defining the LED as a variable)?

R C Grammenos Page 3
ELEC0002 – Microcontrollers and Embedded Programming Workshop November 2019
(previously referred to as ELEC101P)

Serial Communication

Learning outcome: Use the Serial Terminal in CCS.

 Create a new sketch in CCS and select the ASCIITable.ino which can be found under Built-in
Examples > 04. Communication.
 Click on the Open a terminal icon in the menu bar and select the Serial Terminal option with
the following configuration:
o Serial port: Select your UART COM port (see the setup procedure document if you have
not already identified this). In this example, the UART port is COM4 but this will very
likely be different on your machine.
o Baud rate: 9600.

 A Terminal should then open at the bottom of your workspace.

 Build the project and download the program to the MSP432 board. You should see the following
text printed in the Terminal that you just opened. If you do not see the terminal you can click on
the terminal icon (which is usually located on the right side of your workspace).

R C Grammenos Page 4
ELEC0002 – Microcontrollers and Embedded Programming Workshop November 2019
(previously referred to as ELEC101P)

EXERCISES

4. Modify the baud rate.

 Change the baud rate in the code to 115200.


 You will also need to change the Terminal settings to reflect the increased baud rate. If you do
not, then you will find that the characters are not printed properly.
 Reprogram the MSP432 board with the updated settings. If successful, then the ASCII table
should be printed properly in the Serial Terminal.

R C Grammenos Page 5
ELEC0002 – Microcontrollers and Embedded Programming Workshop November 2019
(previously referred to as ELEC101P)

Digital Inputs

Learning outcome: Use the push buttons on the Launchpad and debounce them properly.

Using the push buttons

 Create a new sketch in CCS and select the DigitalReadSerial.ino which can be found under Built-
in Examples > 01. Basics.
 Change the value of the pushButton variable to use PUSH1.
 Change the baud rate to 115200.
 Increase the timing between reads to 0.25 seconds for improved readability.
 Build the project and download the program to the MSP432 board.
 Open a terminal and start pressing the push button PUSH1 (S1) located in the middle-left of the
board. Pressing the push button prints a zero (‘0’) to the monitor.

 If successful, you should get an output similar to the one illustrated in the screenshot below
when you press the pushbutton S1.

QUESTIONS

 Why does pressing the push button print a zero (‘0’) to the Terminal instead of a one (‘1’)?
 What is the issue with this programme when pressing the push button?

R C Grammenos Page 6
ELEC0002 – Microcontrollers and Embedded Programming Workshop November 2019
(previously referred to as ELEC101P)

Debouncing the push buttons

 From the Moodle page, within the Workshop Documents folder, download the zip file called
“DigitalReadSerial_PrintOnPress_EXERCISE”.
 Extract the contents of the zip file to your working folder on your desktop.
 In this extracted folder, you will find two files. One is a sketch called
“DigitalReadSerial_PrintOnPress_EXERCISE”. The other is a text file called
“DigitalReadSerial_ListOfCommands”.
 Create a new empty Energia sketch in CCS and name it DigitalReadSerial_PrintOnPress.
 Copy the contents of the template “DigitalReadSerial_PrintOnPress_EXERCISE” and paste them
in the new empty sketch that has been created.

EXERCISE

5. Your task is to copy the commands provided in the file “DigitalReadSerial_ListOfCommands” and
paste them to the appropriate lines in the sketch “DigitalReadSerial_PrintOnPress_EXERCISE”.

 The comments in the sketch should help you decide where to place the different commands.
 Ensure that the baud rate in your code matches the baud rate in your Serial Terminal settings.
 Once you have completed the sketch and uploaded it to your MSP432:
o You should see an output in your Serial terminal like the one illustrated in the
screenshot below.
o Pressing the push button should print a zero (‘0’) to the monitor while releasing the push
button should print a one (‘1) but only once (not continuously).
o Furthermore, when you press the push button, the red LED should turn OFF while the
green LED should turn ON. Releasing the push button should have the opposite effect.

END OF TASK 1 - BASICS

R C Grammenos Page 7
ELEC0002 – Microcontrollers and Embedded Programming Workshop November 2019
(previously referred to as ELEC101P)

Task 2 – Analogue to Digital Conversion (ADC)


This task will show you how to read an analogue input, convert it to a digital sample and display the
result in the serial terminal.

Additional Hardware

For this task (Task 2), you will require the following hardware in addition to your MSP432:

 A one kilo ohm (1 kΩ) potentiometer (also known as a “pot”).


 Three female-to-female jumper wires to connect the potentiometer to the MSP432.

ADVICE: Please obtain these components from the relevant toolboxes in the lab. Ask a member of
staff if you have any questions or are encountering any problems.

Connecting the pot to the MSP432

Learning outcome: Connect an external analogue device to your MSP432.

 Connect the middle pin of the pot to physical pin 33 on the MSP432 (P5.1). This corresponds to
analogue input A4 (yellow wire in image below).
 Connect the pot’s edge pins to physical pin 1 (+Vcc, red wire) and physical pin 20 (GND, black
wire) on the MSP432.

R C Grammenos Page 8
ELEC0002 – Microcontrollers and Embedded Programming Workshop November 2019
(previously referred to as ELEC101P)

R C Grammenos Page 9
ELEC0002 – Microcontrollers and Embedded Programming Workshop November 2019
(previously referred to as ELEC101P)

Convert an analogue input to a digital sample

Learning outcome: Convert a reading from an analogue device to a digital sample on the MSP432.

 Create a new sketch in CCS and name it “AnalogReadSerial_WithPot_NoConversion”.


 Select the AnalogReadSerial.ino sketch which can be found under Built-in Examples > 01. Basics.

Reading from a pot

EXERCISES

1. From Analogue to Digital.

 Modify the code to read an analogue input on pin A4 rather than A3.
 Increase the delay to 0.5 seconds.
 Remember to set the baud rate in your code to the same settings as for the Serial Terminal.
 Build the project and download the program to the MSP432 board.
 You should see an output similar to the following in the Serial Terminal window when turning
the knob on the pot.

QUESTIONS

 What are the minimum and maximum values you are obtaining when turning the knob on the
pot from one end to the other (in other words, turning the knob from all the way clockwise to all
the way anti-clockwise)?
 Why are you getting these values?

R C Grammenos Page 10
ELEC0002 – Microcontrollers and Embedded Programming Workshop November 2019
(previously referred to as ELEC101P)

Convert the pot reading to its corresponding voltage value

Learning outcome: Convert a digital sample to the actual voltage value corresponding to the reading
acquired from the analogue device.

Recall: In the previous subtask, we printed the digital sample corresponding to the analogue voltage
to the serial terminal. This digital sample, however, is not the real-world value. Hence, in this
subtask, we will convert the digital sample to the actual, real-world voltage value corresponding to
the analogue reading from the pot.

WARNING: Note that the voltage on an (input) analogue pin on the MSP432 can vary from 0V up to
a maximum of 3V (in other words, the voltage applied to the pin should not exceed 3V).

 Create a new empty sketch in CCS and name it “AnalogReadSerial_WithPot_WithConversion”.


 Copy the code from the previous sketch “AnalogReadSerial_WithPot_NoConversion” to the new
sketch.

EXERCISES

2. Add a new variable in the loop routine called “voltage” of type “float” (not “int”). This will allow
decimal points to be printed in the serial terminal window.
3. Set the voltage value to equal the product of the pot reading (digital sample obtained in the
previous subtask) times the maximum input voltage (3.0) divided by the maximum value that the
pot reading can take (1023.0). Ensure you include the decimal points, for example, “3.0” not “3”.
4. Add new commands to print both the pot reading (“sensorValue”) and the converted voltage
(“voltage”) to the serial terminal.

 Build the project and download the program to the MSP432 board.
 Your output should resemble that shown in the following screenshot.

ADVICE: You need to use floating point numbers to support decimal points. For more information,
see https://energia.nu/reference/en/language/variables/conversion/floatcast/

QUESTION
 What is the smallest amount of “voltage change” that can be represented in this scenario?

END OF TASK 2 - ADC


R C Grammenos Page 11
ELEC0002 – Microcontrollers and Embedded Programming Workshop November 2019
(previously referred to as ELEC101P)

Task 3 – Pulse Width Modulation (PWM)


This task will demonstrate pulse width modulation (PWM). Subsequently, in Task 4, PWM will be
used to adjust the speed of a motor. Please refer to the lecture notes to refresh your knowledge of
PWM.

Note: Leave the potentiometer connected to the MSP432.

Using LEDs to demonstrate the PWM concept

Learning outcome: Understand how PWM works by adjusting an LED’s brightness levels (fading).

 Create a new sketch in CCS and name it “Fading_DemoPWMusingLED”.


 Select the Fading.ino sketch which can be found under Built-in Examples > 03. Analog.

Set the LED pin and observe the PWM effect

EXERCISES

1. Read the code and the comments carefully. The variable “fadeValue” is essentially the PWM
duty cycle.
2. Modify the code so that the variable “ledPin” represents the green LED on the MSP432.

 Build the project and download the program to the MSP432 board.
 Then hold your Launchpad in your hand and start shaking it left and right (or back and forth).
 While shaking the Launchpad, you should see green dots turning into green dashed lines and
finally into a green straight line and back to the beginning again. This is equivalent to modifying
the duty cycle, as shown on the Energia website:

“Once you get this example running, grab your LaunchPad and shake it back and forth. What you are
doing here is essentially mapping time across the space. To our eyes, the movement blurs each LED
blink into a line. As the LED fades in and out, those little lines will grow and shrink in length. Now you
are seeing the pulse width.”

R C Grammenos Page 12
ELEC0002 – Microcontrollers and Embedded Programming Workshop November 2019
(previously referred to as ELEC101P)

Use the pot with PWM to fade the LED according to the input voltage

 Create a new empty sketch in CCS and name it


“AnalogReadSerial_WithPot_WithConversion_FadeLED”.
 Copy the code from the previous sketch “AnalogReadSerial_WithPot_NoConversion” to the new
sketch.

EXERCISE

3. Add commands to this code (with the aid of the previous subtask “Fading_DemoPWMusingLED”)
so that the green LED is faded at different levels according to the reading from the
potentiometer.

Hints:
 You need to initialise an LED pin, configure its pin mode in the setup routine and finally write to
this LED pin in the loop routine.
 The potentiometer reading ranges from 0 to 1023 (10-bit) while the PWM duty cycle step ranges
from 0 to 255 (8-bit). You will need to scale the pot reading accordingly to obtain a proper fading
level for the LED.

WARNING: You need to ensure the brackets are in the right place. First you need to carry out the
scaling of 256 over 1024 before multiplying with the pot reading, otherwise you will get an overflow
generating incorrect results!

 Build the project and download the program to the MSP432 board.
 Now start turning the knob on the pot left and right (from one end to the other end).
 In addition to seeing the pot readings and corresponding values in the serial terminal, you
should also notice that the fading level of the green LED changes as we turn the knob on the
potentiometer left and right.

R C Grammenos Page 13
ELEC0002 – Microcontrollers and Embedded Programming Workshop November 2019
(previously referred to as ELEC101P)

Advanced (optional) exercises

Learning outcome: Optimise the function routines used in the sketches in the previous exercises.

Use the function “map” to scale values

 Create a new empty sketch in CCS and name it


“AnalogReadSerial_WithPot_WithConversion_FadeLED_Map”.
 Copy the code from the previous sketch “AnalogReadSerial_WithPot_WithConversion_FadeLED”
to the new sketch.

EXERCISES

4. Use the Energia function “map” to scale the “analogRead” values – ranging from 0 to 1023 – to
the “analogWrite” values – ranging from 0 to 255.
5. In the previous subtasks, you should have noticed that there was a delay in between turning the
knob on the pot (in other words, changing the voltage value) and observing the corresponding
fading effect on the LED. Modify the code to remove this delay while still maintaining the
readability of the pot and voltage readings in the serial terminal.

 Build the project and download the program to the MSP432 board.
 You should notice that the fading effect is immediately visible when turning the pot knob.

END OF TASK 3 - PWM

R C Grammenos Page 14
ELEC0002 – Microcontrollers and Embedded Programming Workshop November 2019
(previously referred to as ELEC101P)

Task 4 – Driving a high-current load (a motor)


This final task looks at combining all the knowledge acquired in the previous three tasks to drive and
control the speed of a motor1.

Additional Hardware

For this task (Task 4), you will require the following hardware in addition to the MSP432 and the
components you used in the previous tasks:

 A solderless breadboard.
 Male-to-female jumper wires to connect the components from the breadboard to the MSP432.
 One diode (ideally a power diode) to provide protection against reverse current.
 A BS170 n-type MOSFET transistor.
 A direct current (DC) motor.
 An external power supply unit (PSU) rated at 5V or more.

ADVICE:

 Please obtain these components from the relevant toolboxes in the Electronics Teaching Lab –
Roberts 610. Ask a member of staff if you have any questions or are encountering any problems.
 An external power supply is available on each bench in Lab 610 and Lab 905 but not in Lab 704.
Hence, you will need to be based in Lab 610 or Lab 905 if you wish to use a bench power supply
for this task. If you are based in Lab 704, you will need to use a portable USB laboratory (such as
the National Instruments myDAQ or Analog Discovery II) which will provide you with a suitable
power supply source.

1
A good and detailed tutorial showing a similar setup for an Arduino Uno is available at the following link:
https://itp.nyu.edu/physcomp/labs/motors-and-transistors/using-a-transistor-to-control-high-current-loads-
with-an-arduino/

R C Grammenos Page 15
ELEC0002 – Microcontrollers and Embedded Programming Workshop November 2019
(previously referred to as ELEC101P)

System setup

Learning outcome: Connect all devices and components to the MSP432 to form a complete system.

WARNING: This is the most time-consuming and challenging aspect of this final task (Task 4). Please
follow the steps below carefully to setup all elements correctly.

1. First, disconnect the potentiometer and all three wires from the MSP432.
2. Connect physical pin 1 (Vcc) and physical pin 20 (GND) on the MSP432 to opposite side rails on
the breadboard, as shown in the schematic below:

 In this particular example, the breadboard has ten columns (A to J) and 30 rows (1 to 30). The
columns for each row are connected between them while the rows themselves are independent.
The only exception to this are the side rails to which Vcc (red wire) and GND (black wire) are
connected to. For the side rails, the rows are connected between them while the two columns
are independent.

3. Plug the potentiometer onto the breadboard across three rows, for example, rows 10-12.
Connect the pot’s middle pin directly to physical pin 33 (P5.1) on the MSP432. Then connect the
pot’s edge pins to the Vcc and GND side rails on the breadboard, as shown in the schematic
below:

R C Grammenos Page 16
ELEC0002 – Microcontrollers and Embedded Programming Workshop November 2019
(previously referred to as ELEC101P)

 Now we are going to place the transistor onto the breadboard. Use a BS170 n-type MOSFET
transistor. With the flat side of the transistor facing up, as shown in the image below:

‘D’ stands for drain, ‘G’ stands for gate and ‘S’ stands for source.

One of the main functions of a transistor is to act as a switching device. By applying a HIGH
(+Vcc) or LOW (GND) voltage to the gate (G) of the transistor, we are allowing (HIGH) or blocking
(LOW) current to flow from the drain to the source, thereby turning the device, to which the
transistor is connected to, either ON or OFF. MOSFET stands for Metal Oxide Semiconductor
Field Effect Transistor. For more information on the BS170, have a look at the datasheet
available at the link below: https://www.fairchildsemi.com/datasheets/BS/BS170.pdf

4. Plug the transistor on the breadboard, for example onto rows 20-22, with the flat side facing
towards the MSP432 board, as shown in the schematic below. Connect the source (S) pin of the
transistor to the GND side rail and the gate (G) pin of the transistor to physical pin 11 (P3.6) on
the MSP432.

WARNING: It is very important that you plug in the transistor correctly. Otherwise you might
damage the MSP432 or other components.

R C Grammenos Page 17
ELEC0002 – Microcontrollers and Embedded Programming Workshop November 2019
(previously referred to as ELEC101P)

ADVICE: The following steps are very important. Please ask a member of staff to help you out if you
are not sure how to wire up the devices and components.

5. Now we are going to connect the motor. Connect the ground terminal of the motor (this is the
black wire of the actual motor you are using, but it is shown as yellow in this schematic) to the
drain (D) pin of the transistor, as shown in the schematic below. Then connect the positive
terminal of the motor (this is the red wire of the actual motor you are using, but it is shown as
green in this schematic) to a hole of a free row on the breadboard (for example, row 5) which is
not being used by any other component or wire, again as shown in the schematic below.

 Now we are going to add a diode in parallel with the motor to provide protection against reverse
current. As shown in the images below2, the anode corresponds to the positive (+ve) side while
the cathode corresponds to the negative (-ve) side. If using a diode with a stripe mark as shown
in the diagram below, then the stripe denotes the cathode. If you are using an LED, the longer
leg denotes the anode (+ve) side while the shorter leg denotes the cathode (-ve) side.

2
The images are courtesy of https://itp.nyu.edu/physcomp/labs/motors-and-transistors/using-a-transistor-to-
control-high-current-loads-with-an-arduino/

R C Grammenos Page 18
ELEC0002 – Microcontrollers and Embedded Programming Workshop November 2019
(previously referred to as ELEC101P)

6. Connect the diode’s anode to a hole on the same row on the breadboard where the motor’s
ground terminal (black wire) and transistor’s drain (D) pin are connected, as shown in the
schematic below (row 20 on the breadboard in this example). Then connect the diode’s cathode
to a hole on the same row on the breadboard as the motor’s positive terminal (red wire) (row 5
on the breadboard in this example):

 Finally, we are going to connect a DC power supply (use the lab’s bench power supply or an
external portable USB laboratory) to the breadboard.

ADVICE: Ask a member of staff or PGTA to help you with this step if you are unsure.

7. WARNING: Ensure the power supply is OFF before you continue.

Connect the power supply’s ground terminal (black) to the GND side rail on the breadboard, as
shown in the schematic below. Then connect the power supply’s positive terminal (red) to a hole
on the same row on the breadboard where the motor’s positive terminal (red wire) and diode’s
cathode pin are connected (row 5 on the breadboard in this example):

R C Grammenos Page 19
ELEC0002 – Microcontrollers and Embedded Programming Workshop November 2019
(previously referred to as ELEC101P)

 The circuit is now complete and all devices and components should now be wired to each other.
 Turn the voltage and current knobs on the power supply anti-clockwise all the way to the left to
zero.

 Now turn the power supply ON.


 Then turn the voltage knob clockwise until it reaches 3V.
 You will increase the current once you have programmed the MSP432 in the next subtask.

R C Grammenos Page 20
ELEC0002 – Microcontrollers and Embedded Programming Workshop November 2019
(previously referred to as ELEC101P)

Programming the MSP432 to drive the motor

Powering and controlling the motor

Learning outcome: Learn how to use the external power supply to power the motor but to control
the motor from the MSP432.

 Create a new empty sketch in CCS and name it “MotorOnOff”.

EXERCISES

8. Write code to turn the motor ON and OFF every second.

Hint: To achieve this objective, you will first need to assign a variable to the pin to which the
gate of the BS170 transistor is connected to. Subsequently, you will need to set this pin as an
output in the setup routine and then use “digitalWrite” to control the motor in the loop routine.

 Build the project and download the program to the MSP432 board.
 Now slowly turn the current knob on the power supply to the right in a clockwise direction until
the motor reaches a reasonable speed. The motor should turn on and off every second.

WARNING: The motor requires a fairly high voltage to start operating. If you find that by turning
the knob on the pot at either end, the motor is not starting, please ask a member of staff to help
you. Do not use your fingers to get the motor going!

9. Add code to turn the red LED ON and OFF at the same time that the motor turns ON and OFF.

 Build the project and download the program to the MSP432 board.
 Both the red LED and the motor should turn ON and OFF every second.

R C Grammenos Page 21
ELEC0002 – Microcontrollers and Embedded Programming Workshop November 2019
(previously referred to as ELEC101P)

Adjusting the speed of the motor

Learning outcome: Learn how to adjust the speed of the motor using a potentiometer and with the
aid of PWM.

 Create a new empty sketch in CCS and name it “MotorOnOff_WithLED_WithPot”.


 Copy the code from the previous sketch “MotorOnOff” to the new sketch.

EXERCISE

10. By referring to the sketches of the previous three tasks (Tasks 1, 2 and 3), write code to control
the speed of the motor.

Hints:
 The speed is controlled using PWM. The duty cycle of PWM in turn is controlled by the
potentiometer.
 For a standard ON/OFF operation, we use the function digitalWrite(). To vary the voltage
supplied to a pin, we use the function analogWrite().

 Build the project and download the program to the MSP432 board.
 The fading effect of the LED and the speed of the motor should vary according to the value of
the analogue reading set by the potentiometer.

END OF TASK 4 – DRIVING A MOTOR

R C Grammenos Page 22

You might also like