The system detects the distance of the bike from the traffic behind. If the traffic behind approaches too close the bike, system generates an alert signal that alerts the cyclist for traffic behind. Moreover, with the help of an app, a cyclist can track the location from where he/she started the journey so that he/she can trace the location back. In addition this android app also helps a biker to flash ‘turn left’ or ‘turn right’ using buttons on a mobile app and generate ‘stop’ signal automatically as the cyclist applies break.
Dependencies: FXOS8700Q HCSR-04 Servo mbed
Revision 0:2f02c1515311, committed 2016-12-02
- Comitter:
- nrrathi
- Date:
- Fri Dec 02 20:34:22 2016 +0000
- Commit message:
- An embedded system that assists a cyclist on traffic conditions, positioning capabilities and wirelessly send traffic signals using LEDs. The system detects the distance of the bike from the traffic behind.
Changed in this revision
diff -r 000000000000 -r 2f02c1515311 FXOS8700Q.lib --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/FXOS8700Q.lib Fri Dec 02 20:34:22 2016 +0000 @@ -0,0 +1,1 @@ +http://developer.mbed.org/teams/Freescale/code/FXOS8700Q/#834488c11340
diff -r 000000000000 -r 2f02c1515311 HCSR04.lib --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/HCSR04.lib Fri Dec 02 20:34:22 2016 +0000 @@ -0,0 +1,1 @@ +https://developer.mbed.org/users/goeltanu/code/HCSR-04/#45864bd4599b
diff -r 000000000000 -r 2f02c1515311 Servo.lib --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Servo.lib Fri Dec 02 20:34:22 2016 +0000 @@ -0,0 +1,1 @@ +http://mbed.org/users/simon/code/Servo/#36b69a7ced07
diff -r 000000000000 -r 2f02c1515311 main.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main.cpp Fri Dec 02 20:34:22 2016 +0000 @@ -0,0 +1,100 @@ +#include "mbed.h" +#include "hcsr04.h" +#include "Servo.h" +#include "FXOS8700Q.h" +#include "math.h" +#define M_PI 3.1415926535 + +Serial pc(USBTX, USBRX); +Serial device (PTC15,PTC14); +HCSR04 usensor(A4,A5); +I2C i2c(PTE25, PTE24); +FXOS8700QAccelerometer acc(i2c, FXOS8700CQ_SLAVE_ADDR1); +DigitalOut RED (LED1); +DigitalOut GREEN (LED2); +DigitalOut BLUE (LED3); +int distance; //Variable to store distance from an object +int state = 0; +double pitch, roll; +const float alpha = 0.5; +double fxg = 0; +double fyg = 0; +double fzg = 0; +motion_data_counts_t acc_raw; + +void filter_accelerometer() +{ + double xg, yg, zg; + + acc.getAxis(acc_raw); + + xg = acc_raw.x; + yg = acc_raw.y; + zg = acc_raw.z; + + // low pass filter + fxg = xg * alpha + (fxg * (1.0 - alpha)); + fyg = yg * alpha + (fyg * (1.0 - alpha)); + fzg = zg * alpha + (fzg * (1.0 - alpha)); + + // pitch and roll calculations + roll = (atan2(-fyg, fzg)*180.0)/M_PI; + pitch = (atan2(fxg, sqrt(fyg*fyg + fzg*fzg))*180.0)/M_PI; + printf(" %0.2f %0.2f \r\n", roll, pitch); + } + +int main() +{ +acc.enable(); + GREEN = 1; + BLUE = 1; + RED = 1; + while(1) + { + usensor.start(); + wait_ms(0.0025); + distance = usensor.get_dist_cm(); + wait(0.5); + pc.printf(" distance = %d\r\n", distance); + if(distance <= 9 ) + { + device.printf("ALERT VEHICLE"); + } + filter_accelerometer(); + if (roll > 22.00 && pitch > 3.00 ) + { + GREEN = BLUE = 1; + RED = 0; + + wait(0.5); + RED = 1; + } + if(device.readable() > 0) + { + state = device.getc(); + pc.printf("Instruction: %i\n\r", state); + } + if (state == '1') + { + RED = BLUE = 1; + GREEN = 0; + wait(0.3); + GREEN = 1; + wait(0.3); + } + else if (state == '2') + { + RED = GREEN = 1; + BLUE = 0; + wait(0.3); + BLUE = 1; + wait (0.3); + } + else if (state == '3') { + RED = GREEN = 1; + BLUE = 1; + + } + + } +} \ No newline at end of file
diff -r 000000000000 -r 2f02c1515311 mbed.bld --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mbed.bld Fri Dec 02 20:34:22 2016 +0000 @@ -0,0 +1,1 @@ +http://mbed.org/users/mbed_official/code/mbed/builds/0ab6a29f35bf \ No newline at end of file