3 Simple Ways to
Share What You Make

With Instructables you can share what you make with the world — and tap into an ever-growing community of creative experts.

PhotosPhotos

Share one or more photos of a project, recipe, or whatever you've made, quickly and easily.

Step by StepStep-By-Step

Share your step-by-step photos with text instructions of what you made so others can do it too!

VideoVideo

Share your how-to video. You'll need your embed code from a video site such as YouTube.

WowWee's Elvis Alive to The Elivinator Project

Step 29Eye fade in and out test

And now making the Elvinator Eye fade in and out test.

http://www.youtube.com/watch?v=ZG7pAvDf_xc

Here is the code for this:

' {$STAMP BS2}
' {$PBASIC 2.5}
' This program sets the brightness of the eye and fades in and the out
pwmduty VAR Byte
pwmout PIN 6 'LED connected to P6

'init
pwmduty=0 'set duty cycle to 0

runhigh:
DO WHILE pwmduty<255 'keep increasing dutycycle till 255 is reached
PWM PWMout, pwmduty,15 ' run to increase voltage to LED decrease last # for faster
pwmduty=pwmduty+1 'Increase duty cycle by 1
LOOP

runlow:
IF pwmduty>=255 THEN pwmduty=254 'set duty cycle to 254
DO WHILE pwmduty >=1 'continue to decrease voltage to LED
PWM pwmout,pwmduty,25 ' run to decrease voltage to LED increase last # for faster
pwmduty=pwmduty-1 'Decrease cycle by 1
LOOP
PAUSE 2000
GOTO runhigh 'start over
« Previous StepDownload PDFView All StepsNext Step »

Pro

Get More Out of Instructables

Already have an Account?

close

All Steps Viewing
View all steps of an Instructable on the same page when you're a Pro Member.

Upgrade to Pro today!
8
Followers
1
Author:GWJax
I love to make and hack into robots and make them do things that they are not designed for. Also I enjoy programming in PBasic for the Parallax Basic Stamps, I enjoy reading electronics books and I ma...
more »