Search this site
Embedded Files
Skip to main content
Skip to navigation
Afterschool Engineering
Home
Course Outline
About Mr. Jonathan
Electronics
Introduction to Electronics
Basic Electronics Video Series
Soldering and Tools
Voltage Divider and Transistor Circuits
LED Circuits
LED Star Maps
Aurora Bear LED Project
Lightbot
Electronics Projects
Liquid Light Fountain
Discrete Logic Circuits
Lessons
Goals
Code Examples
#1 :Meet MicroBit
#2 Basic Programming Challenges
Flow Control and Logic
#3: Neopixels Extension
#4: Using Arrays-the Magic 8-ball
#5- Robotic car
#6-Robotcar programming
#9: Varying Speed with Analog Write
#10: Ultrasonic Sensor
#11: Radio Control
#12: ServoMotors
#13: Line Sensors and Line Following
#14: Robot Swarms
#17- Events
Arcade Games
Arcade Game-Brilliant Labs
Controlling Physical Systems
Serial Communication with Microbit
Micropython
LED Matrix 7219
Microbit as HID Keyboard
Bluetooth Controller App
Projects
Project Ideas
Reka-Bit Projects
Science Buddies Microbit Projects
Neopixel Traffic Light
Infinity Mirror
Trundle Wheel
Plant watering Machine
Weather Station BME280
Data Logging for Physics
2-player Maze Game
Bowling Game
Music with MicroPython
Musical Rounds
Dancing with Robots
Smart House
Brilliant Labs Projects
Tech note: Data Logging: Sensor Monitor
Remote Servo
Tech Note: Capacitive Sensing
DF Mini Mp3 Player
Tech Note:Photogate
Parts List
Cardboard Robots
Internet of Things
What is the Internet of Things?
Thingspeak IOT
IOT Weather Station
Pictoblox Activities
Thingspeak IOT-Microbit
Blynk IOT ESP8266
AI Projects
AI with Pictoblox
Teachable Machine
AI Voice Control Module
Fixed Command Words
Huskylens AI Camera
Afterschool Engineering
Home
Course Outline
About Mr. Jonathan
Electronics
Introduction to Electronics
Basic Electronics Video Series
Soldering and Tools
Voltage Divider and Transistor Circuits
LED Circuits
LED Star Maps
Aurora Bear LED Project
Lightbot
Electronics Projects
Liquid Light Fountain
Discrete Logic Circuits
Lessons
Goals
Code Examples
#1 :Meet MicroBit
#2 Basic Programming Challenges
Flow Control and Logic
#3: Neopixels Extension
#4: Using Arrays-the Magic 8-ball
#5- Robotic car
#6-Robotcar programming
#9: Varying Speed with Analog Write
#10: Ultrasonic Sensor
#11: Radio Control
#12: ServoMotors
#13: Line Sensors and Line Following
#14: Robot Swarms
#17- Events
Arcade Games
Arcade Game-Brilliant Labs
Controlling Physical Systems
Serial Communication with Microbit
Micropython
LED Matrix 7219
Microbit as HID Keyboard
Bluetooth Controller App
Projects
Project Ideas
Reka-Bit Projects
Science Buddies Microbit Projects
Neopixel Traffic Light
Infinity Mirror
Trundle Wheel
Plant watering Machine
Weather Station BME280
Data Logging for Physics
2-player Maze Game
Bowling Game
Music with MicroPython
Musical Rounds
Dancing with Robots
Smart House
Brilliant Labs Projects
Tech note: Data Logging: Sensor Monitor
Remote Servo
Tech Note: Capacitive Sensing
DF Mini Mp3 Player
Tech Note:Photogate
Parts List
Cardboard Robots
Internet of Things
What is the Internet of Things?
Thingspeak IOT
IOT Weather Station
Pictoblox Activities
Thingspeak IOT-Microbit
Blynk IOT ESP8266
AI Projects
AI with Pictoblox
Teachable Machine
AI Voice Control Module
Fixed Command Words
Huskylens AI Camera
More
Home
Course Outline
About Mr. Jonathan
Electronics
Introduction to Electronics
Basic Electronics Video Series
Soldering and Tools
Voltage Divider and Transistor Circuits
LED Circuits
LED Star Maps
Aurora Bear LED Project
Lightbot
Electronics Projects
Liquid Light Fountain
Discrete Logic Circuits
Lessons
Goals
Code Examples
#1 :Meet MicroBit
#2 Basic Programming Challenges
Flow Control and Logic
#3: Neopixels Extension
#4: Using Arrays-the Magic 8-ball
#5- Robotic car
#6-Robotcar programming
#9: Varying Speed with Analog Write
#10: Ultrasonic Sensor
#11: Radio Control
#12: ServoMotors
#13: Line Sensors and Line Following
#14: Robot Swarms
#17- Events
Arcade Games
Arcade Game-Brilliant Labs
Controlling Physical Systems
Serial Communication with Microbit
Micropython
LED Matrix 7219
Microbit as HID Keyboard
Bluetooth Controller App
Projects
Project Ideas
Reka-Bit Projects
Science Buddies Microbit Projects
Neopixel Traffic Light
Infinity Mirror
Trundle Wheel
Plant watering Machine
Weather Station BME280
Data Logging for Physics
2-player Maze Game
Bowling Game
Music with MicroPython
Musical Rounds
Dancing with Robots
Smart House
Brilliant Labs Projects
Tech note: Data Logging: Sensor Monitor
Remote Servo
Tech Note: Capacitive Sensing
DF Mini Mp3 Player
Tech Note:Photogate
Parts List
Cardboard Robots
Internet of Things
What is the Internet of Things?
Thingspeak IOT
IOT Weather Station
Pictoblox Activities
Thingspeak IOT-Microbit
Blynk IOT ESP8266
AI Projects
AI with Pictoblox
Teachable Machine
AI Voice Control Module
Fixed Command Words
Huskylens AI Camera
Assignment #9: Varying Speed with Analog Write
Objective:
To learn to use analog Write/PWM to adjust the speed of motors
PinOuts of the MicroBit
If the enable pins are jumpered out or connected to +3V, the motors run at maximum speed
To adjust the speed we can use a PWM(Pulse Width Modulation) signal using the
analogWrite
command to vary the amount of power to the motor,
from 0 to 1023
Connect ENABLE A to Pin 0
Connect ENABLE B to Pin 1
What happens when A is pressed? When B is pressed?
Below: Demo code- speed ramps up from 0 to maximum
Example 2: Using Sound Sensor
Full Speed is 1023 (Analog Write)
Full Volume is 255(Analog Read)
So use Math Block to multiply sound level by 4
Report abuse
Page details
Page updated
Report abuse