Components and supplies
5V Relay Module
Arduino UNO
PVC Pipe 10mm ID x 300mm Lg (Bent)
Metal Ball 9.5mm
IR Sensor Module
Jumper wires (generic)
9V battery (generic)
Perma-Proto Breadboard Half Size
Tools and machines
Multi meter
Welding Machine
Soldering iron (generic)
Apps and platforms
Arduino IDE
Project description
Code
Arduino-UNO Code
arduino
1int obstaclePin3 = 3; // This is our input pin (Rotation) 2int obstaclePin4 3 = 4; // This is our input pin (Hand Sensor 1of4) 4int obstaclePin5 = 5; // This 5 is our input pin (Hand Sensor 2of4) 6int obstaclePin6 = 6; // This is our input 7 pin (Hand Sensor 3of4) 8int obstaclePin7 = 7; // This is our input pin (Hand 9 Sensor 4of4) 10 11int hasObstacle3 = HIGH; // HIGH MEANS OBSTACLE (Rotation) 12int 13 hasObstacle4 = LOW; // LOW MEANS NO OBSTACLE 14int hasObstacle5 = LOW; // LOW 15 MEANS NO OBSTACLE 16int hasObstacle6 = LOW; // LOW MEANS NO OBSTACLE 17int hasObstacle7 18 = LOW; // LOW MEANS NO OBSTACLE 19int fall = HIGH; // HIGH MEANS VEHICLE HAS NOT 20 FALLEN 21 22void setup() { 23 pinMode(LED_BUILTIN, OUTPUT); 24 pinMode(obstaclePin3, 25 INPUT); 26 pinMode(obstaclePin4, INPUT); 27 pinMode(obstaclePin5, INPUT); 28 29 pinMode(obstaclePin6, INPUT); 30 pinMode(obstaclePin7, INPUT); 31 pinMode(8, 32 OUTPUT); 33 pinMode(9, INPUT_PULLUP); 34 Serial.begin(9600); 35} 36 37void 38 loop() { 39 hasObstacle3 = digitalRead(obstaclePin3); //Reads the output of the 40 obstacle sensor from the 7th PIN of the Digital section of the arduino 41 hasObstacle4 42 = digitalRead(obstaclePin4); 43 hasObstacle5 = digitalRead(obstaclePin5); 44 45 hasObstacle6 = digitalRead(obstaclePin6); 46 hasObstacle7 = digitalRead(obstaclePin7); 47 48 fall = digitalRead(9); 49 50 if (fall == LOW) 51 { 52 Serial.println("Engine 53 Killed - fall"); 54 digitalWrite(LED_BUILTIN, HIGH); // Open the main scooter 55 KEY circuit 56 digitalWrite(8, LOW); // no power to relay 57 delay (5000); 58 59 digitalWrite(LED_BUILTIN, LOW); 60 digitalWrite(8, HIGH); // no power to 61 relay 62 } 63 else if (hasObstacle3 == HIGH) 64 { 65 Serial.println("Engine 66 is in running condition1"); 67 digitalWrite(LED_BUILTIN, LOW);//Illuminates 68 the 13th Port LED 69 digitalWrite(8, HIGH); // no power to relay 70 } 71 72 else if (hasObstacle3 == LOW && hasObstacle4 == HIGH && hasObstacle5 == HIGH 73 && hasObstacle6 == HIGH && hasObstacle7 == HIGH) 74 { 75 Serial.println("Engine 76 is in running condition1"); 77 digitalWrite(LED_BUILTIN, LOW);//OFF the 13th 78 Port LED 79 digitalWrite(8, HIGH); // no power to relay 80 } 81 82 else 83 84 { 85 Serial.println("Engine Killed"); 86 digitalWrite(LED_BUILTIN, HIGH); 87 // Open the main scooter KEY circuit 88 digitalWrite(8, LOW); // no power to 89 relay 90 delay (5000); 91 digitalWrite(LED_BUILTIN, LOW); 92 digitalWrite(8, 93 HIGH); // no power to relay 94 } 95} 96
Arduino-UNO Code
arduino
1int obstaclePin3 = 3; // This is our input pin (Rotation) 2int obstaclePin4 = 4; // This is our input pin (Hand Sensor 1of4) 3int obstaclePin5 = 5; // This is our input pin (Hand Sensor 2of4) 4int obstaclePin6 = 6; // This is our input pin (Hand Sensor 3of4) 5int obstaclePin7 = 7; // This is our input pin (Hand Sensor 4of4) 6 7int hasObstacle3 = HIGH; // HIGH MEANS OBSTACLE (Rotation) 8int hasObstacle4 = LOW; // LOW MEANS NO OBSTACLE 9int hasObstacle5 = LOW; // LOW MEANS NO OBSTACLE 10int hasObstacle6 = LOW; // LOW MEANS NO OBSTACLE 11int hasObstacle7 = LOW; // LOW MEANS NO OBSTACLE 12int fall = HIGH; // HIGH MEANS VEHICLE HAS NOT FALLEN 13 14void setup() { 15 pinMode(LED_BUILTIN, OUTPUT); 16 pinMode(obstaclePin3, INPUT); 17 pinMode(obstaclePin4, INPUT); 18 pinMode(obstaclePin5, INPUT); 19 pinMode(obstaclePin6, INPUT); 20 pinMode(obstaclePin7, INPUT); 21 pinMode(8, OUTPUT); 22 pinMode(9, INPUT_PULLUP); 23 Serial.begin(9600); 24} 25 26void loop() { 27 hasObstacle3 = digitalRead(obstaclePin3); //Reads the output of the obstacle sensor from the 7th PIN of the Digital section of the arduino 28 hasObstacle4 = digitalRead(obstaclePin4); 29 hasObstacle5 = digitalRead(obstaclePin5); 30 hasObstacle6 = digitalRead(obstaclePin6); 31 hasObstacle7 = digitalRead(obstaclePin7); 32 fall = digitalRead(9); 33 34 if (fall == LOW) 35 { 36 Serial.println("Engine Killed - fall"); 37 digitalWrite(LED_BUILTIN, HIGH); // Open the main scooter KEY circuit 38 digitalWrite(8, LOW); // no power to relay 39 delay (5000); 40 digitalWrite(LED_BUILTIN, LOW); 41 digitalWrite(8, HIGH); // no power to relay 42 } 43 else if (hasObstacle3 == HIGH) 44 { 45 Serial.println("Engine is in running condition1"); 46 digitalWrite(LED_BUILTIN, LOW);//Illuminates the 13th Port LED 47 digitalWrite(8, HIGH); // no power to relay 48 } 49 else if (hasObstacle3 == LOW && hasObstacle4 == HIGH && hasObstacle5 == HIGH && hasObstacle6 == HIGH && hasObstacle7 == HIGH) 50 { 51 Serial.println("Engine is in running condition1"); 52 digitalWrite(LED_BUILTIN, LOW);//OFF the 13th Port LED 53 digitalWrite(8, HIGH); // no power to relay 54 } 55 56 else 57 { 58 Serial.println("Engine Killed"); 59 digitalWrite(LED_BUILTIN, HIGH); // Open the main scooter KEY circuit 60 digitalWrite(8, LOW); // no power to relay 61 delay (5000); 62 digitalWrite(LED_BUILTIN, LOW); 63 digitalWrite(8, HIGH); // no power to relay 64 } 65} 66
Downloadable files
Circuit Drawing
Circuit Drawing
Circuit Drawing
Circuit Drawing
untitled
untitled
Comments
Only logged in users can leave comments
merrypaulraj
0 Followers
•0 Projects
Table of contents
Intro
4
0