Arduino Playground is read-only starting December 31st, 2018. For more info please look at this Forum Post

Sketch Library

I'm merging this library into the Code Library This page will be left here in case people have linked to it, but any future sketches will be posted there.

Do you have a favorite function, utility or short sketch to demonstrate a particular technique? Add it to the this library. Code should be well commented so beginner programmers can follow it. If it's possible, it would be a good idea to try and "encapsulate" your idea into a function to facilitate easy cut and paste between programs.

Random Functions

  • randomHat() - choose every number from a "hat" before repeating
  • randomWalk(stepSize) - wander between endpoints at a specified rate

Smoothing Functions

  • smooth(data, filterVal, smoothedVal) - a low-pass filter smoothing function,
    useful for removing sensor jitter

  • digitalSmooth(data, smoothArrayName) - a digital low-pass filter smoothing function, useful for removing sensor jitter, and glitches

Mapping Functions

  • autoscale - scale a variable between two ranges using linear interpolation

  • fscale - a function to map a variable between two floating point ranges.
    Has a parameter to logarithmically favor either end of the output range

  • analog_to_range - function that reads a value from analog pin and converts it to a value in the specified range.

Frequency / Music Generation Functions

  • freqout(freq, duration) - a simple frequency generator

PWM Techniques

Sensor Techniques

Playground Home