├── README.md └── E-Bicycle Code.c /README.md: -------------------------------------------------------------------------------- 1 | # E-Bicycle-Locking-System 2 | Electrical Bicycle Locking System 3 | -------------------------------------------------------------------------------- /E-Bicycle Code.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | SoftwareSerial bluetooth(10, 11); 4 | int motorPin1 = 2; 5 | int motorPin2 = 3; 6 | 7 | void setup() { 8 | pinMode(motorPin1, OUTPUT); 9 | pinMode(motorPin2, OUTPUT); 10 | 11 | Serial.begin(9600); 12 | bluetooth.begin(9600); 13 | } 14 | 15 | void loop() { 16 | if (bluetooth.available()) { 17 | char command = bluetooth.read(); 18 | 19 | 20 | switch (command) { 21 | case 'L': 22 | lockBicycle(); 23 | break; 24 | case 'U': 25 | unlockBicycle(); 26 | break; 27 | default: 28 | break; 29 | } 30 | } 31 | } 32 | 33 | void lockBicycle() { 34 | digitalWrite(motorPin1, HIGH); 35 | digitalWrite(motorPin2, LOW); 36 | delay(2000); 37 | digitalWrite(motorPin1, LOW); 38 | } 39 | 40 | void unlockBicycle() { 41 | digitalWrite(motorPin1, LOW); 42 | digitalWrite(motorPin2, HIGH); 43 | delay(2000); 44 | digitalWrite(motorPin2, LOW); 45 | } 46 | --------------------------------------------------------------------------------