Skip to content
Parallax Learn

Parallax Learn

  • Welcome
  • Tutorials
        • Tutorial Series head tag

          Tutorial Series
        • Tutorial Series

          The special, classroom-ready series pages are organized collections of tutorials for our most popular hardware and/or languages. The tutorials for each topic are conveniently accessible from a single page, shown in the order it is recommended that they be completed.
        • Robotics Series Head tag

          Robotics Series
        • Robotics Series

          • Artificial Intelligence
          • Cybersecurity: Radio Data tutorialCybersecurity
          • cyber:bot + Python
          • cyber:bot + MakeCode
          • Boe-Bot Tutorial SeriesBoe-Bot
          • Arduino Shield-Bot
          • ActivityBot with C TutorialsActivityBot + C
          • ActivityBot with BlocklyProp Tutorial SeriesActivityBot + BlocklyProp
          • Scribbler 3 Tutorial SeriesScribbler 3
        • Electronics & Programming Series Head tag

          Electronics & Programming Series
          • BS2 Board of Education Tutorial SeriesBS2 Board of Education
          • Propeller C-Language BasicsPropeller C Basics
          • FLiP Try-It Kit C Tutorial SeriesFLiP Try-It Kit + C
          • FLiP Try-It Kit BlocklyProp TutorialsFLiP Try-It Kit + BlocklyProp
          • Badge WX Tutorial SeriesBadge WX
          • Propeller BlocklyProp Basics and ProjectsPropeller BlocklyProp Basics
          • View All Tutorial Series »
        • Browse Tutorials
        • Browse Tutorials

          Individual tutorials sorted by robot or kit, and language.
        • By Robot or Kit
          • ActivityBot
          • SumoBot WX
          • Boe-Bot
          • Shield-Bot
          • cyber:bot
          • Badge WX
          • ELEV-8
          • ARLO
        • By Language
        • By Language

          • Propeller C
          • Arduino
          • BlocklyProp
          • PBASIC
          • Python
          • MakeCode
          • View All Tutorials »
  • Educators
  • Reference
  • Downloads
  • Home
  • All Courses
  • Sense Pushbutton Presses

Sense Pushbutton Presses

How it Works

How It Works

An oscilloscope is typically a separate piece of equipment.  If we were using one, it wouldn’t be necessary to change the code because the oscilloscope has its own processor for monitoring and displaying measurements.

This script started as button_light_blink from the Build and Test a Pushbutton activity’s Your Turn section.  Since the micro:bit is functioning as its own oscilloscope, calls to plot(volts(pin0), “y0”, volts(pin2), “y2”) are added before and after statements that check the pushbutton and change the LED light on/off states.  

Try This

In electronics, a “start pulse” from one device can cause on/off signals from another device.  Those signals might contain information, like binary communication data, or they might be something like the return waves from an ultrasonic ranging pulse (that measures distance).  To emulate these events, when the script you will use in this activity detects a button press, it will blink the light six times.  

  • Right-click button_led_blink_6x_with_plot.hex (below), and choose Save Link As…to download.

button_led_blink_6x_with_plot.hex

  • Click the micro:bit Python Editor’s Open button, then select and open button_led_blink_6x_with_plot.hex. 
  • Click Send to micro:bit.  
  • Click the three vertical dots  ⋮  by the Send to micro:bit button, and select Disconnect.
  • Start the CYBERscope:
    • Go back to the CYBERscope tab.
      If you already closed the CYBERscope tab, open a another tab and reopen cyberscope.parallax.com.  
    • Click the CYBERscope’s Connect button.
    • In the serial port dialog, select the port with mbed in its name, and then click Connect. 

Tests

  • Wait until the plotted dots reach (or wraps back around to) somewhere in the 2k to 4k range.
  • Press and hold the pushbutton for just a blink or two.
  • Verify that your plot resembles the one below.  
  • Again, before the first pushbutton press, you might notice the red Ch2 voltage trace is plotting irregularly in the 0.5 to 1.5 V range because P13 is an input that has not been set low or high.
  • See how the oscilloscope shows that the button level returned to 0 (not pressed), but the LED continues its on/off pattern for 6 repetitions?


Printer-friendly version
Script and Tests
Prev
Trigger on Rising or Falling Edges
Next

DISCUSSION FORUMS | PARALLAX INC. STORE

About | Terms of Use | Feedback: learn@parallax.com | Copyright©Parallax Inc. 2024

© 2025 Parallax Learn • Built with GeneratePress