116
Overview of the Circuit Playground Express https://learn.adafruit.com/adafruit-circuit-playground-express ASSESSMENT CRITERIA A B C Processes and production skills Processes and production skills Investigatin g and defining purposeful definition and decomposition of complex problems in terms of functional and non-functional effective definition and decomposition of complex problems in terms of functional and non-functional definition and decomposition of complex problems in terms of functional and non-functional - Defined functional non- functional requirements Generating and designing; producing and implementi ng purposeful design and evaluation of user experiences and algorithms effective design and evaluation of user experiences and design and evaluation of user experiences and algorithms - Designed User Experience and Algorithm purposeful design and proficient implementation of modular programs, including an object- oriented program, using algorithms and data structures involving modular functions that effective design and effective implementation of modular programs, including an object- oriented program, using algorithms and data structures involving modular functions that design and implementation of modular programs, including an object- oriented program, using algorithms and data structures involving modular functions that - Implemented with CircuitPython systematic testing and prediction of results and proficient implementation of digital solutions reliable testing and prediction of results and effective implementation of digital solutions testing and prediction of results and implementation of digital solutions - Tested Algorithm Evaluating discerning evaluation of information systems and their solutions in terms of risk, sustainability and potential for innovation and enterprise informed evaluation of information systems and their solutions in terms of risk, sustainability and potential for innovation and enterprise evaluation of information systems and their solutions in terms of risk, sustainability and potential for innovation and enterprise - evaluated Overview Tuesday, 26 March 2019 1:26 PM Embedded Systems Page 1

Overview - Through The Classroom Door...•Overview •What is CircuitPython? •Frequently Asked Questions •Installing Mu Editor •Installing CircuitPython •The CIRCUITPY Drive

  • Upload
    others

  • View
    4

  • Download
    0

Embed Size (px)

Citation preview

Page 1: Overview - Through The Classroom Door...•Overview •What is CircuitPython? •Frequently Asked Questions •Installing Mu Editor •Installing CircuitPython •The CIRCUITPY Drive

Overview of the Circuit Playground Express

https://learn.adafruit.com/adafruit-circuit-playground-express

ASSESSMENT CRITERIA

A B C

Processes and

production skills

Processes and

production skills

Investigating and

defining

purposeful definition and

decomposition of complex problems in terms of functional and non-functional

effective definition and

decomposition of complex problems in terms of functional and non-functional

definition and decomposition of complex problems in terms of functional and non-functional - Defined functional non-functional requirements

Generating and

designing;

producing and

implementing

purposeful design and

evaluation of user experiences and algorithms

effective design and

evaluation of user experiences and

design and evaluation of user experiences and algorithms- Designed User Experience and Algorithm

purposeful design and

proficient implementation of

modular programs, including an object-oriented program, using algorithms and data structures involving modular functions that

effective design and

effective implementation of

modular programs, including an object-oriented program, using algorithms and data structures involving modular functions that

design and implementation of modular programs, including an object-oriented program, using algorithms and data structures involving modular functions that - Implemented with CircuitPython

systematic testing and

prediction of results and proficient implementation of

digital solutions

reliable testing and

prediction of results and effective implementation of

digital solutions

testing and prediction of results and implementation of digital solutions- Tested Algorithm

Evaluating discerning evaluation of

information systems and their solutions in terms of risk, sustainability and potential for innovation and enterprise

informed evaluation of

information systems and their solutions in terms of risk, sustainability and potential for innovation and enterprise

evaluation of information systems and their solutions in terms of risk, sustainability and potential for innovation and enterprise- evaluated

OverviewTuesday, 26 March 2019 1:26 PM

Embedded Systems Page 1

Page 2: Overview - Through The Classroom Door...•Overview •What is CircuitPython? •Frequently Asked Questions •Installing Mu Editor •Installing CircuitPython •The CIRCUITPY Drive

Copy this whole section to your OneNote Space & then fill it in

Resources

https://learn.adafruit.com/neopixels-with-makecode

https://makecode.adafruit.com/tutorials/sirenhttps://makecode.adafruit.com/

NeopixelsThursday, 21 March 2019 9:51 AM

Embedded Systems Page 2

Page 3: Overview - Through The Classroom Door...•Overview •What is CircuitPython? •Frequently Asked Questions •Installing Mu Editor •Installing CircuitPython •The CIRCUITPY Drive

1. functional non-functional requirements

definition and decomposition of complex problems in terms of functional and non functional requirements

- defined functional requirements and decomposed Input, Processing, Output (IPO) chart

- defined non-functional requirements and decomposed the user experience

Control Structures

We will be using these blocks:

- Repeat (loop or ITERATION) the instructions or code that is inside block

- light up all neopixel LEDs in a ring.

We will be using a SEQUENCE of blocks in our Algorithm.

Functional Requirements - Input, process, output (IPO) table

Work your way through the Siren tutorial, filling in the table below as you go.

Input (event/data) Processing (coding) Output (action)

Embedded Systems Page 3

Page 4: Overview - Through The Classroom Door...•Overview •What is CircuitPython? •Frequently Asked Questions •Installing Mu Editor •Installing CircuitPython •The CIRCUITPY Drive

Non-functional requirements - UI and UX

Outline what the user interface (UI) and user experience(UX) will be like? Use the information below as a guide.

Your response here

2. User Experience and Algorithm

design and evaluation of user experiences and algorithms

Embedded Systems Page 4

Page 5: Overview - Through The Classroom Door...•Overview •What is CircuitPython? •Frequently Asked Questions •Installing Mu Editor •Installing CircuitPython •The CIRCUITPY Drive

- sketched the user experience

- designed the algorithm in makecode

- evaluated the user experience to recommend changes

- evaluated algorithm to refine and make more efficient

Sketch what the user experience will be like.

Your response here

Example

Embedded Systems Page 5

Page 6: Overview - Through The Classroom Door...•Overview •What is CircuitPython? •Frequently Asked Questions •Installing Mu Editor •Installing CircuitPython •The CIRCUITPY Drive

Algorithm

Paste a screenshot from MakeCode

How would you refine your algorithm and make it more efficient?

Your response here

UX Recommendations

How would you modify the User Experience (UX)

Your response here

Embedded Systems Page 6

Page 7: Overview - Through The Classroom Door...•Overview •What is CircuitPython? •Frequently Asked Questions •Installing Mu Editor •Installing CircuitPython •The CIRCUITPY Drive

3. Testing algorithm

testing and prediction of results and implementation of digital solutions

- tested and refined make code algorithm, taking care to record iterations

Refined Algorithm

How did you refine and improve your algorithm to make it more efficient?

Your response here

4. Implement with Circuitpython

design and implementation of modular programs, including an object-oriented program, using algorithms and data structures involving modular functions that reflect the relationships of real-world data and data entities

- implemented the solution in circuit python

Embedded Systems Page 7

Page 8: Overview - Through The Classroom Door...•Overview •What is CircuitPython? •Frequently Asked Questions •Installing Mu Editor •Installing CircuitPython •The CIRCUITPY Drive

- implemented the solution in circuit python

Resources

https://learn.adafruit.com/circuitpython-essentials

https://learn.adafruit.com/circuitpython-made-easy-on-circuit-playground-express

Installations

You need to pair up with another student and only install CircuitPython on onedevice. The other will be needed to prototype in MakeCode.

Overview•

What is CircuitPython?•

Frequently Asked Questions•

Installing Mu Editor•

Installing CircuitPython•

The CIRCUITPY Drive•

Creating and Editing Code•

Connecting to the Serial Console•

Use a # to comment under each line of the code below, explaining what it does.

Your response here

import boardimport digitalioimport time

led = digitalio.DigitalInOut(board.D13)led.direction = digitalio.Direction.OUTPUT

Embedded Systems Page 8

Page 9: Overview - Through The Classroom Door...•Overview •What is CircuitPython? •Frequently Asked Questions •Installing Mu Editor •Installing CircuitPython •The CIRCUITPY Drive

led.direction = digitalio.Direction.OUTPUT

while True: led.value = True time.sleep(0.5) led.value = False time.sleep(0.5)

Serial ConsoleInteracting with the Serial Console•

Install Libraries

Use the REPL to find out what version of CircuitPython you are running; look at the initial prompt in the CircuitPython REPL

The REPL•

What version are you running?

Your response here

CircuitPython Libraries•

Create a lib folder in the root of your CIRCUITPY drive

Unzip adafruit-circuitpython-bundle-3.x-mpy-20190320.zip or similar to the root of your CIRCUITPY drive

Neopixels

Review:https://learn.adafruit.com/circuitpython-made-easy-on-circuit-playground-express/neopixels

Remember, your algorithm is:

Embedded Systems Page 9

Page 10: Overview - Through The Classroom Door...•Overview •What is CircuitPython? •Frequently Asked Questions •Installing Mu Editor •Installing CircuitPython •The CIRCUITPY Drive

The code you need to light up one ring red is:

from adafruit_circuitplayground.express import cpx1.2.

while True:3.cpx.pixels.fill((50, 0, 0))4.

From <https://learn.adafruit.com/circuitpython-made-easy-on-circuit-playground-express/neopixels>

What code do you need to add, to then light up all the LEDs blue ?

Test it

Python Code

Copy your code and use # comments to explain what each line does.

Copy and paste your Python code here

5. Evaluate

Embedded Systems Page 10

Page 11: Overview - Through The Classroom Door...•Overview •What is CircuitPython? •Frequently Asked Questions •Installing Mu Editor •Installing CircuitPython •The CIRCUITPY Drive

evaluation of information systems and their solutions in terms of risk, sustainability and potential for innovation and enterprise

1. evaluated enterprise needs and opportunities

2. evaluated innovation3. evaluated sustainability4. made recommendations

Evaluate

Enterprise needs and opportunitiesWhat needs or opportunities does the solution address? How well does it address these?

InnovativeHow is the digital solution innovative? What potential impact does it have?

SustainabilityWhat is the lifespan of your solution? How long before better technology arrives and it is obsolete?

Is your solution easy to use and learn? Why/Why not?

RecommendationsRecommend at least one improvement that you would like to see made to the digital solution. Why?

Your response here

Embedded Systems Page 11

Page 12: Overview - Through The Classroom Door...•Overview •What is CircuitPython? •Frequently Asked Questions •Installing Mu Editor •Installing CircuitPython •The CIRCUITPY Drive

Copy this whole section to your OneNote Space & then fill it in

Resources

https://makecode.adafruit.com/tutorials/night-light

Neopixels and LoopsFriday, 22 March 2019 12:51 PM

Embedded Systems Page 12

Page 13: Overview - Through The Classroom Door...•Overview •What is CircuitPython? •Frequently Asked Questions •Installing Mu Editor •Installing CircuitPython •The CIRCUITPY Drive

1. functional non-functional requirements

definition and decomposition of complex problems in terms of functional and non functional requirements

- defined functional requirements and decomposed Input, Processing, Output (IPO) chart

- defined non-functional requirements and decomposed the user experience

Control Structures

Embedded Systems Page 13

Page 14: Overview - Through The Classroom Door...•Overview •What is CircuitPython? •Frequently Asked Questions •Installing Mu Editor •Installing CircuitPython •The CIRCUITPY Drive

The blocks we will be using are:

- This will repeat (loop or ITERATION) the instructions or code that is inside block a set number of times.

- similar to show ring block

- set the brightness level of the LEDs

- continue with previous instructions for this amount of time, before initiating the next instruction

Functional Requirements - Input, process, output (IPO) table

Work your way through the Night Light tutorial, filling in the table below as you go.

Input (event/data) Processing (coding) Output (action)

Non-functional requirements - UI and UX

Outline what the user interface (UI) and user experience(UX) will be like? Use the information below as a guide.

Your response here

Embedded Systems Page 14

Page 15: Overview - Through The Classroom Door...•Overview •What is CircuitPython? •Frequently Asked Questions •Installing Mu Editor •Installing CircuitPython •The CIRCUITPY Drive

2. User Experience and Algorithm

design and evaluation of user experiences and algorithms

Embedded Systems Page 15

Page 16: Overview - Through The Classroom Door...•Overview •What is CircuitPython? •Frequently Asked Questions •Installing Mu Editor •Installing CircuitPython •The CIRCUITPY Drive

- sketched the user experience

- designed the algorithm in makecode

- evaluated the user experience to recommend changes

- evaluated algorithm to refine and make more efficient

Sketch what the user experience will be like.

Your response here

Example

Embedded Systems Page 16

Page 17: Overview - Through The Classroom Door...•Overview •What is CircuitPython? •Frequently Asked Questions •Installing Mu Editor •Installing CircuitPython •The CIRCUITPY Drive

Algorithm

Paste a screenshot from MakeCode

How would you refine your algorithm and make it more efficient?

Your response here

Embedded Systems Page 17

Page 18: Overview - Through The Classroom Door...•Overview •What is CircuitPython? •Frequently Asked Questions •Installing Mu Editor •Installing CircuitPython •The CIRCUITPY Drive

UX Recommendations

How would you modify the User Experience (UX)

Your response here

3. Testing algorithm

testing and prediction of results and implementation of digital solutions

- tested and refined make code algorithm, taking care to record iterations

Refined Algorithm

How did you refine and improve your algorithm to make it more efficient?

Your response here

4. Implement with Circuitpython

Embedded Systems Page 18

Page 19: Overview - Through The Classroom Door...•Overview •What is CircuitPython? •Frequently Asked Questions •Installing Mu Editor •Installing CircuitPython •The CIRCUITPY Drive

design and implementation of modular programs, including an object-oriented program, using algorithms and data structures involving modular functions that reflect the relationships of real-world data and data entities

- implemented the solution in circuit python

Resources

https://learn.adafruit.com/circuitpython-essentials

https://learn.adafruit.com/circuitpython-made-easy-on-circuit-playground-express

Remember, your algorithm is:

Embedded Systems Page 19

Page 20: Overview - Through The Classroom Door...•Overview •What is CircuitPython? •Frequently Asked Questions •Installing Mu Editor •Installing CircuitPython •The CIRCUITPY Drive

For Loops in Python

For loops are traditionally used when you have a block of code which you want to repeat a fixed number of times.

For example:

For loop from 0 to 2, therefore running 3 times.

print "Hello World"print "This is the next thing to repeat"print index

for index in range(0, 2):

NOTE: there is a : at the end of the for statement and the code that needs to be looped is indented. "index" is a variable that will hold the current value of the loop and can be used within the looping code. For example, the last line will print the current loop number.

Neopixel brightness

Remember, the CircuitPython code to light up all the LEDs blue is:

from adafruit_circuitplayground.express import cpx

while True:cpx.pixels.fill((0, 0, 50))

The 50 for blue should be 255 at full strength, but we have lowered it to 50 so its not so bright. A better solution is to adjust the brightness with this code:

Embedded Systems Page 20

Page 21: Overview - Through The Classroom Door...•Overview •What is CircuitPython? •Frequently Asked Questions •Installing Mu Editor •Installing CircuitPython •The CIRCUITPY Drive

cpx.pixels.brightness = 0.3cpx.pixels.fill((0, 0, 255))

From <https://learn.adafruit.com/circuitpython-made-easy-on-circuit-playground-express/neopixels>

However, in this solution, we will not be using this to adjust the brightness of the LEDs.

You should realise that, from our algorithm, we are adjusting the brightness by using the value of the index looping variable, for 0 to 255. So we can go from 0 to 255 with:

cpx.pixels.fill((0, 0, index))

Luckily, index is an integer so we can use it in calculations:

cpx.pixels.fill((0, 0, 255 - index))

NOTE: python likes spaces between numbers and operators in mathematical calculations

Pausing

To pause, we need to use the time library (module), so, we import time and cpx.

import timefrom adafruit_circuitplayground.express import cpx

To pause, we use:

time.sleep(time in seconds)

NOTE: most other languages associated with embedded systems use milliseconds (ms); so keep this in mind; and remember that your algorithm uses ms.

Python Code

Implement your solution in CircuitPython code.

Test it

Copy your code and use # comments to explain what each line does.

Copy and paste your Python code here

5. Evaluate

Embedded Systems Page 21

Page 22: Overview - Through The Classroom Door...•Overview •What is CircuitPython? •Frequently Asked Questions •Installing Mu Editor •Installing CircuitPython •The CIRCUITPY Drive

evaluation of information systems and their solutions in terms of risk, sustainability and potential for innovation and enterprise

1. evaluated enterprise needs and opportunities

2. evaluated innovation3. evaluated sustainability4. made recommendations

Evaluate

Enterprise needs and opportunitiesWhat needs or opportunities does the solution address? How well does it address these?

InnovativeHow is the digital solution innovative? What potential impact does it have?

SustainabilityWhat is the lifespan of your solution? How long before better technology arrives and it is obsolete?

Is your solution easy to use and learn? Why/Why not?

RecommendationsRecommend at least one improvement that you would like to see made to the digital solution. Why?

Your response here

Embedded Systems Page 22

Page 23: Overview - Through The Classroom Door...•Overview •What is CircuitPython? •Frequently Asked Questions •Installing Mu Editor •Installing CircuitPython •The CIRCUITPY Drive

Copy this whole section to your OneNote Space & then fill it in

1. functional non-functional requirements

Sensors - accelerometer: shakeFriday, 22 March 2019 2:24 PM

Embedded Systems Page 23

Page 24: Overview - Through The Classroom Door...•Overview •What is CircuitPython? •Frequently Asked Questions •Installing Mu Editor •Installing CircuitPython •The CIRCUITPY Drive

definition and decomposition of complex problems in terms of functional and non functional requirements

- defined functional requirements and decomposed Input, Processing, Output (IPO) chart

- defined non-functional requirements and decomposed the user experience

Control Structures

The blocks we will be using are:

- conditional logic

- set value of a variable

- set colour of a nominated pixel

- continue with previous instructions for this amount of time, before initiating the next instruction

- initiate this set of instructions when the board is shaken

- turn all noepixel LEDs off

Functional Requirements - Input, process, output (IPO) table

Embedded Systems Page 24

Page 25: Overview - Through The Classroom Door...•Overview •What is CircuitPython? •Frequently Asked Questions •Installing Mu Editor •Installing CircuitPython •The CIRCUITPY Drive

Functional Requirements - Input, process, output (IPO) table

The starter Algorithm we will use:

The accelerometer is located at the exact centre of the board. The sensor can provide acceleration values for the x, y and z axes in addition to taps and shakes.

Fill this out:

Embedded Systems Page 25

Page 26: Overview - Through The Classroom Door...•Overview •What is CircuitPython? •Frequently Asked Questions •Installing Mu Editor •Installing CircuitPython •The CIRCUITPY Drive

Input (event/data) Processing (coding) Output (action)

Non-functional requirements - UI and UX

Outline what the user interface (UI) and user experience(UX) will be like? Use the information below as a guide.

Your response here

2. User Experience and Algorithm

Embedded Systems Page 26

Page 27: Overview - Through The Classroom Door...•Overview •What is CircuitPython? •Frequently Asked Questions •Installing Mu Editor •Installing CircuitPython •The CIRCUITPY Drive

design and evaluation of user experiences and algorithms

- sketched the user experience

- designed the algorithm in makecode

- evaluated the user experience to recommend changes

- evaluated algorithm to refine and make more efficient

Sketch what the user experience will be like.

Your response here

Example

Embedded Systems Page 27

Page 28: Overview - Through The Classroom Door...•Overview •What is CircuitPython? •Frequently Asked Questions •Installing Mu Editor •Installing CircuitPython •The CIRCUITPY Drive

Algorithm

Paste a screenshot from MakeCode

How would you refine your algorithm and make it more efficient? Loop?

Your response here

Embedded Systems Page 28

Page 29: Overview - Through The Classroom Door...•Overview •What is CircuitPython? •Frequently Asked Questions •Installing Mu Editor •Installing CircuitPython •The CIRCUITPY Drive

UX Recommendations

How would you modify the User Experience (UX)? What does the photon block do?

Your response here

3. Testing algorithm

testing and prediction of results and implementation of digital solutions

- tested and refined make code algorithm, taking care to record iterations

Refined Algorithm

How did you refine and improve your algorithm to make it more efficient?

Your response here

4. Implement with Circuitpython

Embedded Systems Page 29

Page 30: Overview - Through The Classroom Door...•Overview •What is CircuitPython? •Frequently Asked Questions •Installing Mu Editor •Installing CircuitPython •The CIRCUITPY Drive

design and implementation of modular programs, including an object-oriented program, using algorithms and data structures involving modular functions that reflect the relationships of real-world data and data entities

- implemented the solution in circuit python

Resources

https://learn.adafruit.com/circuitpython-made-easy-on-circuit-playground-express/neopixels

https://learn.adafruit.com/circuitpython-made-easy-on-circuit-playground-express/shake

https://learn.adafruit.com/circuitpython-essentials

https://learn.adafruit.com/circuitpython-made-easy-on-circuit-playground-express

Remember, your algorithm is something like:

Embedded Systems Page 30

Page 31: Overview - Through The Classroom Door...•Overview •What is CircuitPython? •Frequently Asked Questions •Installing Mu Editor •Installing CircuitPython •The CIRCUITPY Drive

Shake

from adafruit_circuitplayground.express import cpx

while True:if cpx.shake():

Inside our forever loop, we check to see if the board has been shaken with if cpx.shake():

Let's use shaking the board to turn on the first LED to red

from adafruit_circuitplayground.express import cpx

cpx.pixels.brightness = 0.3

while True:if cpx.shake():cpx.pixels[0] = (255, 0, 0)

Variables and random numbers

from random import *

Embedded Systems Page 31

Page 32: Overview - Through The Classroom Door...•Overview •What is CircuitPython? •Frequently Asked Questions •Installing Mu Editor •Installing CircuitPython •The CIRCUITPY Drive

from random import *

x = randint(1, 100) # Pick a random number between 1 and 100.

This code will use the random module to assign a random number to the variable x, between 1 and 100.

Python Code

Implement your solution in CircuitPython code.

Test it

Copy your code and use # comments to explain what each line does.

Copy and paste your Python code here

Refinement

Hopefully, you solved this problem using loops, to make your code more efficient. Remember,

For loop from 0 to 2, therefore running 3 times.

print "Hello World"print "This is the next thing to repeat"print index

for index in range(0, 2):

You can set the range of the loop with a variable

roll = randint(1,6)

print index

for index in range(1, randint):

What will print?

You can also use the value of index to turn on LEDs

roll = randint(1,6)

cpx.pixels[index] = (255, 0, 0)

for index in range(0, randint-1):

5. Evaluate

Embedded Systems Page 32

Page 33: Overview - Through The Classroom Door...•Overview •What is CircuitPython? •Frequently Asked Questions •Installing Mu Editor •Installing CircuitPython •The CIRCUITPY Drive

evaluation of information systems and their solutions in terms of risk, sustainability and potential for innovation and enterprise

1. evaluated enterprise needs and opportunities

2. evaluated innovation3. evaluated sustainability4. made recommendations

Evaluate

Enterprise needs and opportunitiesWhat needs or opportunities does the solution address? How well does it address these?

InnovativeHow is the digital solution innovative? What potential impact does it have?

SustainabilityWhat is the lifespan of your solution? How long before better technology arrives and it is obsolete?

Is your solution easy to use and learn? Why/Why not?

RecommendationsRecommend at least one improvement that you would like to see made to the digital solution. Why?

Your response here

Resources

https://learn.adafruit.com/make-it-sensehttps://makecode.adafruit.com/projects/cartoon-network/crownhttps://makecode.adafruit.com/projects/cartoon-network/darwin-goldfishhttps://makecode.adafruit.com/projects/magic-wandhttps://makecode.adafruit.com/examples/egg-gamehttps://makecode.adafruit.com/examples/animation-shakerhttps://makecode.adafruit.com/examples/juggle-counterhttps://makecode.adafruit.com/examples/energy-glovehttps://makecode.adafruit.com/examples/dicehttps://makecode.adafruit.com/examples/levelhttps://makecode.adafruit.com/examples/egg-gamehttps://makecode.adafruit.com/examples/spin-ithttps://makecode.adafruit.com/projects/reaction

Embedded Systems Page 33

Page 34: Overview - Through The Classroom Door...•Overview •What is CircuitPython? •Frequently Asked Questions •Installing Mu Editor •Installing CircuitPython •The CIRCUITPY Drive

Embedded Systems Page 34

Page 35: Overview - Through The Classroom Door...•Overview •What is CircuitPython? •Frequently Asked Questions •Installing Mu Editor •Installing CircuitPython •The CIRCUITPY Drive

Copy this whole section to your OneNote Space & then fill it in

1. functional non-functional requirements

Sensors - accelerometer: tiltFriday, 22 March 2019 2:24 PM

Embedded Systems Page 35

Page 36: Overview - Through The Classroom Door...•Overview •What is CircuitPython? •Frequently Asked Questions •Installing Mu Editor •Installing CircuitPython •The CIRCUITPY Drive

definition and decomposition of complex problems in terms of functional and non functional requirements

- defined functional requirements and decomposed Input, Processing, Output (IPO) chart

- defined non-functional requirements and decomposed the user experience

Control Structures

The blocks we will be using are:

- set colour of a nominated pixel

- continue with previous instructions for this amount of time, before initiating the next instruction

- initiate this set of instructions when the board is tilted

- turn all noepixel LEDs off

Tilt in MakeCode

There is no predefined Tilt function in Makecode, therefore, we need to create our own using

The accelerometer is located at the exact center of the board. The sensor can provide acceleration values for the x, y and z axes in addition to taps and shakes.

Embedded Systems Page 36

Page 37: Overview - Through The Classroom Door...•Overview •What is CircuitPython? •Frequently Asked Questions •Installing Mu Editor •Installing CircuitPython •The CIRCUITPY Drive

In MakeCode, The values returned are in milligravities (mg), while in python it is m/s2 (meters per second-squared). An axis is an invisible line going through the center of the accelerometer in the center of your board. The x axis is across the board, left to right. The y axis is across the board, top to bottom. The z axis is straight through the board front to back.

The way the accelerometer on the board works is that it can sense the amount of "gravity" it feels in 3 different axes.

The gravity on the x axis is what we'll use to determine the tilt. The way we can tell when the acceleometer (i.e. the Circuit Playground Express) is tilted with respect to an axis (X in our case) is to track the value for that axis.

Gravity at the Earth's surface is nominally about 9.8 m/s2, or 1000mg. So when the Circuit Playground Express is level, the value of Z will be ~9.8 (1000mg) and X will be 0. This is show in the lefthand half of the figure below.

When the Circuit Playground express is tilted 45 degrees, the force toward the center of the earth will still be 9.8, but it will be divided now between the X and Z axis, as show to the right below they will each be ~6.9 (9.8 * sin(45) or 1000*sin(45) mg ). Tilt it the other way and X will have a negative value.

By monitoring the value of X we can therefore tell how far along that axis the Circuit Playground Express is tilted.

MakeCode Tilt values

Embedded Systems Page 37

Page 38: Overview - Through The Classroom Door...•Overview •What is CircuitPython? •Frequently Asked Questions •Installing Mu Editor •Installing CircuitPython •The CIRCUITPY Drive

MakeCode Tilt values

-775mg = Tilted all the way left

775mg = Tilted all the way right

Functional Requirements - Input, process, output (IPO) table

The starter Algorithm we will use:

Input (event/data) Processing (coding) Output (action)

Non-functional requirements - UI and UX

Outline what the user interface (UI) and user experience(UX) will be like? Use the information below as a guide.

Your response here

Embedded Systems Page 38

Page 39: Overview - Through The Classroom Door...•Overview •What is CircuitPython? •Frequently Asked Questions •Installing Mu Editor •Installing CircuitPython •The CIRCUITPY Drive

2. User Experience and Algorithm

design and evaluation of user experiences and algorithms

Embedded Systems Page 39

Page 40: Overview - Through The Classroom Door...•Overview •What is CircuitPython? •Frequently Asked Questions •Installing Mu Editor •Installing CircuitPython •The CIRCUITPY Drive

- sketched the user experience

- designed the algorithm in makecode

- evaluated the user experience to recommend changes

- evaluated algorithm to refine and make more efficient

Sketch what the user experience will be like.

Your response here

Example

Embedded Systems Page 40

Page 41: Overview - Through The Classroom Door...•Overview •What is CircuitPython? •Frequently Asked Questions •Installing Mu Editor •Installing CircuitPython •The CIRCUITPY Drive

Algorithm

Paste a screenshot from MakeCode

How would you refine your algorithm and make it more efficient? Loop?

Your response here

Embedded Systems Page 41

Page 42: Overview - Through The Classroom Door...•Overview •What is CircuitPython? •Frequently Asked Questions •Installing Mu Editor •Installing CircuitPython •The CIRCUITPY Drive

UX Recommendations

How would you modify the User Experience (UX)? What does the photon block do?

Your response here

3. Testing algorithm

testing and prediction of results and implementation of digital solutions

- tested and refined make code algorithm, taking care to record iterations

Refined Algorithm

How did you refine and improve your algorithm to make it more efficient?

Your response here

4. Implement with Circuitpython

Embedded Systems Page 42

Page 43: Overview - Through The Classroom Door...•Overview •What is CircuitPython? •Frequently Asked Questions •Installing Mu Editor •Installing CircuitPython •The CIRCUITPY Drive

design and implementation of modular programs, including an object-oriented program, using algorithms and data structures involving modular functions that reflect the relationships of real-world data and data entities

- implemented the solution in circuit python

Resources

https://learn.adafruit.com/circuit-playground-express-head-tilt-ears/code

from adafruit_circuitplayground.express import cpx

while True:x, _, _ = cpx.acceleration

Remember, your algorithm is:

Embedded Systems Page 43

Page 44: Overview - Through The Classroom Door...•Overview •What is CircuitPython? •Frequently Asked Questions •Installing Mu Editor •Installing CircuitPython •The CIRCUITPY Drive

Initial Code

from adafruit_circuitplayground.express import cpx

while True:x, y, z = cpx.acceleration

The last line will set current xyz values to equivalent variables. We don't need y and z, so we can use:

x, _, _ = cpx.acceleration

If else Conditions (SELECTION) in Python

Python supports the usual logical conditions from mathematics:

Equals: a == bNot Equals: a != bLess than: a < bLess than or equal to: a <= bGreater than: a > bGreater than or equal to: a >= bThese conditions can be used in several ways, most commonly in "if statements" and loops.

An "if statement" is written by using the if keyword.

Example

a = 33b = 200if b > a: print("b is greater than a")

In this example we use two variables, a and b, which are used as part of the if statement to test whether b is greater than a. As a is 33, and b is 200, we know that 200 is greater than 33, and so we print to screen that "b is greater than a".

Indentation

Embedded Systems Page 44

Page 45: Overview - Through The Classroom Door...•Overview •What is CircuitPython? •Frequently Asked Questions •Installing Mu Editor •Installing CircuitPython •The CIRCUITPY Drive

IndentationPython relies on indentation, using whitespace, to define scope in the code. Other programming languages often use curly-brackets for this purpose.

ElifThe elif keyword is pythons way of saying "if the previous conditions were not true, then try this condition".

Example

a = 33b = 33if b > a: print("b is greater than a")elif a == b: print("a and b are equal")

In this example a is equal to b, so the first condition is not true, but the elif condition is true, so we print to screen that "a and b are equal".

From <https://www.w3schools.com/python/python_conditions.asp>

Accelerometer values in PythonIn MakeCode, The values returned are in milligravities (mg), while in python it is m/s2 (meters per second-squared)

Generally,

leftif x < -5.0:

rightelif x > 5.0:

Python Code

Implement your solution in CircuitPython code.

Test it

Copy your code and use # comments to explain what each line does.

Copy and paste your Python code here

5. Evaluate

Embedded Systems Page 45

Page 46: Overview - Through The Classroom Door...•Overview •What is CircuitPython? •Frequently Asked Questions •Installing Mu Editor •Installing CircuitPython •The CIRCUITPY Drive

evaluation of information systems and their solutions in terms of risk, sustainability and potential for innovation and enterprise

1. evaluated enterprise needs and opportunities

2. evaluated innovation3. evaluated sustainability4. made recommendations

Evaluate

Enterprise needs and opportunitiesWhat needs or opportunities does the solution address? How well does it address these?

InnovativeHow is the digital solution innovative? What potential impact does it have?

SustainabilityWhat is the lifespan of your solution? How long before better technology arrives and it is obsolete?

Is your solution easy to use and learn? Why/Why not?

RecommendationsRecommend at least one improvement that you would like to see made to the digital solution. Why?

Your response here

Resources

https://learn.adafruit.com/make-it-sensehttps://learn.adafruit.com/sensors-in-makecodehttps://makecode.adafruit.com/projects/cartoon-network/crownhttps://makecode.adafruit.com/examples/energy-glovehttps://makecode.adafruit.com/examples/levelhttps://makecode.adafruit.com/examples/egg-gamehttps://learn.adafruit.com/bosebuild-reactive-sound/uploading-the-code

Embedded Systems Page 46

Page 47: Overview - Through The Classroom Door...•Overview •What is CircuitPython? •Frequently Asked Questions •Installing Mu Editor •Installing CircuitPython •The CIRCUITPY Drive

from adafruit_circuitplayground.express import cpx1.cpx.detect_taps = 22.while True:3.if cpx.tapped:4.print("Tapped!")5.

From <https://learn.adafruit.com/make-it-shake-rattle-and-roll/use-in-circuitpython>

Copy this whole section to your OneNote Space & then fill it in

1. functional non-functional requirements

definition and decomposition of complex problems in terms of functional and non functional requirements

- defined functional requirements and decomposed Input, Processing, Output (IPO) chart

- defined non-functional requirements and decomposed the user experience

Functional Requirements - Input, process, output (IPO) table

Sensors - accelerometer: tapsMonday, 25 March 2019 10:54 AM

Embedded Systems Page 47

Page 48: Overview - Through The Classroom Door...•Overview •What is CircuitPython? •Frequently Asked Questions •Installing Mu Editor •Installing CircuitPython •The CIRCUITPY Drive

Functional Requirements - Input, process, output (IPO) table

Work your way through the Tap, filling in the table below as you go.

Input (event/data) Processing (coding) Output (action)

Non-functional requirements - UI and UX

Outline what the user interface (UI) and user experience(UX) will be like? Use the information below as a guide.

Your response here

2. User Experience and Algorithm

design and evaluation of user experiences and algorithms

- sketched the user experience

- designed the algorithm in makecode

- evaluated the user experience to recommend changes

- evaluated algorithm to refine and make more efficient

Embedded Systems Page 48

Page 49: Overview - Through The Classroom Door...•Overview •What is CircuitPython? •Frequently Asked Questions •Installing Mu Editor •Installing CircuitPython •The CIRCUITPY Drive

Sketch what the user experience will be like.

- single and double

Your response here

Example

Algorithm

Use Pseudocode

PseudocodeGuide

Algorithms Pseudocode

How would you refine your algorithm and make it more efficient? Loop?

Your response here

UX Recommendations

How would you modify the User Experience (UX)? What does the photon block do?

Your response here

Embedded Systems Page 49

Page 50: Overview - Through The Classroom Door...•Overview •What is CircuitPython? •Frequently Asked Questions •Installing Mu Editor •Installing CircuitPython •The CIRCUITPY Drive

3. Testing algorithm

testing and prediction of results and implementation of digital solutions

- tested and refined make code algorithm, taking care to record iterations

Refined Algorithm

How did you refine and improve your algorithm to make it more efficient?

Your response here

4. Implement with Circuitpython

design and implementation of modular programs, including an object-oriented program, using algorithms and data structures involving modular functions that reflect the relationships of real-world data and data entities

- implemented the solution in circuit python

Resources

https://learn.adafruit.com/circuitpython-made-easy-on-circuit-playground-express/tap

Embedded Systems Page 50

Page 51: Overview - Through The Classroom Door...•Overview •What is CircuitPython? •Frequently Asked Questions •Installing Mu Editor •Installing CircuitPython •The CIRCUITPY Drive

Python Code

Implement your solution in CircuitPython code.

Test it

Copy your code and use # comments to explain what each line does.

Copy and paste your Python code here

5. Evaluate

evaluation of information systems and their solutions in terms of risk, sustainability and potential for innovation and enterprise

1. evaluated enterprise needs and opportunities

2. evaluated innovation3. evaluated sustainability4. made recommendations

Evaluate

Enterprise needs and opportunitiesWhat needs or opportunities does the solution address? How well does it address these?

InnovativeHow is the digital solution innovative? What potential impact does it have?

SustainabilityWhat is the lifespan of your solution? How long before better technology arrives and it is obsolete?

Is your solution easy to use and learn? Why/Why not?

RecommendationsRecommend at least one improvement that you would like to see made to the digital solution. Why?

Your response here

Embedded Systems Page 51

Page 52: Overview - Through The Classroom Door...•Overview •What is CircuitPython? •Frequently Asked Questions •Installing Mu Editor •Installing CircuitPython •The CIRCUITPY Drive

Copy this whole section to your OneNote Space & then fill it in

1. functional non-functional requirements

Sensors - Light SensorMonday, 25 March 2019 7:59 AM

Embedded Systems Page 52

Page 53: Overview - Through The Classroom Door...•Overview •What is CircuitPython? •Frequently Asked Questions •Installing Mu Editor •Installing CircuitPython •The CIRCUITPY Drive

definition and decomposition of complex problems in terms of functional and non functional requirements

- defined functional requirements and decomposed Input, Processing, Output (IPO) chart

- defined non-functional requirements and decomposed the user experience

Control Structures

The blocks we will be using are:

Play a musical tone on the speaker. The tone has a pitch (frequency) as high or low as you say. The tone will keep playing until tell it to stop.

frequency is a number that says how high-pitched or low-pitched the tone is. This number is in Hz (Hertz), which is a measurement of frequency (pitch).

Functional Requirements - Input, process, output (IPO) table

The starter Algorithm we will use:

Embedded Systems Page 53

Page 54: Overview - Through The Classroom Door...•Overview •What is CircuitPython? •Frequently Asked Questions •Installing Mu Editor •Installing CircuitPython •The CIRCUITPY Drive

Input (event/data) Processing (coding) Output (action)

Non-functional requirements - UI and UX

Outline what the user interface (UI) and user experience(UX) will be like? Use the information below as a guide.

Your response here

2. User Experience and Algorithm

Embedded Systems Page 54

Page 55: Overview - Through The Classroom Door...•Overview •What is CircuitPython? •Frequently Asked Questions •Installing Mu Editor •Installing CircuitPython •The CIRCUITPY Drive

design and evaluation of user experiences and algorithms

- sketched the user experience

- designed the algorithm in makecode

- evaluated the user experience to recommend changes

- evaluated algorithm to refine and make more efficient

Sketch what the user experience will be like.

Your response here

Example

Embedded Systems Page 55

Page 56: Overview - Through The Classroom Door...•Overview •What is CircuitPython? •Frequently Asked Questions •Installing Mu Editor •Installing CircuitPython •The CIRCUITPY Drive

Algorithm

Paste a screenshot from MakeCode

How would you refine your algorithm and make it more efficient? Loop?

Your response here

UX Recommendations

Embedded Systems Page 56

Page 57: Overview - Through The Classroom Door...•Overview •What is CircuitPython? •Frequently Asked Questions •Installing Mu Editor •Installing CircuitPython •The CIRCUITPY Drive

UX Recommendations

How would you modify the User Experience (UX)? What does the photon block do?

Your response here

3. Testing algorithm

testing and prediction of results and implementation of digital solutions

- tested and refined make code algorithm, taking care to record iterations

Refined Algorithm

How did you refine and improve your algorithm to make it more efficient?

Your response here

4. Implement with Circuitpython

Embedded Systems Page 57

Page 58: Overview - Through The Classroom Door...•Overview •What is CircuitPython? •Frequently Asked Questions •Installing Mu Editor •Installing CircuitPython •The CIRCUITPY Drive

design and implementation of modular programs, including an object-oriented program, using algorithms and data structures involving modular functions that reflect the relationships of real-world data and data entities

- implemented the solution in circuit python

Resources

https://learn.adafruit.com/circuitpython-made-easy-on-circuit-playground-express/lighthttps://learn.adafruit.com/fancyled-library-for-circuitpythonhttps://learn.adafruit.com/make-it-sound/music-and-sound-in-makecode-2

Light rangeIn MakeCode, the light values range from 0 to 255. In CircuitPython, the light values range from 0 to 320.

Remember, your algorithm is:

In CircuitPython, there is no "on light" function, so we will need to make our own version. You can do this in makecode as well.

Embedded Systems Page 58

Page 59: Overview - Through The Classroom Door...•Overview •What is CircuitPython? •Frequently Asked Questions •Installing Mu Editor •Installing CircuitPython •The CIRCUITPY Drive

Neopixel Animations

Here are some examples you could adapt:

# slowly power up via blue colorfor i in range(50):CPX_pixels.fill((0, 0, i))time.sleep(0.05)

# blast off!CPX_pixels.fill((255, 0, 0))

while True:# pulse effectfor i in range(255, 0, -5):CPX_pixels.fill((i, 0, 0))for i in range(0, 255, 5):CPX_pixels.fill((i, 0, 0))

From <https://learn.adafruit.com/make-it-glow-with-crickit/using-circuit-playground-neopixels>

Music and Sound in CircuitPython

Use cpx.start_tone(frequency)

From <https://learn.adafruit.com/make-it-sound/music-and-sound-in-makecode-2>

Python Code

Implement your solution in CircuitPython code.

Test it

Copy your code and use # comments to explain what each line does.

Copy and paste your Python code here

5. Evaluate

Embedded Systems Page 59

Page 60: Overview - Through The Classroom Door...•Overview •What is CircuitPython? •Frequently Asked Questions •Installing Mu Editor •Installing CircuitPython •The CIRCUITPY Drive

evaluation of information systems and their solutions in terms of risk, sustainability and potential for innovation and enterprise

1. evaluated enterprise needs and opportunities

2. evaluated innovation3. evaluated sustainability4. made recommendations

Evaluate

Enterprise needs and opportunitiesWhat needs or opportunities does the solution address? How well does it address these?

InnovativeHow is the digital solution innovative? What potential impact does it have?

SustainabilityWhat is the lifespan of your solution? How long before better technology arrives and it is obsolete?

Is your solution easy to use and learn? Why/Why not?

RecommendationsRecommend at least one improvement that you would like to see made to the digital solution. Why?

Your response here

Resources

https://learn.adafruit.com/circuitpython-made-easy-on-circuit-playground-express/light

https://makecode.adafruit.com/reference/input/on-light-condition-changed

https://makecode.adafruit.com/reference/input/light-level

https://makecode.adafruit.com/reference/input/set-light-threshold

https://learn.adafruit.com/sensors-in-makecode/light-sensor

https://learn.adafruit.com/make-it-sound/music-and-sound-in-makecode-2

Embedded Systems Page 60

Page 61: Overview - Through The Classroom Door...•Overview •What is CircuitPython? •Frequently Asked Questions •Installing Mu Editor •Installing CircuitPython •The CIRCUITPY Drive

Copy this whole section to your OneNote Space & then fill it in

1. functional non-functional requirements

definition and decomposition of complex problems in terms of functional and non functional requirements

- defined functional requirements and decomposed Input, Processing, Output (IPO) chart

- defined non-functional requirements and decomposed the user experience

Control Structures

The blocks we will be using are:

Sensors - TemperatureMonday, 25 March 2019 8:00 AM

Embedded Systems Page 61

Page 62: Overview - Through The Classroom Door...•Overview •What is CircuitPython? •Frequently Asked Questions •Installing Mu Editor •Installing CircuitPython •The CIRCUITPY Drive

This remaps the specified value from one range to another. This function maps the value of from low to the value of to low, the value of from high to the value of to high, and intermediate values to intermediate values.

The reason we need this is because the temperature sensor will return Celsius values from 0 to 100+, while we need to set the brightness of the LEDs from 0 to 255. The map function enables us to take a Celsius value and convert it to an equivalent value that is within the range of the LEDs.

Functional Requirements - Input, process, output (IPO) table

The starter Algorithm we will use:

Input (event/data) Processing (coding) Output (action)

Non-functional requirements - UI and UX

Outline what the user interface (UI) and user experience(UX) will be like? Use the information below as a guide.

Your response here

2. User Experience and Algorithm

Embedded Systems Page 62

Page 63: Overview - Through The Classroom Door...•Overview •What is CircuitPython? •Frequently Asked Questions •Installing Mu Editor •Installing CircuitPython •The CIRCUITPY Drive

design and evaluation of user experiences and algorithms

- sketched the user experience

- designed the algorithm in makecode

- evaluated the user experience to recommend changes

- evaluated algorithm to refine and make more efficient

Sketch what the user experience will be like.

Your response here

Example

Algorithm

Paste a screenshot from MakeCode

How would you refine your algorithm and make it more efficient? Loop?

Embedded Systems Page 63

Page 64: Overview - Through The Classroom Door...•Overview •What is CircuitPython? •Frequently Asked Questions •Installing Mu Editor •Installing CircuitPython •The CIRCUITPY Drive

How would you refine your algorithm and make it more efficient? Loop?

Your response here

UX Recommendations

How would you modify the User Experience (UX)? What does the photon block do?

Your response here

3. Testing algorithm

testing and prediction of results and implementation of digital solutions

- tested and refined make code algorithm, taking care to record iterations

Refined Algorithm

How did you refine and improve your algorithm to make it more efficient?

Your response here

4. Implement with Circuitpython

design and implementation of modular programs, including an object-oriented program, using algorithms and data structures involving modular functions that reflect the relationships of real-world data and data entities

- implemented the solution in circuit python

Embedded Systems Page 64

Page 65: Overview - Through The Classroom Door...•Overview •What is CircuitPython? •Frequently Asked Questions •Installing Mu Editor •Installing CircuitPython •The CIRCUITPY Drive

Resourceshttps://learn.adafruit.com/circuitpython-made-easy-on-circuit-playground-express/temperaturehttps://learn.adafruit.com/adafruit-circuit-playground-express/playground-temperature

Remember, our Algorithm is:

simpleio.map_range

The simpleio module contains classes to provide simple access to IO. We can also use this API to map a number from one range to another:

simpleio.map_range(x, in_min, in_max, out_min, out_max)

From <https://circuitpython.readthedocs.io/projects/simpleio/en/latest/api.html >

To import, we need:

from adafruit_circuitplayground.express import cpximport simpleio

Lets set a temperature range:

# Set these based on your ambient temperature for best results!minimum_temp = 24maximum_temp = 30

Now map to brightness:

while True:brightness = simpleio.map_range(cpx.temperature, minimum_temp, maximum_temp, 0, 255)

We can't use cpx.pixels.brightness as this needs a decimal value between 0 and 1, so we will use cpx.pixels.fill and adjust the R value for red brightness:

cpx.pixels.fill((brightness, 0, 0))

Python Code

Implement your solution in CircuitPython code.

Test it

Copy your code and use # comments to explain what each line does.

Copy and paste your Python code here

5. Evaluate

Embedded Systems Page 65

Page 66: Overview - Through The Classroom Door...•Overview •What is CircuitPython? •Frequently Asked Questions •Installing Mu Editor •Installing CircuitPython •The CIRCUITPY Drive

evaluation of information systems and their solutions in terms of risk, sustainability and potential for innovation and enterprise

1. evaluated enterprise needs and opportunities

2. evaluated innovation3. evaluated sustainability4. made recommendations

Evaluate

Enterprise needs and opportunitiesWhat needs or opportunities does the solution address? How well does it address these?

InnovativeHow is the digital solution innovative? What potential impact does it have?

SustainabilityWhat is the lifespan of your solution? How long before better technology arrives and it is obsolete?

Is your solution easy to use and learn? Why/Why not?

RecommendationsRecommend at least one improvement that you would like to see made to the digital solution. Why?

Your response here

Resourceshttps://learn.adafruit.com/circuitpython-made-easy-on-circuit-playground-express/temperaturehttps://learn.adafruit.com/adafruit-circuit-playground-express/playground-temperaturehttps://makecode.adafruit.com/reference/input/temperaturehttps://learn.adafruit.com/sensors-in-makecode/thermometer

Embedded Systems Page 66

Page 67: Overview - Through The Classroom Door...•Overview •What is CircuitPython? •Frequently Asked Questions •Installing Mu Editor •Installing CircuitPython •The CIRCUITPY Drive

Copy this whole section to your OneNote Space & then fill it in

Sensors - ButtonsMonday, 25 March 2019 8:00 AM

Embedded Systems Page 67

Page 68: Overview - Through The Classroom Door...•Overview •What is CircuitPython? •Frequently Asked Questions •Installing Mu Editor •Installing CircuitPython •The CIRCUITPY Drive

1. functional non-functional requirements

definition and decomposition of complex problems in terms of functional and non functional requirements

- defined functional requirements and decomposed Input, Processing, Output (IPO) chart

- defined non-functional requirements and decomposed the user experience

Embedded Systems Page 68

Page 69: Overview - Through The Classroom Door...•Overview •What is CircuitPython? •Frequently Asked Questions •Installing Mu Editor •Installing CircuitPython •The CIRCUITPY Drive

Control Structures

Functional Requirements - Input, process, output (IPO) table

The starter Algorithm we will use:

You can pretty much program the CPE to do anything when a button is pressed. This algorithm checks to see if the A button is pressed and then turns on all the LEDs red; otherwise, all LEDs are off.

Use this algorithm any way you like; maybe play a sound?

Input (event/data) Processing (coding) Output (action)

Embedded Systems Page 69

Page 70: Overview - Through The Classroom Door...•Overview •What is CircuitPython? •Frequently Asked Questions •Installing Mu Editor •Installing CircuitPython •The CIRCUITPY Drive

Input (event/data) Processing (coding) Output (action)

Non-functional requirements - UI and UX

Outline what the user interface (UI) and user experience(UX) will be like? Use the information below as a guide.

Your response here

2. User Experience and Algorithm

Embedded Systems Page 70

Page 71: Overview - Through The Classroom Door...•Overview •What is CircuitPython? •Frequently Asked Questions •Installing Mu Editor •Installing CircuitPython •The CIRCUITPY Drive

design and evaluation of user experiences and algorithms

- sketched the user experience

- designed the algorithm in makecode

- evaluated the user experience to recommend changes

- evaluated algorithm to refine and make more efficient

Sketch what the user experience will be like.

Your response here

Example

Embedded Systems Page 71

Page 72: Overview - Through The Classroom Door...•Overview •What is CircuitPython? •Frequently Asked Questions •Installing Mu Editor •Installing CircuitPython •The CIRCUITPY Drive

Algorithm

Paste a screenshot from MakeCode

How would you refine your algorithm and make it more efficient? Loop?

Your response here

Embedded Systems Page 72

Page 73: Overview - Through The Classroom Door...•Overview •What is CircuitPython? •Frequently Asked Questions •Installing Mu Editor •Installing CircuitPython •The CIRCUITPY Drive

UX Recommendations

How would you modify the User Experience (UX)? What does the photon block do?

Your response here

3. Testing algorithm

testing and prediction of results and implementation of digital solutions

- tested and refined make code algorithm, taking care to record iterations

Refined Algorithm

How did you refine and improve your algorithm to make it more efficient?

Your response here

4. Implement with Circuitpython

Embedded Systems Page 73

Page 74: Overview - Through The Classroom Door...•Overview •What is CircuitPython? •Frequently Asked Questions •Installing Mu Editor •Installing CircuitPython •The CIRCUITPY Drive

design and implementation of modular programs, including an object-oriented program, using algorithms and data structures involving modular functions that reflect the relationships of real-world data and data entities

- implemented the solution in circuit python

Resourceshttps://learn.adafruit.com/circuitpython-made-easy-on-circuit-playground-express/buttons

Try all of the options here: https://learn.adafruit.com/circuitpython-made-easy-on-circuit-playground-express/buttons

Python Code

Implement your solution in CircuitPython code.

Test it

Copy your code and use # comments to explain what each line does.

Copy and paste your Python code here

5. Evaluate

Embedded Systems Page 74

Page 75: Overview - Through The Classroom Door...•Overview •What is CircuitPython? •Frequently Asked Questions •Installing Mu Editor •Installing CircuitPython •The CIRCUITPY Drive

evaluation of information systems and their solutions in terms of risk, sustainability and potential for innovation and enterprise

1. evaluated enterprise needs and opportunities

2. evaluated innovation3. evaluated sustainability4. made recommendations

Evaluate

Enterprise needs and opportunitiesWhat needs or opportunities does the solution address? How well does it address these?

InnovativeHow is the digital solution innovative? What potential impact does it have?

SustainabilityWhat is the lifespan of your solution? How long before better technology arrives and it is obsolete?

Is your solution easy to use and learn? Why/Why not?

RecommendationsRecommend at least one improvement that you would like to see made to the digital solution. Why?

Your response here

Resourceshttps://makecode.adafruit.com/learnsystem/beep-beep

Embedded Systems Page 75

Page 76: Overview - Through The Classroom Door...•Overview •What is CircuitPython? •Frequently Asked Questions •Installing Mu Editor •Installing CircuitPython •The CIRCUITPY Drive

Copy this whole section to your OneNote Space & then fill it in

Capacitive TouchThe Circuit Playground Express has seven capacitive touch pads around the outside, labeled A1 - A7. These pads return True if you touch them.

Sensors - Capacitive TouchMonday, 25 March 2019 8:00 AM

Embedded Systems Page 76

Page 77: Overview - Through The Classroom Door...•Overview •What is CircuitPython? •Frequently Asked Questions •Installing Mu Editor •Installing CircuitPython •The CIRCUITPY Drive

Since the pads are capacitive, you can also attach alligator clips to them and any number of capacitive items and touch those to activate them as well

1. functional non-functional requirements

definition and decomposition of complex problems in terms of functional and non functional requirements

Embedded Systems Page 77

Page 78: Overview - Through The Classroom Door...•Overview •What is CircuitPython? •Frequently Asked Questions •Installing Mu Editor •Installing CircuitPython •The CIRCUITPY Drive

- defined functional requirements and decomposed Input, Processing, Output (IPO) chart

- defined non-functional requirements and decomposed the user experience

Control Structures

- When pin A1-A7 touched

- play a music tone

Functional Requirements - Input, process, output (IPO) table

The starter Algorithm we will use:

Input (event/data) Processing (coding) Output (action)

Embedded Systems Page 78

Page 79: Overview - Through The Classroom Door...•Overview •What is CircuitPython? •Frequently Asked Questions •Installing Mu Editor •Installing CircuitPython •The CIRCUITPY Drive

Non-functional requirements - UI and UX

Outline what the user interface (UI) and user experience(UX) will be like? Use the information below as a guide.

Your response here

2. User Experience and Algorithm

Embedded Systems Page 79

Page 80: Overview - Through The Classroom Door...•Overview •What is CircuitPython? •Frequently Asked Questions •Installing Mu Editor •Installing CircuitPython •The CIRCUITPY Drive

design and evaluation of user experiences and algorithms

- sketched the user experience

- designed the algorithm in makecode

- evaluated the user experience to recommend changes

- evaluated algorithm to refine and make more efficient

Sketch what the user experience will be like.

Your response here

Example

Embedded Systems Page 80

Page 81: Overview - Through The Classroom Door...•Overview •What is CircuitPython? •Frequently Asked Questions •Installing Mu Editor •Installing CircuitPython •The CIRCUITPY Drive

Algorithm

Paste a screenshot from MakeCode

How would you refine your algorithm and make it more efficient? Loop?

Your response here

Embedded Systems Page 81

Page 82: Overview - Through The Classroom Door...•Overview •What is CircuitPython? •Frequently Asked Questions •Installing Mu Editor •Installing CircuitPython •The CIRCUITPY Drive

UX Recommendations

How would you modify the User Experience (UX)? What does the photon block do?

Your response here

3. Testing algorithm

testing and prediction of results and implementation of digital solutions

- tested and refined make code algorithm, taking care to record iterations

Refined Algorithm

How did you refine and improve your algorithm to make it more efficient?

Your response here

4. Implement with Circuitpython

Embedded Systems Page 82

Page 83: Overview - Through The Classroom Door...•Overview •What is CircuitPython? •Frequently Asked Questions •Installing Mu Editor •Installing CircuitPython •The CIRCUITPY Drive

design and implementation of modular programs, including an object-oriented program, using algorithms and data structures involving modular functions that reflect the relationships of real-world data and data entities

- implemented the solution in circuit python

Resourceshttps://learn.adafruit.com/circuitpython-made-easy-on-circuit-playground-express/capacitive-touchhttps://learn.adafruit.com/circuitpython-made-easy-on-circuit-playground-express/play-tonehttps://core-electronics.com.au/tutorials/capacitive-touch-keyboard-with-circuitpython-adafruit-circuit-playground-express-tutorial.html

Python and Event Handlers

Python doesn't really use event handler functions like Java, Javascript or C#. For example, in Javacript:

input.pinA1.onEvent(ButtonEvent.Click, function () {music.playTone(262, music.beat(BeatFraction.Half))})

Instead, we can use if..elsif

from adafruit_circuitplayground.express import cpx

while True:if cpx.touch_A1:

Embedded Systems Page 83

Page 84: Overview - Through The Classroom Door...•Overview •What is CircuitPython? •Frequently Asked Questions •Installing Mu Editor •Installing CircuitPython •The CIRCUITPY Drive

if cpx.touch_A1:

Play Tone

cpx.play_tone() requires two things from you: a frequency in hertz and a length of time in seconds. So anytime you want to use it, you'll add cpx.play_tone(frequency, seconds) to your code, where frequency is the hertz of the tone you'd like to play, and seconds is the length of time you'd like it to play.There are many tone generators available on the internet that will give you the hertz of a specific tone. The two tones added to the code below are middle C and the D above middle C. Try adding another tone.

from adafruit_circuitplayground.express import cpx

while True:

cpx.play_tone(262, 1)cpx.play_tone(294, 1)

if cpx.touch_A1:

Multiple TouchesFor other pin touches, just extend on the code with elsif

from adafruit_circuitplayground.express import cpx

while True:

cpx.play_tone(262, 1)cpx.play_tone(294, 1)

if cpx.touch_A1:

elif cpx.touch_A2: cpx.start_tone(523)else: cpx.stop_tone()

Other ideasConsider using different coloured lights for each tone.

Challenge: https://learn.adafruit.com/adafruit-circuit-playground-express/playground-drum-machine

Python Code

Implement your solution in CircuitPython code.

Test it

Copy your code and use # comments to explain what each line does.

Copy and paste your Python code here

5. Evaluate

Embedded Systems Page 84

Page 85: Overview - Through The Classroom Door...•Overview •What is CircuitPython? •Frequently Asked Questions •Installing Mu Editor •Installing CircuitPython •The CIRCUITPY Drive

evaluation of information systems and their solutions in terms of risk, sustainability and potential for innovation and enterprise

1. evaluated enterprise needs and opportunities

2. evaluated innovation3. evaluated sustainability4. made recommendations

Evaluate

Enterprise needs and opportunitiesWhat needs or opportunities does the solution address? How well does it address these?

InnovativeHow is the digital solution innovative? What potential impact does it have?

SustainabilityWhat is the lifespan of your solution? How long before better technology arrives and it is obsolete?

Is your solution easy to use and learn? Why/Why not?

RecommendationsRecommend at least one improvement that you would like to see made to the digital solution. Why?

Your response here

Resourceshttps://learn.adafruit.com/circuitpython-made-easy-on-circuit-playground-express/capacitive-touchhttps://learn.adafruit.com/circuitpython-made-easy-on-circuit-playground-express/play-tonehttps://core-electronics.com.au/tutorials/capacitive-touch-keyboard-with-circuitpython-adafruit-circuit-playground-express-tutorial.htmlhttps://learn.adafruit.com/circuitpython-made-easy-on-circuit-playground-express/capacitive-touchhttps://makecode.adafruit.com/courses/maker/projects/music-makerhttps://learn.adafruit.com/circuit-playground-express-piano-in-the-key-of-limehttps://learn.adafruit.com/touch-tone-for-circuit-playground-expresshttps://core-electronics.com.au/tutorials/capacitive-touch-keyboard-with-circuitpython-adafruit-circuit-playground-express-tutorial.html

Embedded Systems Page 85

Page 86: Overview - Through The Classroom Door...•Overview •What is CircuitPython? •Frequently Asked Questions •Installing Mu Editor •Installing CircuitPython •The CIRCUITPY Drive

Embedded Systems Page 86

Page 87: Overview - Through The Classroom Door...•Overview •What is CircuitPython? •Frequently Asked Questions •Installing Mu Editor •Installing CircuitPython •The CIRCUITPY Drive

Copy this whole section to your OneNote Space & then fill it in

1. functional non-functional requirements

Sensors - soundThursday, 21 March 2019 9:52 AM

Embedded Systems Page 87

Page 88: Overview - Through The Classroom Door...•Overview •What is CircuitPython? •Frequently Asked Questions •Installing Mu Editor •Installing CircuitPython •The CIRCUITPY Drive

definition and decomposition of complex problems in terms of functional and non functional requirements

- defined functional requirements and decomposed Input, Processing, Output (IPO) chart

- defined non-functional requirements and decomposed the user experience

Sound Sensor

The sound sensor on the Circuit Playground Express is in the lower right corner below push button B marked with an ear.

This microphone is a bit different than some used in Arduino projects. Instead of an analog microphone, which requires an external op-amp and level management, the Circuit Playground Express uses a PDM microphone. This is a digital mic which is a lot smaller and less expensive. You will need to use MakeCode/CircuitPython/Arduino support libraries to read the audio, you cannot read it like an analog voltage.

Functional Requirements - Input, process, output (IPO) table

The starter Algorithm we will use:

Embedded Systems Page 88

Page 89: Overview - Through The Classroom Door...•Overview •What is CircuitPython? •Frequently Asked Questions •Installing Mu Editor •Installing CircuitPython •The CIRCUITPY Drive

Input (event/data) Processing (coding) Output (action)

Non-functional requirements - UI and UX

Outline what the user interface (UI) and user experience(UX) will be like? Use the information below as a guide.

Your response here

Embedded Systems Page 89

Page 90: Overview - Through The Classroom Door...•Overview •What is CircuitPython? •Frequently Asked Questions •Installing Mu Editor •Installing CircuitPython •The CIRCUITPY Drive

2. User Experience and Algorithm

design and evaluation of user experiences and algorithms

- sketched the user experience

- designed the algorithm in makecode

- evaluated the user experience to recommend changes

- evaluated algorithm to refine and make more efficient

Sketch what the user experience will be like.

Your response here

Embedded Systems Page 90

Page 91: Overview - Through The Classroom Door...•Overview •What is CircuitPython? •Frequently Asked Questions •Installing Mu Editor •Installing CircuitPython •The CIRCUITPY Drive

Your response here

Example

Algorithm

Paste a screenshot from MakeCode

Embedded Systems Page 91

Page 92: Overview - Through The Classroom Door...•Overview •What is CircuitPython? •Frequently Asked Questions •Installing Mu Editor •Installing CircuitPython •The CIRCUITPY Drive

How would you refine your algorithm and make it more efficient? Loop?

Your response here

UX Recommendations

How would you modify the User Experience (UX)? What does the photon block do?

Your response here

3. Testing algorithm

testing and prediction of results and implementation of digital solutions

- tested and refined make code algorithm, taking care to record iterations

Refined Algorithm

How did you refine and improve your algorithm to make it more efficient?

Your response here

4. Implement with Circuitpython

Embedded Systems Page 92

Page 93: Overview - Through The Classroom Door...•Overview •What is CircuitPython? •Frequently Asked Questions •Installing Mu Editor •Installing CircuitPython •The CIRCUITPY Drive

design and implementation of modular programs, including an object-oriented program, using algorithms and data structures involving modular functions that reflect the relationships of real-world data and data entities

- implemented the solution in circuit python

Resourceshttps://learn.adafruit.com/the-scream-munch-screaming-interactive-scream-painting/code-with-circuitpythonhttps://circuitpython.readthedocs.io/en/2.x/shared-bindings/audiobusio/PDMIn.htmlhttps://learn.adafruit.com/sensor-plotting-with-mu-and-circuitpython/soundhttps://learn.adafruit.com/make-it-sense/circuitpython-3

This is our base algorithm (below) and to implement in javascript, it's quite easy

forever(function () {if (input.soundLevel() > 45) {light.setBrightness(input.soundLevel())light.setAll(0xff0000)pause(1)} else {light.clear()}

Embedded Systems Page 93

Page 94: Overview - Through The Classroom Door...•Overview •What is CircuitPython? •Frequently Asked Questions •Installing Mu Editor •Installing CircuitPython •The CIRCUITPY Drive

}})

However, in CircuitPython, its not so easy

First, we'll import some libraries that add capabilities to our CircuitPython code.Then, we'll create a variable NUM_SAMPLES to represent the number of samples we'll use when testing the microphone for loud sounds.

import timeimport mathimport arrayimport audiobusio

# Number of samples to read at once.NUM_SAMPLES = 160

Helper FunctionsThere are also two helper functions. The first one uses maths to return a mean, or average. It is used

in the second helper. The second felper function uses maths to return a normalised rms average. These functions are then used to take multiple sound samples really quickly and average them to get a more accurate reading.

We define a procedure named normalized_rms that will be used for removing DC bias from our mic readings before computing the root mean square (a type of average).

Embedded Systems Page 94

Page 95: Overview - Through The Classroom Door...•Overview •What is CircuitPython? •Frequently Asked Questions •Installing Mu Editor •Installing CircuitPython •The CIRCUITPY Drive

def normalized_rms(values): minbuf = int(mean(values)) samples_sum = sum( float(sample - minbuf) * (sample - minbuf) for sample in values )

return math.sqrt(samples_sum / len(values))

The mean procedure is also defined -- this is used to calculate the mean of our sampled values.

def mean(values): return sum(values) / len(values)

Microphone

Now we'll set up the microphone object to use the Circuit Playground Express's microphone at a sample rate of 16,000 and a bit depth of 16.

And, we'll immediately take a sample of the room's ambient sound to provide a baseline.

mic = audiobusio.PDMIn(board.MICROPHONE_CLOCK, board.MICROPHONE_DATA, sample_rate=16000, bit_depth=16)

# Record an initial sample to calibrate. Assume it's quiet when we start.samples = array.array('H', 0 * NUM_SAMPLES)mic.record(samples, len(samples))

Main Loop

Now we are at the main loop of the program, the part that runs over and over and over again endlessly.

Here, the microphone is sampled, and the normalized root mean square is calculated and assigned to a variable named magnitude.

while True: mic.record(samples, len(samples)) magnitude = normalized_rms(samples)

If the yelling volume caused a magnitude reading of 2000, say, and normal room noise is below 400, then 1000 is a good magnitude to use as your threshold.

This if statement checks to see if the current magnitude is below 1000. If it is, nothing happens. Else, if the reading is higher, then the LEDs light up blue to the brightness level of the magnitude.

After this is done, the system waits a couple of seconds before the main loop runs again

if magnitude < 1000: # it's quiet, do nothing. pass

cpx.pixels.fill((0, 0, magnitude))

time.sleep(0.1)

else:

Embedded Systems Page 95

Page 96: Overview - Through The Classroom Door...•Overview •What is CircuitPython? •Frequently Asked Questions •Installing Mu Editor •Installing CircuitPython •The CIRCUITPY Drive

ChallengeCan you code this to light up LEDs? One LED for soft and all LEDs for loud

Hint: https://learn.adafruit.com/adafruit-circuit-playground-express/playground-sound-meterhttps://core-electronics.com.au/tutorials/sound-reactive-lights-circuitpython-circuit-playground-express-tutorial.html

Python Code

Implement your solution in CircuitPython code.

Test it

Copy your code and use # comments to explain what each line does.

Copy and paste your Python code here

5. Evaluate

evaluation of information systems and their solutions in terms of risk, sustainability and potential for innovation and enterprise

1. evaluated enterprise needs and opportunities

2. evaluated innovation3. evaluated sustainability4. made recommendations

Evaluate

Enterprise needs and opportunitiesWhat needs or opportunities does the solution address? How well does it address these?

Innovative

Embedded Systems Page 96

Page 97: Overview - Through The Classroom Door...•Overview •What is CircuitPython? •Frequently Asked Questions •Installing Mu Editor •Installing CircuitPython •The CIRCUITPY Drive

InnovativeHow is the digital solution innovative? What potential impact does it have?

SustainabilityWhat is the lifespan of your solution? How long before better technology arrives and it is obsolete?

Is your solution easy to use and learn? Why/Why not?

RecommendationsRecommend at least one improvement that you would like to see made to the digital solution. Why?

Your response here

Resourceshttps://learn.adafruit.com/make-it-sense/use-the-sound-sensorhttps://core-electronics.com.au/tutorials/sound-reactive-lights-makecode-circuit-playground-express-tutorial.htmlhttps://learn.adafruit.com/bosebuild-reactive-sound/uploading-the-codehttps://learn.adafruit.com/adafruit-circuit-playground-express/playground-sound-meterhttps://core-electronics.com.au/tutorials/sound-reactive-lights-circuitpython-circuit-playground-express-tutorial.html

Embedded Systems Page 97

Page 98: Overview - Through The Classroom Door...•Overview •What is CircuitPython? •Frequently Asked Questions •Installing Mu Editor •Installing CircuitPython •The CIRCUITPY Drive

Copy this whole section to your OneNote Space & then fill it in

Servo MotorsThere are two types of servo motors:- 180 Degree- 360 Degree Continuous rotation

180 DegreeThese are the most common in embedded system projects. They can turn 90 degrees left or right. It is given an angle to proceed to rather than a speed and direction

ServosThursday, 21 March 2019 9:53 AM

Embedded Systems Page 98

Page 99: Overview - Through The Classroom Door...•Overview •What is CircuitPython? •Frequently Asked Questions •Installing Mu Editor •Installing CircuitPython •The CIRCUITPY Drive

360 Degree Continuous rotationThese can spin 360 degrees in either direction. They can also be given a speed at which to spin.

1. functional non-functional requirements

definition and decomposition of complex problems in terms of functional and non functional requirements

- defined functional requirements and decomposed Input, Processing, Output (IPO) chart

- defined non-functional requirements and decomposed the user experience

Functional Requirements - Input, process, output (IPO) table

The starter Algorithm we will use:

Embedded Systems Page 99

Page 100: Overview - Through The Classroom Door...•Overview •What is CircuitPython? •Frequently Asked Questions •Installing Mu Editor •Installing CircuitPython •The CIRCUITPY Drive

Input (event/data) Processing (coding) Output (action)

Non-functional requirements - UI and UX

Outline what the user interface (UI) and user experience(UX) will be like? Use the information below as a guide.

Your response here

2. User Experience and Algorithm

Embedded Systems Page 100

Page 101: Overview - Through The Classroom Door...•Overview •What is CircuitPython? •Frequently Asked Questions •Installing Mu Editor •Installing CircuitPython •The CIRCUITPY Drive

design and evaluation of user experiences and algorithms

- sketched the user experience

- designed the algorithm in makecode

- evaluated the user experience to recommend changes

- evaluated algorithm to refine and make more efficient

Sketch what the user experience will be like.

Your response here

Example

Embedded Systems Page 101

Page 102: Overview - Through The Classroom Door...•Overview •What is CircuitPython? •Frequently Asked Questions •Installing Mu Editor •Installing CircuitPython •The CIRCUITPY Drive

Algorithm

Paste a screenshot from MakeCode

How would you refine your algorithm and make it more efficient? Loop?

Your response here

UX Recommendations

How would you modify the User Experience (UX)? What does the photon block do?

Your response here

3. Testing algorithm

Embedded Systems Page 102

Page 103: Overview - Through The Classroom Door...•Overview •What is CircuitPython? •Frequently Asked Questions •Installing Mu Editor •Installing CircuitPython •The CIRCUITPY Drive

testing and prediction of results and implementation of digital solutions

- tested and refined make code algorithm, taking care to record iterations

Refined Algorithm

How did you refine and improve your algorithm to make it more efficient?

Your response here

4. Implement with Circuitpython

design and implementation of modular programs, including an object-oriented program, using algorithms and data structures involving modular functions that reflect the relationships of real-world data and data entities

- implemented the solution in circuit python

Resourceshttps://learn.adafruit.com/using-servos-with-circuitpython/circuitpythonhttps://learn.adafruit.com/adafruit-circuit-playground-express/circuitpython-servohttps://learn.adafruit.com/lucky-cat-with-circuit-playground-express/code-with-circuitpython

Embedded Systems Page 103

Page 104: Overview - Through The Classroom Door...•Overview •What is CircuitPython? •Frequently Asked Questions •Installing Mu Editor •Installing CircuitPython •The CIRCUITPY Drive

Servos and Pulse Width Modulation (PWM)

Analog vs Digital SignalsMost coding will be using digital electrical signals, with just two discrete levels. In terms of Digital Out, the signal is either high (1 or on) or low (0 or off). Figure 4-28 is a visual representation of a digital signal that alternates between high and low.

Unlike digital signals, analog signals can vary with an indefinite number of steps between high and low. For example, Figure 4-29 shows an analog signal of a sine wave. Notice in the figure that as time progresses, the voltage moves fluidly between high and low levels.

Pulse-width Modulation (Outputs)Another way to generate analog signals is with a technique called pulse-width modulation (or PWM). Like using a digital to analog converter you can use PWM to control the voltage output by a pin. However PWM is actually using a very high speed digital signal (either on or off, never in-between) to approximate an analog value.

Frequency and Duty CycleThe digital "pulse" that is used to simulate an analog signal, will "pulse" at a specific frequency. We can specify the frequency of the PWM signal in hertz. The default is 500 hz, or 500 times a second.The duty cycle is the percent of time that it’s held at a high vs. low signal. The default is 0, or a completely low / off signal, and can be any 16-bit unsigned value.

Before you control the PWM output you’ll want to understand how frequency and duty cycle affect the output signal. As mentioned earlier a PWM output isn’t actually an analog signal in the truest sense of the word–at no point is a PWM output any voltage in-between fully on (~3.3V) or off (0V / ground). However a PWM output can appear to many devices to be an in-between voltage by very quickly turning itself on and off.Imagine flicking a light switch on and off very quickly, like 30 times a second. The light bulb would be changing so quickly your eyes might not even see the change from on to off and back on again–it would appear to be solidly lit at a moderate brightness. Now imagine as you’re quickly turning the light on and off you hold it on slightly longer than you hold it off. The light would appear to be brighter because it’s turned on more often than it’s turned off! Likewise if you hold the switch off very slightly longer than on you would

Embedded Systems Page 104

Page 105: Overview - Through The Classroom Door...•Overview •What is CircuitPython? •Frequently Asked Questions •Installing Mu Editor •Installing CircuitPython •The CIRCUITPY Drive

turned off! Likewise if you hold the switch off very slightly longer than on you would see the light grow dimmer. Your eyes are effectively ‘averaging out’ the fast changes and seeing the light’s overall brightness change. Remember at no point is the light actually in-between fully on or off–if your eyes were fast enough they would actually see the light as flickering on and off!

With a PWM output the frequency is the rate at which the signal turns on and off. Typically you set this to a high value that’s much faster than the device you’re connected to can see or measure. For a LED any value greater than about 60-100hz is enough to appear to the human eye as unchanging. For other devices like servos they might expect a very specific PWM frequency like 50hz.Duty cycle is the percent of time that a part of the PWM signal is fully on vs. fully off. Think of duty cycle like a knob you can twist from 0 to 100%, where at 0% the signal is always turned off and never turns on, at 50% the signal is on for exactly as much time as it’s off, and at 100% it’s always turned on. You can adjust the duty cycle to any in-between value, like 33.33%, to have the signal turned on for 1/3 of the time and turned off for the remaining 2/3 of the time. By manipulating the duty cycle you have similar control as if you were adjusting the voltage output by the pin!

To further illustrate how PWM is different from true analog output, look at the image below which shows oscilloscope output of a PWM signal at different duty cycles (0%, 25%, 50%, 75%, and 100%). Notice how as the duty cycle increases the amount of time the signal is at a high logic level (3.3V) gets longer. At 50% duty cycle the signal is high for twice as long as at 25% duty cycle (compare how long the tops of each wave are to check for yourself). At the extremes of 0% and 100% you can also see the signal never changes and is always at a high or low level!

From <https://learn.adafruit.com/circuitpython-basics-analog-inputs-and-outputs/pulse-width-modulation-outputs>

Not every device can work with or ‘see’ the varying voltages output with PWM, but many devices like LEDs and servos work great with PWM. The advantage of using PWM is that it typically doesn’t need special hardware from the microprocessor like with a digital to analog converter. In many cases you can use any digital output as a PWM output

There's two ways to control servos, one is lower-level - where you will control the PWM pin directly. And one is higher-level using the Motor Library. We will use the later. In order to use servos, we take advantage of pulseio (for PWM) and we will use adafruit_motor which manages servos.

adafruit_motoris a library so be sure to grab it from the library bundle if you have not yet! If you need help installing the library, check out

the CircuitPython Libraries page.

Servo CodeHere's an example that will sweep a servo connected to pin A2 from 0 degrees to 180 degrees and back:

import timeimport boardimport pulseiofrom adafruit_motor import servo

# create a PWMOut object on Pin A2.

Embedded Systems Page 105

Page 106: Overview - Through The Classroom Door...•Overview •What is CircuitPython? •Frequently Asked Questions •Installing Mu Editor •Installing CircuitPython •The CIRCUITPY Drive

# create a PWMOut object on Pin A2.pwm = pulseio.PWMOut(board.A2, duty_cycle=2 ** 15, frequency=50)

# Create a servo object, my_servo.my_servo = servo.Servo(pwm)

while True:for angle in range(0, 180, 5): # 0 - 180 degrees, 5 degrees at a time.my_servo.angle = angletime.sleep(0.05)for angle in range(180, 0, -5): # 180 - 0 degrees, 5 degrees at a time.my_servo.angle = angletime.sleep(0.05)

Note that we assume that 0 degrees is 0.5ms and 180 degrees is a pulse width of 2.5ms.

From <https://learn.adafruit.com/adafruit-circuit-playground-express/circuitpython-servo>

Alternative Code

import timeimport boardimport pulseiofrom adafruit_motor import servo

# create a PWMOut object on Pin A1pwm = pulseio.PWMOut(board.A1, frequency=50)

# Create a servo object, my_servomy_servo = servo.Servo(pwm)

while True:for angle in range(50): # 0 to 49 degrees in 1 deg stepsmy_servo.angle = angletime.sleep(0.005) # Tiny delay each stepstime.sleep(0.25) # More time at end of arm downfor angle in range(50, 0, -1): # 50 to 0 degrees in 1 deg stepsmy_servo.angle = angletime.sleep(0.005)time.sleep(0.25) # More time when arm up

From <https://learn.adafruit.com/lucky-cat-with-circuit-playground-express/code-with-circuitpython>

Python Code

Implement your solution in CircuitPython code.

Test it

Copy your code and use # comments to explain what each line does.

Copy and paste your Python code here

5. Evaluate

evaluation of information systems and their solutions in terms of risk, sustainability and potential for innovation and enterprise

1. evaluated enterprise needs and opportunities

2. evaluated innovation3. evaluated sustainability4. made recommendations

Embedded Systems Page 106

Page 107: Overview - Through The Classroom Door...•Overview •What is CircuitPython? •Frequently Asked Questions •Installing Mu Editor •Installing CircuitPython •The CIRCUITPY Drive

4. made recommendations

Evaluate

Enterprise needs and opportunitiesWhat needs or opportunities does the solution address? How well does it address these?

InnovativeHow is the digital solution innovative? What potential impact does it have?

SustainabilityWhat is the lifespan of your solution? How long before better technology arrives and it is obsolete?

Is your solution easy to use and learn? Why/Why not?

RecommendationsRecommend at least one improvement that you would like to see made to the digital solution. Why?

Your response here

Resourceshttps://learn.adafruit.com/adafruit-circuit-playground-express/circuitpython-servohttps://learn.adafruit.com/lucky-cat-with-circuit-playground-express/code-with-circuitpythonhttps://learn.adafruit.com/cardboard-box-for-circuit-playground-expresshttps://learn.adafruit.com/makey-paper-crafthttps://learn.adafruit.com/Cardboard-Robot-Inchworm/overviewhttps://learn.adafruit.com/spinning-logo

Embedded Systems Page 107

Page 108: Overview - Through The Classroom Door...•Overview •What is CircuitPython? •Frequently Asked Questions •Installing Mu Editor •Installing CircuitPython •The CIRCUITPY Drive

This is optional

https://learn.adafruit.com/adafruit-circuit-playground-express/playground-temperature

TemperatureTuesday, 26 March 2019 11:27 AM

Embedded Systems Page 108

Page 109: Overview - Through The Classroom Door...•Overview •What is CircuitPython? •Frequently Asked Questions •Installing Mu Editor •Installing CircuitPython •The CIRCUITPY Drive

Copy this whole section to your OneNote Space & then fill it in

This is your Assessment Task

Item 2Embedde...

Ideation

These are some reasonably challenging projects: please choose one.

https://learn.adafruit.com/circuit-playground-express-ir-zombie-game

https://learn.adafruit.com/circuit-playground-treasure-hunt

Mini - ProjectThursday, 21 March 2019 9:53 AM

Embedded Systems Page 109

Page 110: Overview - Through The Classroom Door...•Overview •What is CircuitPython? •Frequently Asked Questions •Installing Mu Editor •Installing CircuitPython •The CIRCUITPY Drive

https://learn.adafruit.com/circuit-playground-treasure-hunt

https://learn.adafruit.com/circuit-playground-sound-controlled-robot/introduction

Scamper

Use Scamper to brainstorm a list of fresh ideas that develop and improve the original

Your response here

1. Define functional non-functional requirements

definition and decomposition of complex problems in terms of functional and non functional requirements

Embedded Systems Page 110

Page 111: Overview - Through The Classroom Door...•Overview •What is CircuitPython? •Frequently Asked Questions •Installing Mu Editor •Installing CircuitPython •The CIRCUITPY Drive

- defined functional requirements and decomposed Input, Processing, Output (IPO) chart

- defined non-functional requirements and decomposed the user experience

Define and clarify the problemrestate the problem in your own words.a.- You will need to either research established technology and the problem it solves, that you can improve or find a new problem that can be solved with a wearable. Eg holding a phone to navigate, which is inconvenient or could be stolenidentify fundamental cause of a problem or to represent related elements of a problem that need to be jointly addressed in th e digital solutionb.what is required in the solution. Why?c.what are the mandatory constraints?d.what will be produced as a solution?e.how will it be used? How is it interactive?f.

Functional Requirements - Input, process, output (IPO) table

Input (event/data) Processing (coding) Output (action)

Non-functional requirements - UI and UX

Outline what the user interface (UI) and user experience(UX) will be like? Use the information below as a guide.

Your response here

2. Design User Experience and Algorithm

Embedded Systems Page 111

Page 112: Overview - Through The Classroom Door...•Overview •What is CircuitPython? •Frequently Asked Questions •Installing Mu Editor •Installing CircuitPython •The CIRCUITPY Drive

design and evaluation of user experiences and algorithms

- sketched the user experience

- designed the algorithm in makecode

- evaluated the user experience to recommend changes

- evaluated algorithm to refine and make more efficient

Sketch what the user experience will be like.

Your response here

Example

Embedded Systems Page 112

Page 113: Overview - Through The Classroom Door...•Overview •What is CircuitPython? •Frequently Asked Questions •Installing Mu Editor •Installing CircuitPython •The CIRCUITPY Drive

Algorithm

Paste a screenshot from MakeCode

How would you refine your algorithm and make it more efficient?

Your response here

UX Recommendations

How would you modify the User Experience (UX)

Your response here

3. Testing algorithm

Embedded Systems Page 113

Page 114: Overview - Through The Classroom Door...•Overview •What is CircuitPython? •Frequently Asked Questions •Installing Mu Editor •Installing CircuitPython •The CIRCUITPY Drive

testing and prediction of results and implementation of digital solutions

- tested and refined make code algorithm, taking care to record iterations

Refined Algorithm

How did you refine and improve your algorithm to make it more efficient?

Your response here

4. Implement with Circuitpython

design and implementation of modular programs, including an object-oriented program, using algorithms and data structures involving modular functions that reflect the relationships of real-world data and data entities

- implemented the solution in circuit python

Python Code

Copy your code and use # comments to explain what each line does.

Copy and paste your Python code here

5. Evaluate

Embedded Systems Page 114

Page 115: Overview - Through The Classroom Door...•Overview •What is CircuitPython? •Frequently Asked Questions •Installing Mu Editor •Installing CircuitPython •The CIRCUITPY Drive

evaluation of information systems and their solutions in terms of risk, sustainability and potential for innovation and enterprise

1. evaluated enterprise needs and opportunities

2. evaluated innovation3. evaluated sustainability4. made recommendations

Evaluate

Enterprise needs and opportunitiesWhat needs or opportunities does the solution address? How well does it address these?

InnovativeHow is the digital solution innovative? What potential impact does it have?

SustainabilityWhat is the lifespan of your solution? How long before better technology arrives and it is obsolete?

Is your solution easy to use and learn? Why/Why not?

RecommendationsRecommend at least one improvement that you would like to see made to the digital solution. Why?

Your response here

Embedded Systems Page 115

Page 116: Overview - Through The Classroom Door...•Overview •What is CircuitPython? •Frequently Asked Questions •Installing Mu Editor •Installing CircuitPython •The CIRCUITPY Drive

All about circuit python https://learn.adafruit.com/adafruit-circuit-playground-express

https://learn.adafruit.com/adafruit-circuit-playground-express/circuitpython-quickstart

https://learn.adafruit.com/category/micropython-slash-circuitpython

https://circuitpython.readthedocs.io/en/3.x/

https://learn.adafruit.com/category/circuitpython

https://learn.adafruit.com/welcome-to-circuitpython

https://learn.adafruit.com/circuitpython-essentials

https://learn.adafruit.com/adafruit-circuit-playground-express/circuitpython-playgroundhttps://cdn-learn.adafruit.com/downloads/pdf/circuitpython-made-easy-on-circuit-playground-express.pdf

https://cdn-learn.adafruit.com/downloads/pdf/adafruit-circuit-playground-express.pdf

Circuitpython resources listed in github

https://github.com/adafruit/awesome-circuitpython

https://github.com/adafruit/Adafruit_Learning_System_Guides/tree/master/CircuitPython_Essentials

A couple of projects involving makecode

https://core-electronics.com.au/tutorials/natural-disaster-sensor-project-adafruit-circuit-playground-express-tutorial-makecode.html

https://core-electronics.com.au/tutorials/ir-controlled-lights-with-circuitpython-adafruit-circuit-playground-express-tutorial.html

https://core-electronics.com.au/tutorials/circuit-playground-express-workshop-for-beginners-and-educators.html

Block based coding https://makecode.adafruit.com/

https://learn.adafruit.com/category/makecode

https://makecode.adafruit.com/examples/

https://www.python.org/

ResourcesWednesday, 13 March 2019 7:57 AM

Embedded Systems Page 116