Sign in

username:

password:



Not a member?

Search basicx



Search tips

Subscribe to basicx



basicx by Keywords

Accelerometer | ADC | ADXL | Adxl20 | AVR | BasicStamp | BX-35 | BX28 | BX35 | COM3 | Compiler | Downloader | EEPROM | Electromagnet | GetADC | GP2D1 | GPS | I2C | IDE | Keypad | LCD | LCD+ | MIDI | Motors | Multitasking | Netmedia | Networking | PCB | PID | PlaySound | PWM | Relays | RTC | Servo | ShiftOut | SitePlayer | SPI | Stack | Timer | USB

Ads

Discussion Groups

Discussion Groups | BasicX | servo and bx

Discussion forum for the BasicX family of microcontroller chips.

servo and bx - limorgarcia - Oct 27 22:19:00 2003

Hey all,
I'm trying to run two servo motors with two pots. I am not sure of
how to code it so each set would run seperately. this is my code and
it doesn't work. what am i doing wrong?
thnx

dim minPulse as single ' the minimum pulseWidth
dim maxPulse as single ' the maximum pulseWidth
dim pulseWidth as single ' the servo's pulsewidth
dim pulseRange as single ' the range of possible pulses
dim sensorValue as integer ' for the pot Sub main()
call delay(0.5) ' start program with a half-second delay minPulse = 0.0015
maxPulse = 0.0022
pulseWidth = minPulse

pulseRange = maxPulse - minPulse

' the main loop:
do
sensorValue = getADC(13)
sensorValue2 = getADC(15)
debug.print "getADC(15)="; Cstr(getADC(15))

call pulseOut(12, pulseWidth, 1) if (getpin(15)<50) then
call secondServo()
end if

pulseWidth = minPulse + ((pulseRange * cSng(sensorValue)) / 1023.0) loop

End Sub

sub secondServo()
call pulseOut(8, pulseWidth, 1)

end sub






(You need to be a member of basicx -- send a blank email to basicx-subscribe@yahoogroups.com )


Re: servo and bx - limorgarcia - Oct 27 22:57:00 2003

thank you all, it is solved.
lg --- In , "limorgarcia" <limorgarcia@y...>
wrote:
> Hey all,
> I'm trying to run two servo motors with two pots. I am not sure of
> how to code it so each set would run seperately. this is my code
and
> it doesn't work. what am i doing wrong?
> thnx
>
> dim minPulse as single ' the minimum pulseWidth
> dim maxPulse as single ' the maximum pulseWidth
> dim pulseWidth as single ' the servo's pulsewidth
> dim pulseRange as single ' the range of possible pulses
> dim sensorValue as integer ' for the pot > Sub main()
> call delay(0.5) ' start program with a half-second delay > minPulse = 0.0015
> maxPulse = 0.0022
> pulseWidth = minPulse
>
> pulseRange = maxPulse - minPulse
>
> ' the main loop:
> do
> sensorValue = getADC(13)
> sensorValue2 = getADC(15)
> debug.print "getADC(15)="; Cstr(getADC(15))
>
> call pulseOut(12, pulseWidth, 1) > if (getpin(15)<50) then
> call secondServo()
> end if
>
> pulseWidth = minPulse + ((pulseRange * cSng(sensorValue)) / 1023.0) > loop
>
> End Sub
>
> sub secondServo()
> call pulseOut(8, pulseWidth, 1)
>
> end sub




(You need to be a member of basicx -- send a blank email to basicx-subscribe@yahoogroups.com )