3.3.1.4 Packet Tracer – SBC Actuate (Answers)

3.3.1.4 Packet Tracer – SBC Actuate With Python (Instructor Version)

Topology

3.3.1.4 Packet Tracer - SBC Actuate (Answers) 2

Objectives

Become proficient using Python to program Packet Tracer’s SBC device.

Background / Scenario

Python is wide-spread, robust and easy to programming language that runs on several different computer platforms. Packet Tracer 7.1 takes advantage of this and implements Python-supported IoT devices.

In this Packet Tracer activity you will program the Packet Tracer 7.1’s SBC device using Python. The goal is to allow a coffee maker to start brewing coffee when someone enters the kitchen (movement is detected). A countertop lamp will also turn on.

Required Resources

  • Packet Tracer 7.1 or newer.

Part 1: Adding and Connecting the Necessary Devices

You will start with an empty work space. Add the following devices to Packet Tracer’s work space:

a. A SBC device can be found under Components >> Boards >> SBC-PT.

b. A Coffee Maker can be found under End Devices >> Home >>Appliance.

c. A Counter Top Lamp can be found under End Devices >> Home>> Light.

d. A Motion Sensor can be found under Components >> Sensors >> Motion Sensor

e. Change the names of the devices to match the diagram.

f. Using IoT Custom Cable, connect the devices to the PT-SBC board. The IoT Custom Cable can be found under Connections.

Use the following table to find the correct ports:

Device SBC Port
Coffee Maker D1
Lamp D2
Motion Sensor D9

Part 2: Programming the SBC

The SBC mimics real-world single board computers such as the Raspberry Pi.

One of the advantages of SBC-PT is that it can be programmed with Python.

Note: Python used in PT is an open source Python to JavaScript interpreter that is not updating to Python 3.0. For this reason there may be slight differences in the syntax between the code observed in PT and that in devices using Python 3.

a. Click on the SBC and select the Programming tab.

Is there any code pre-loaded in the SBC?
____________________________________________________

The contents of the Programming tab are divided into two main parts. The left pane displays all the files containing the programs created by you. The right pane displays the contents of the file currently selected on the left portion. Click the New button above the left pane to create a new file. Name it main.py and select Empty – Python for the template type. Click Create. The left pane should now list your new file, main.py.

b. On the left pane, select main.py and click Open; the Open button is located immediately above the left pane. The right pane is now ready to receive the code for your main.py program.

c. Using the right pane, write a program to instruct the SBC to turn on the Coffee Maker and the Light when motion is detected by the Motion Detector.

Part 3: Testing

To test your code, first run the main.py by clicking Run. Then press the ALT key while moving the mouse over the Motion Sensor. This should signify movement to Packet Tracer which will be captured by the PTMotion Sensor. Once movement is detected, a HIGH digital signal is sent to the SBC which in turn, turns on the coffee maker and the light. Messages also appear in the console of the SBC.

Did the Coffee Maker turn on?
_______________________________________________________

Did the light turn on?
_______________________________________________________

What changes would have to be made in the SBC if the motion detector was moved to port D5?
_______________________________________________________

What PT-SBC port, if any, should be used to connect an analog sensor?
_______________________________________________________

Download 3.3.1.4 Packet Tracer – SBC Actuate


guest
0 Comments
Inline Feedbacks
View all comments