GroupA / Mbed 2 deprecated WaG_final

Dependencies:   mbed

Fork of Lab_6_WaG by GroupA

Committer:
spm71
Date:
Thu Apr 12 16:12:28 2018 +0000
Revision:
58:69f9a4607a16
Parent:
57:aef01bd9b3be
Child:
60:604c10531f58
Started whacker function

Who changed what in which revision?

UserRevisionLine numberNew contents of line
spm71 57:aef01bd9b3be 1 /******************************************************************************
spm71 57:aef01bd9b3be 2 * EECS 397
spm71 57:aef01bd9b3be 3 *
spm71 57:aef01bd9b3be 4 * Assignment Name: Lab 7: WaG
spm71 57:aef01bd9b3be 5 *
spm71 57:aef01bd9b3be 6 * Authors: Sam Morrison and Phong Nguyen
spm71 57:aef01bd9b3be 7 * File name: wag.cpp
spm71 57:aef01bd9b3be 8 * Purpose: Wag functions
spm71 57:aef01bd9b3be 9 *
spm71 57:aef01bd9b3be 10 * Created: 04/12/2018
spm71 57:aef01bd9b3be 11 * Last Modified: 04/12/2018
spm71 57:aef01bd9b3be 12 *
spm71 57:aef01bd9b3be 13 ******************************************************************************/
spm71 57:aef01bd9b3be 14
spm71 57:aef01bd9b3be 15 #include "mbed.h"
spm71 57:aef01bd9b3be 16 #include "io_pins.h"
spm71 57:aef01bd9b3be 17 #include "wag.h"
spm71 57:aef01bd9b3be 18 #include <stdlib.h>
spm71 57:aef01bd9b3be 19 #include <stdio.h>
spm71 58:69f9a4607a16 20 #include <string.h>
spm71 58:69f9a4607a16 21 #include <timer.h>
spm71 58:69f9a4607a16 22
spm71 58:69f9a4607a16 23 void gnoll() {
spm71 58:69f9a4607a16 24 int hit, miss;
spm71 58:69f9a4607a16 25 int a_num;
spm71 58:69f9a4607a16 26 int led_command;
spm71 58:69f9a4607a16 27 int sensor_no = 0 //change to match station
spm71 58:69f9a4607a16 28
spm71 58:69f9a4607a16 29 for (int i = 0; i < 15; i++) {
spm71 58:69f9a4607a16 30 a_num = rand() % 8;
spm71 58:69f9a4607a16 31 turn_to_target(stp_sensor_pos[a_num]);
spm71 58:69f9a4607a16 32 lzr_on();
spm71 58:69f9a4607a16 33 wait(LASER_DELAY);
spm71 58:69f9a4607a16 34 if (sensor_values[sensor_no + a_num] > PTHRESH) {
spm71 58:69f9a4607a16 35 led_command = 0x0500 + a_num;
spm71 58:69f9a4607a16 36 spi_send(as1107, led_command);
spm71 58:69f9a4607a16 37 }
spm71 58:69f9a4607a16 38
spm71 58:69f9a4607a16 39 clock_t start = clock();
spm71 58:69f9a4607a16 40 clock_t finish = clock();
spm71 58:69f9a4607a16 41 do {
spm71 58:69f9a4607a16 42 // check for whacker sensors
spm71 58:69f9a4607a16 43 finish = clock();
spm71 58:69f9a4607a16 44 } while (finish - start < VOLLEY_DELAY)
spm71 58:69f9a4607a16 45 }
spm71 58:69f9a4607a16 46
spm71 58:69f9a4607a16 47 }