Arduino Sketches

This page has links to Arduino sketches developed as demonstrations for Invention Bootcamp.

You can download a zip archive of complete set of sketches at once.

Table of contents

  1. LED Blinking
  2. Light Sensor and Nightlight Demo
  3. NeoPixel Codes
  4. Hand washing timer
  5. Button Input
  6. Accelerometer measurements
  7. Temperature measurements
  8. HC-SR04 Ultrasonic Sensor
  9. External Micro-OLED Displays
  10. Servo Motors

LED Blinking

  • Slightly rewritten version of the library code Blink.ino
  • Blink one of the NeoPixels on the Circuit Playground with BlinkNeoPixel.ino

Light Sensor and Nightlight Demo

The following codes use the on-board light sensor and NeoPixels on the Circuit Playground

  • Read and print the value of the light sensor on a Circuit Playground with CP_LightSensor.ino
  • Use ambient light levels from the Circuit Playground light sensor to create a nightlight with nightlight1.ino

NeoPixel Codes

The following codes work with the Circuit Playground

Hand washing timer

Button Input

The Circuit Playground Classic does not expose the interrupt pins on the ATmel328 microcontroller. The following codes show how to

Accelerometer measurements

The following codes use the on-board accelerometer of an Circuit Playground

  • Use an accelerometer to turn on all Neopixels when the Circuit Playground is flipped over, fliplight.ino
  • Whitman’s demo that changes colors of the NeoPixels in response to tilting the Circuit Playground, TiltcolorPresentation.ino

Temperature measurements

The following codes use the on-board temperature sensor of the Circuit Playground

The following codes use an external TMP36 temperature sensor

HC-SR04 Ultrasonic Sensor

  • Read and print the values of an HC-SR04 ultrasonic sensor, CP_ping.ino

Details of connecting the HC-SR04 to a Circuit Playground are provided on a separate page.

External Micro-OLED Displays

Use an external micro-OLED display to show the system clock (as a demo). The display is connected via I2C and is compatible with most Arduino boards having I2C, including the Circuit Playground

Servo Motors

  • Move a servo motor back and forth, Sweep.ino

The following diagram shows how to connect a servo motor to a Circuit Playground.

Wiring for a servo motor