Notice. New forum software under development. It's going to miss a few functions and look a bit ugly for a while, but I'm working on it full time now as the old forum was too unstable. Couple days, all good. If you notice any issues, please contact me.
|
Forum Index : Microcontroller and PC projects : picomite PWM
Author | Message | ||||
Bill.b Senior Member Joined: 25/06/2011 Location: AustraliaPosts: 226 |
Need some help with the following program for a train controller using HC-06 bluetooth module. Bluetooth working OK,the problem is the PWM control not accepting the setpin. 'Bluetooth Train control for the picomite and HC-06 bluetooth module '28/01/2024 'Bill Brown Option colourcode on Option autorun on Option DEFAULT NONE Dim aa$ Dim integer c(4),x dim integer FWDSelect dim integer REVSelect dim integer counter1 SetPin GP22, Dout setpin gp5, dout setpin gp6, dout setpin gp7, dout setpin gp8, dout setpin gp9, dout SetPin GP12, pwm6A SetPin GP10, pwm5A counter1 = 0 '-------------------------------------------- SetPin GP0, Gp1, com1 Open "com1:9600,256,intmenu, 2" As #1 Do Loop '********* Bluetooth selection from HC-06 ********************** Sub intmenu aa$=(Input$(2,#1)) x = Val(aa$) Print "x= "x, Pause 100 Select Case x Case 11 'Light ON print "1", ' pin GP5 = 1 Case 22 'Light OFF print "2", ' pin GP5 = 0 Case 33 'Smoke ON print "3", pin GP6 = 1 pin GP7 = 0 Case 44 'Smoke OFF print "4", pin GP6 = 0 pin GP7 = 0 Case 55 'Forward print "5", FWDSelect = 1 RevSelect = 0 Case 66 'Reverse print "6", FWDSelect = 0 RevSelect = 1 Case 77 'Train Stop PWM 5 OFF PWM 6, OFF Case 88 ' increase Train Speed If FWDSelect = 1 then counter1 = counter1 + 10 if counter1 > 100 then counter1 = 100 endif endif print "8", print Counter1 PWM 6,1000,,counter1 PWM 5, OFF Case 99 'Decrease Train Speed print "9", If REVSelect = 1 then counter1 = counter1 - 10 if counter1 < 0 then counter1 = 0 endif endif print counter1 PWM 5,1000,,counter1 PWM 6, OFF end select End Sub ************************************************* Maximite Control Centre Build date: 2023/10/13 Data server on port 50900 started Control server on port 50899 started started D:\mmfiles\TrainControl.bas Uploading using: 'target port\COM11: s\ Upload started Connected to COM11 at NEW > > AUTOSAVE Upload completed 1 Saved 1560 bytes > Time taken: 3235mS RUN x= 55 5 x= 88 8 10 [71] PWM 6,1000,,counter1 Error : Pin not set for PWM > Bill In the interests of the environment, this post has been constructed entirely from recycled electrons. |
||||
TassyJim Guru Joined: 07/08/2011 Location: AustraliaPosts: 6098 |
Remove the second comma PWM 6,1000,counter1 It thinks you have 6B configured. Same for 5B later in the code. Jim VK7JH MMedit MMBasic Help |
||||
Bill.b Senior Member Joined: 25/06/2011 Location: AustraliaPosts: 226 |
Thanks Jim That did the trick. Working OK now. Bill In the interests of the environment, this post has been constructed entirely from recycled electrons. |
||||
Print this page |