![]() |
|
|||||||
| Homework Help Stuck on a textbook question or coursework? Cramming for a test and need help understanding something? Post your questions and attempts here and let others help. |
|
|
|
Thread Tools | Display Modes |
|
#1
|
|||
|
|||
|
K I am a TOTAL programming noob and i am having a hard time with this problem from my class. ANY help would be great! Here is the problem:
"Write a program with the following devices: An active-High LED on P0 (LED1) An active-High PB on P8 (PB1) Servo on P13 Program the controller to loop continuously and perform the following: - At run, the LED will be off and the servo will be fully CW. - When the PB is pressed, the LED will blink 10 times at a rate of once per second. - A count down will be shown on the screen. - After the 10 blinks, the servo will move fully CCW - When the button is released the servo will move back to CW immediately and the LED will be off. Here is what i have so far: ' {$STAMP BS2} ' {$PBASIC 2.5} duration VAR Word duration = 750 DO IF (IN8 = 1) THEN DEBUG "10" ,CR HIGH 0 PAUSE 500 LOW 0 PAUSE 1000 DEBUG "9" ,CR HIGH 0 PAUSE 500 LOW 0 PAUSE 1000 DEBUG "8" ,CR HIGH 0 PAUSE 500 LOW 0 PAUSE 1000 DEBUG "7" ,CR HIGH 0 PAUSE 500 LOW 0 PAUSE 1000 DEBUG "6" ,CR HIGH 0 PAUSE 500 LOW 0 PAUSE 1000 DEBUG "5" ,CR HIGH 0 PAUSE 500 LOW 0 PAUSE 1000 DEBUG "4" ,CR HIGH 0 PAUSE 500 LOW 0 PAUSE 1000 DEBUG "3" ,CR HIGH 0 PAUSE 500 LOW 0 PAUSE 1000 DEBUG "2" ,CR HIGH 0 PAUSE 500 LOW 0 PAUSE 1000 DEBUG "1" ,CR HIGH 0 PAUSE 500 LOW 0 PAUSE 1000 IF IN8 = 1 THEN IF duration > 500 THEN duration = duration - 25 ENDIF ENDIF PULSOUT 13, duration PAUSE 1000 ELSE PAUSE 1000 PULSOUT 13, 500 ENDIF LOOP Um the LED works fine, but i can get the servo to drive correctly. Its either always energized or it wont drive all the way to ccw or cw. Thanks for your help in advance! |
|
#3
|
||||
|
||||
|
I have removed the duplicates as retched has indicated. It is best if a thread is only posted once since all members can see all threads regardless of the sub-forum in which it is posted.
hgmjr |
|
#4
|
||||
|
||||
|
Are you using the BasicSTAMP Compiler?
Do you have to "LOOP DO" in your compiler or is it automatic? You want the count down to 1 then a step to the motor then repeat the countdown then 1 more step?
__________________
-rm- |
|
#5
|
|||
|
|||
|
Sorry about that guys ive been workin on this for awhile i am going nuts, yes i am using BASIC Stamp kit. Right now the push button activates the countdown and led blink and will drive the servo ccw and then cw. but as soon as i run the program the servo is wiggin out. then when i push the button it starts the blink etc. ideally once it runs then it stops until the button is depressed again, but the servo is constantly driving back and forth. I know its a problem with my code and not the servo...but not sure what i am doing wrong.
|
|
#6
|
||||
|
||||
|
It sounds like you have a floating pin.
Try assigning pin 13 LOW in the beginning. It is floating between high and low and the servo doesn't know what to do until the end of the countdown
__________________
-rm- |
|
#7
|
|||
|
|||
|
how do i do that?
|
|
#8
|
||||
|
||||
|
Code:
Setup:
CONFIGPIN SCHMITT, %0010000000000000
DO: 'continue your DO from here
Each number after the % is a pin starting at 16 going to 1. the last 0 means ALL pins
__________________
-rm- |
|
#10
|
|||
|
|||
|
no its just bs2, it wont do the configpin command
|
|
| Bookmarks |
| Tags |
| microcontroller, programming, question |
| Thread Tools | |
| Display Modes | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| 8051 architecture programming question | Eric90 | Embedded Systems and Microcontrollers | 5 | 03-18-2010 07:44 AM |
| Microcontroller programming in C | herc | Embedded Systems and Microcontrollers | 5 | 08-27-2009 05:58 AM |
| Embedded C programming in 8051 and PIC microcontroller | triplehdineshbabu | Embedded Systems and Microcontrollers | 1 | 02-16-2009 09:56 AM |
| Programming PIC32 Microcontroller Inputs | DancinNancy | Embedded Systems and Microcontrollers | 6 | 01-28-2009 06:03 PM |
| Need Help Programming PIC32 microcontroller | DancinNancy | Programmer's Corner | 0 | 01-28-2009 04:01 AM |