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
- LED Blinking
- Light Sensor and Nightlight Demo
- NeoPixel Codes
- Hand washing timer
- Button Input
- Accelerometer measurements
- Temperature measurements
- HC-SR04 Ultrasonic Sensor
- External Micro-OLED Displays
- 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
- Blink one of the NeoPixels on the Circuit Playground with BlinkNeoPixel.ino
- Use NeoPixels to indicate temperature from the on-board temperature sensor, neopixel_temp_scale.ino
- Display status of a count-down timer with NeoPixels, and use buttons to add time to the timer, CP_countdown_timer.ino
Hand washing timer
- Original handWashTimer1.ino demonstrated in this YouTube video.
- Version compatible with Codebender handWashTimer_CB.ino
- Upgraded to use the slide switch to change the display handWashTimer_CB_upORdown.ino
Button Input
The Circuit Playground Classic does not expose the interrupt pins on the ATmel328 microcontroller. The following codes show how to
- Use left-right buttons to select a NeoPixel to light up, CP_button_up_down.ino
- Play tunes depending on which button is pressed with leftRightButtonsMusic.ino
- Display status of a count-down timer with NeoPixels, and use buttons to add time to the timer, CP_countdown_timer.ino
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
- Read and print the value of the on-board temperature sensor, Hello_Temperature.ino from Adafruit
- Use NeoPixels to indicate temperature from the on-board temperature sensor, neopixel_temp_scale.ino
The following codes use an external TMP36 temperature sensor
- Read and print the value of the TMP36 sensor reading, CP_read_TMP36.ino
- Read and print the instantaneous and running average of the TMP36 sensor reading, CP_read_TMP36_average_running.ino
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
- Show the system clock on a 128x32 microOLED display CP_micro_OLED_128x32_time.ino
- Show the system clock on a 128x64 microOLED display CP_micro_OLED_128x64_time.ino
- Show the system clock on a 128x64 microOLED display, compatible with Codebender CPCB_micro_OLED_128x64_time.ino
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.