::: Pro-Business :::
Wednesday, March 10, 2010
You are here: Home
   
 
Location: BlogsGeek Speak :)Project: Adventurers' Club Masks    
Posted by: Rembrandt 4/3/2007 1:20 PM
With a little more tinkering, I got the code fairly close to a 'double blink' with the servo. [With the beginnings of serial out as well, I might take a little stab at a windows program to read what the pic is sending out and update an image on the screen or something .. the beginnings of a controll program.

Since I have done a lot of talking about stuff, with out much concrete examples, I decided the otherday to start pasting up code. That way I can not only show others, but have some place to go find it if i lose my project :P

So, here is the 'blink' routine, which is written for the PIC 16F874-A

'****************************************************************
'*  Name    : Futaba s3003 RC Servo Test 'Blink-Blink
'*  Author  : Steven Ivan Walk                                     
'*  Notice  : Freely given from www.Code-Geek.com  
'*          :                                                                     
'*  Date    : 4/3/2007                                                   
'*  Version : 1.1                                                          
'*  Notes   : PIC 16F874-A,                                       
'*          : Pin 20 = Servo Control Out                          
'*          : Pin 21 = LED indicator Out                          
'*          : Pin 40 = Serial Communication Out              
'*          : 4.00 hz Crystal                                             
'****************************************************************
DEFINE OSC 4
start:
    high portd.2
    pulseWidth var byte
    ' set up constants with the minimum and maximum pulsewidths
    minPulse CON 50
    maxPulse CON 100
    ' set up a constant with the time between pulses:
    refreshPeriod CON 20
    looper var word
    outerlooper var word
    ' set an initial pulsewidth:
    pulseWidth = minPulse

main:
for outerlooper = 1 to 2
    'take the output pin low so we can pulse it high
    Low PORTd.1
    ' pulse the pin
    for looper = 1 to 12
        PulsOut PORTd.1, pulseWidth
        ' pause for as long as needed:
        Serout2 portb.7, 16468, [DEC pulsewidth,10,13]
        Pause refreshPeriod
    next

    Low PORTd.1
    ' pulse the pin
    for looper = 1 to 12
        PulsOut PORTd.1, maxpulse
        ' pause for as long as needed:
        Serout2 portb.7, 16468, [DEC maxpulse,10,13]
        Pause refreshPeriod
    Next
    pause 250
Next   
pause 2000
Serout2 portb.7, 16468, ["looping",10,13]
GoTo main
Permalink |  Trackback





 Blog History Minimize


    

Privacy Statement | Terms Of Use
Copyright 2005 by My Website