Tagged: buggy code
May 15, 2015 at 10:45 am #2216
Have made input A run motor 1 forward (if A is Hi then Motor 1 Forward else Motor 1 Stop) & input B run motor 2 forward but if I try to use inputs C & D to run 1 & 2 in reverse I get a wierd pulsing effect and they wont go in reverse??
Help pleaseMay 15, 2015 at 12:55 pm #2217
Crumbuggy code:May 15, 2015 at 1:04 pm #2219JosephKeymaster
I suspect as the program runs through the loop, both ‘else’ sections are being executed and turning the motor off, hence the pulsing.
You could fix this by adding an ‘if C low’ in the else section of the if A statement.
Alternatively, you could change the program so it deals with the four combinations of each input separately. So for motor 1:
A: HI C: LO — Motor 1 Forwards
A: LO C: HI — Motor 1 Reverse
A: LO C: LO — Motor 1 Stop
A: HI C: HI — Motor 1 Stop (or could set forward)
I’ve just enabled attachments, so you can now upload your program. I’ll try and attach and image now…
Hope this helps!
JosephMay 15, 2015 at 1:32 pm #2222
I’ll give it a try.
SteveMay 15, 2015 at 1:48 pm #2223JosephKeymaster
No problem 🙂
It looks like my Crumble file didn’t attach – will try again…May 16, 2015 at 4:40 pm #2241MikeParticipant
Depends a bit on what you have attached to A, B, C and D… What is the hardware setup? 🙂May 16, 2015 at 5:25 pm #2244
All sorted. The code that Joseph attached worked perfectly.
I have 4 little PTM switches on a board with one side of each commonly connected to a croc lead to be clipped to +ve the other 4 sides to crocs for clipping to A,B,C & DMay 16, 2015 at 5:47 pm #2245
- You must be logged in to reply to this topic.