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.
Dependencies: mbed
Fork of Lab_6_WaG by
wag.cpp
- Committer:
- phn10
- Date:
- 2018-04-17
- Revision:
- 59:6b3a52d87465
- Parent:
- 57:aef01bd9b3be
- Child:
- 60:604c10531f58
File content as of revision 59:6b3a52d87465:
/****************************************************************************** * EECS 397 * * Assignment Name: Lab 7: WaG * * Authors: Sam Morrison and Phong Nguyen * File name: wag.cpp * Purpose: Wag functions * * Created: 04/12/2018 * Last Modified: 04/12/2018 * ******************************************************************************/ #include "mbed.h" #include "io_pins.h" #include "wag.h" #include <stdlib.h> #include <stdio.h> #include <string.h> extern Timer t; void whack(int sensor_no, float * sensor_values) { bool sensor_registered = false; int sensor_no = // --> need to specify sensor_no // start timer for sensor reading t.start(); // keep reading until one of the sensor get laser pointed in while (!sensor_registered) { // read value of all gnoll sensor for (int i = 0; i < TGT_SENSOR_QUAN; i++) { // scan all 16 sensors into sensor_values array ana_scan_mux(sensor_values, TGT_SENSOR_QUAN * 2); } // detect which sensor get lasered on for (int i = 0; i < TGT_SENSOR_QUAN + sensor_no; i++) { if (sensor_values[i] > THRESHOLD_SIGNAL) sensor_registered = true; } // if (reading sensor timer expired) display error and freeze t.stop(); if (t.read() > EXPIRED_TIMER) { pc.printf("Error: Reading timer expired. See whack() function.\n"); while (1); } } // point whack’s laser to the corresponding sensor on it’s target array // activate whacker’s laser while (signal from corresponding sensor value > THRESHOLD_SIGNAL) { if (finding sensor timer expired) display error and freeze } activate corresponding indicator // waiting for gnoll laser to turn off to turn off while (gnoll’s laser turned on) {} // turn off laer gnoll lzr_off(); }