Shop OBEX P1 Docs P2 Docs Learn Events
Protoboard inside v5.1 Skywalker RC Airplane — Parallax Forums

Protoboard inside v5.1 Skywalker RC Airplane

xanaduxanadu Posts: 3,347
edited 2012-12-02 10:03 in Robotics
First project LED lighting


So the code is optimized to make the whole prop the LED controller, as I add new things that will need to shrink down, pins and cogs.
{{

Airplane Anti-Collision, Position, and Nav light testing

}}

CON

 _clkmode = xtal1 + pll16x  
 _xinfreq = 5_000_000


VAR

 long beacons [100] 'stack space
 long strobess [100] 'stack space


PUB main

                   'enable output pins
 dira[16] := 1     'green nav 
 dira[17] := 1     'land/taxi
 dira[18] := 1     'red nav
 dira[19] := 1     'white pos
 dira[20] := 1     'beacon/AC
 dira[21] := 1     'strobes


 cognew(beacon, @beacons)
 cognew(strobes, @strobess) 

 repeat
  
  outa[16] := 1    
  outa[17] := 1    
  outa[18] := 1  
  outa[19] := 1    
     
   
     
    
PUB beacon

 dira[20] := 1     'beacon/AC


  repeat

   outa[20] := 1
   waitcnt (clkfreq / 10 + cnt)
   outa[20] := 0
   waitcnt (clkfreq * 1 + cnt)


PUB strobes

 dira[21] := 1     'strobes   
 
repeat
  
  outa[21] := 1
  waitcnt(clkfreq / 10 + cnt)
  
  outa[21] := 0
  waitcnt(clkfreq / 10 + cnt)
  
  outa[21] := 1
  waitcnt(clkfreq / 10 + cnt)
  
  outa[21] := 0
  waitcnt(clkfreq / 10 + cnt)
  
  outa[21] := 1
  waitcnt(clkfreq / 10 + cnt)

  outa[21] := 0
  waitcnt(clkfreq / 10 + cnt)

  outa[21] := 1
  waitcnt(clkfreq / 10 + cnt)
  
  outa[21] := 0
  waitcnt(clkfreq * 2 + cnt)   

Comments

Sign In or Register to comment.