
Don't want to screw something by updating the code as Ivelin updated himself while I was writing so I am forking it.
Dependencies: LocalPositionSystem MMA8451Q Motor_Driver Sensors mbed
Fork of TDP_main by
Diff: sensor_measure.h
- Revision:
- 15:6453cd351452
- Parent:
- 12:bb21b76b6375
- Child:
- 16:3649eb1a056d
--- a/sensor_measure.h Wed Mar 11 14:00:37 2015 +0000 +++ b/sensor_measure.h Thu Mar 12 18:44:57 2015 +0000 @@ -17,17 +17,19 @@ #define _SENSOR_MEASURE_H #define NUMBER_SAMPLES 20 // NUMBER OF SAMPLES FOR SENSOR TESTING -#define NUMBER_SENSORS_REGULAR 2 // number for the array of sensors +#define NUMBER_SENSORS_REGULAR 8 // number for the array of sensors #define NUMBER_SENSORS_SQUARE 0 //define pinout for all the sensors -DigitalIn pin_right_right(PTD0); -DigitalIn pin_right_centre(PTD2); -DigitalIn pin_right_left(PTD2); -DigitalIn pin_left_right(PTD3); -DigitalIn pin_left_centre(PTD4); -DigitalIn pin_left_left(PTD5); -//InterruptIn in(PTD0); maybe more~? +DigitalIn pin_right_right_up(PTD0); +DigitalIn pin_right_left_up(PTD2); +DigitalIn pin_right_right_down(PTD2); +DigitalIn pin_right_left_down(PTD3); +DigitalIn pin_left_right_down(PTD4); +DigitalIn pin_left_left_down(PTD5); +//DigitalIn pin_left_right_up(); +//DigitalIn pin_left_left_up(); + //timer used by the sensor Timer sensorTimer; @@ -45,8 +47,14 @@ }sensor_data; -sensor_data right_right; -sensor_data right_centre; +sensor_data right_right_up; +sensor_data right_left_up; +sensor_data right_right_down; +sensor_data right_left_down; +sensor_data left_right_down; +sensor_data left_left_down; +sensor_data left_right_up; +sensor_data left_left_up; // and so on.... sensor_data *sensorArray [NUMBER_SENSORS_REGULAR]; //array just used for getting value out of the sensors, helps for iteration(see main program) @@ -55,18 +63,18 @@ void sensor_initialise () { int arrayBuilder = 0; //integer solely used for populating the array //right_right - right_right.pin = &pin_right_right; - right_right.blackValue = 2013; - right_right.whiteValue = 10000; - right_right.grayValue = 0; // 0 for all the non-square sensors - right_right.state = 0; //setting all sensors as black at begging - sensorArray [arrayBuilder++] = &right_right; //Array goes from rightmost to left, then centre? - right_centre.pin = &pin_right_centre; - right_centre.blackValue = 6000; - right_centre.whiteValue = 10000; - right_centre.grayValue = 0; - right_centre.state = 0; - sensorArray [arrayBuilder++] = &right_centre; + right_right_up.pin = &pin_right_right_up; + right_right_up.blackValue = 2013; + right_right_up.whiteValue = 10000; + right_right_up.grayValue = 0; // 0 for all the non-square sensors + right_right_up.state = 0; //setting all sensors as black at begging + sensorArray [arrayBuilder++] = &right_right_up; //Array goes from rightmost to left, then centre? + right_left_up.pin = &pin_right_left_up; + right_left_up.blackValue = 6000; + right_left_up.whiteValue = 10000; + right_left_up.grayValue = 0; + right_left_up.state = 0; + sensorArray [arrayBuilder++] = &right_left_up; //and contiune so on.. }