Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Fork of testrcmotor by
Revision 1:a750fbe3305c, committed 2014-10-16
- Comitter:
- tsevcik08
- Date:
- Thu Oct 16 18:53:13 2014 +0000
- Parent:
- 0:88d8a50a003e
- Commit message:
- Arm servo code
Changed in this revision
| main.cpp | Show annotated file Show diff for this revision Revisions of this file |
--- a/main.cpp Thu Oct 09 18:01:03 2014 +0000
+++ b/main.cpp Thu Oct 16 18:53:13 2014 +0000
@@ -1,24 +1,37 @@
+//Code for the arm servo
+//Created 09 OCT 14, 3/C Stabler
+//Revised:
+// 16 OCT- Code works, needs smoothing out
#include "mbed.h"
#include "Servo.h"
-Servo dylan1(p21);
-DigitalIn sw1(p16);
+Servo arm(p21);
+DigitalIn sw1(p16); //up
+DigitalIn sw2(p17); //down
+
+int main(){
-int main()
-{
- float servopos;
- while (1) {
- if (sw1 == 1) {
- for (servopos = 0; servopos <= 1.0; servopos += 1.0) {
- dylan1 = servopos;
- }
- wait (1);
- } else if (sw1 == 0) {
- for (servopos = 1.0; servopos >= 0; servopos -=1.0) {
- dylan1 = servopos;
- }
- wait (1);
+ float armpos;
+
+ while(1){
+
+ if((sw1 == 1) && (sw2 == 0)){
+ armpos += .05;
+ arm = armpos;
+ wait(.1);
+ }
+ else if((sw1 == 0) && (sw2 == 0)){
+ arm = armpos;
+ wait(.1);
+ }
+ if((sw2 == 1) && (sw1 == 0)){
+ armpos -= .01;
+ arm = armpos;
+ wait(.05);
+ }
+ else if((sw2 == 0) && (sw1 == 0)){
+ arm = armpos;
+ wait(.1);
}
}
-}
-
+}
\ No newline at end of file
