Home » Physical Computing » The Swinging LED
The Swinging LED
Final Project, Preliminary Work
November 20, 2002
 
I would call it a metronome if it didn't swing so haphazardly. But it does swing and light up. Next step: building a stronger arm with a better set of LEDs.

» Obligatory Frustration



» The Working Circuit (schematic soon)

» The Swinging LED in Action

» PIC Code

define OSC 4
include "modedefs.bas"
output PORTC.3
output PORTA.1
output PORTA.4
output PORTA.2

high PORTA.1
pause 500

'DEFINE ADC_BITS 8
'DEFINE ADC_CLOCK 3
'DEFINE ADC_SAMPLEUS 10
'input PORTA.5
'ADCON1 = %10000010

switchingperiod CON 90
pulseperiod CON 20
'pulseperiod VAR BYTE

' PORTA.1 => ENABLE     Motor Power
' PORTC.3 => PHASE      Directional Control

main:

    low PORTC.3
    
    low PORTA.1
    pause pulseperiod
    high PORTA.1
    pause switchingperiod
   
    high PORTC.3
    
    low PORTA.1
    pause pulseperiod
    high PORTA.1
    pause switchingperiod

    
goto main

Copyright © 2002 James G. Robinson
(and various collaborators, where noted).