Trigonometry Stuffy

This is a modification to the Night Light Stuffy code found in the project section.

 

To make the light more realistic, I wanted to have the LED pulse slowly from the off state to the on state. To make this gradual, I need to use a math function that many of you have studied: the sine function.

 

A sine wave is a oscillating pattern that repeats over a period of time. A basic sine function has is lowest value at -1 and its highest at +1. It rises and then falls, much like a pattern of say a heartbeat.

 

To mimic this pattern with an LED, the Lilypad needs some programming to help do this. A quick Google search turned up the exact model I needed -- thanks Sparkfun! https://www.sparkfun.com/tutorials/329

 

This link describes in detail how the sine function works and how to scale it for the inputs on a LED. There is a little bit of math here, so you might need a refresher in some trigonometry.

 

However, this is a great application of math and physical computing.

 

The end result was a version 2 of the Stuffy Night Light. I have posted this version 2 code here in Pastebin. The results? It seems to work pretty good.