this is

Dependencies:   mbed Servo Motor

Revision:
5:c2d2c1804d2e
Parent:
2:260539a94ad7
Child:
6:648b5e2ede73
--- a/main.cpp	Tue Oct 16 15:43:05 2018 +0000
+++ b/main.cpp	Fri Oct 19 14:13:50 2018 +0000
@@ -2,14 +2,16 @@
 #include "stdlib.h"
 #include "stdio.h"
 #include "Servo.h"
-
+#include "Motor.h"
 DigitalOut leds[4] = {p25, p24, p23, p28};
 DigitalOut ledz[2] = {p27,p26};
 DigitalIn button[4] = {p17, p18, p19, p20};
 Servo myservo(p21);
 Servo hmyservo(p22);
+Motor m(p29);
 float hpos;
 float pos;
+float f; //Motor speed
 int r; //used for randomly lighting LEDs
 int i; //counter
 int s; // seed
@@ -19,6 +21,7 @@
 int n; // preventatibe variable
 int o; // preventative variable
 int w = 0; //counter for successful attempts
+int x; //count the number of times the motor runs
 
 int main() {
     
@@ -115,8 +118,13 @@
     printf("you got %d out of 10 right!\n\r", w);
     
     if (w < 10) {//if, gun trigger
-    
-    
+       for (x=0; x<1; x++){
+        f = -1.0;
+        m.speed(f);
+        wait(3);
+        m.speed(-f);
+        wait(3);
+        }
         for (pos =0.0; pos<=10.0; pos=pos+10.0) {
             myservo=(pos/10.0);
             wait (0.07);