-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
2f66398
commit 226ef19
Showing
16 changed files
with
671 additions
and
0 deletions.
There are no files selected for viewing
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
#include <Servo.h> | ||
|
||
int position = 0; | ||
|
||
int i = 0; | ||
|
||
int j = 0; | ||
|
||
Servo servo_9; | ||
|
||
void setup() | ||
{ | ||
servo_9.attach(9); | ||
|
||
} | ||
|
||
void loop() | ||
{ | ||
position = 0; | ||
for (position = 1; position <= 179; position += 1) { | ||
servo_9.write(position); | ||
delay(20); // Wait for 20 millisecond(s) | ||
} | ||
for (position = 179; position >= 1; position -= 1) { | ||
servo_9.write(position); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
#include <Servo.h> | ||
|
||
int i = 0; | ||
|
||
int j = 0; | ||
|
||
int outputValue = 0; | ||
|
||
int SensorValue = 0; | ||
|
||
Servo servo_9; | ||
|
||
void setup() | ||
{ | ||
pinMode(A0, INPUT); | ||
servo_9.attach(9); | ||
|
||
} | ||
|
||
void loop() | ||
{ | ||
SensorValue = analogRead(A0); | ||
outputValue = map(SensorValue, 0, 1023, 0, 180); | ||
servo_9.write(outputValue); | ||
delay(10); // Delay a little bit to improve simulation performance | ||
} |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
#include <Servo.h> | ||
#include <Keypad.h> | ||
Servo ServoMotor; | ||
|
||
char* password = "123"; | ||
|
||
int position = 0; | ||
const byte ROWS = 4; | ||
const byte COLS = 4; | ||
char keys[ROWS][COLS] = { | ||
{'1','2','3','A'}, | ||
{'4','5','6','B'}, | ||
{'7','8','9','C'}, | ||
{'*','0','#','D'} | ||
}; | ||
byte rowPins[ROWS] = { 8 , 7, 6, 5}; | ||
byte colPins[COLS] = { 4, 3, 2, 1 }; | ||
Keypad keypad = Keypad( makeKeymap(keys), rowPins, colPins, ROWS, COLS ); | ||
|
||
// Create two variables for LED Lights | ||
int RedpinLock = 13; | ||
int GreenpinUnlock = 12; | ||
void setup() | ||
{ | ||
pinMode(RedpinLock, OUTPUT); | ||
pinMode(GreenpinUnlock, OUTPUT); | ||
ServoMotor.attach(11); | ||
LockedPosition(true); | ||
} | ||
void loop() | ||
{ | ||
char key = keypad.getKey(); | ||
if (key == '*' || key == '#') | ||
{ | ||
position = 0; | ||
LockedPosition(true); | ||
} | ||
if (key == password[position]) | ||
{ | ||
position ++; | ||
} | ||
if (position == 3) | ||
{ | ||
LockedPosition(false); | ||
} | ||
delay(100); | ||
} | ||
void LockedPosition(int locked) | ||
{ | ||
if (locked) | ||
{ | ||
digitalWrite(RedpinLock, HIGH); | ||
digitalWrite(GreenpinUnlock, LOW); | ||
ServoMotor.write(11); | ||
} | ||
else | ||
{ | ||
digitalWrite(RedpinLock, LOW); | ||
digitalWrite(GreenpinUnlock, HIGH); | ||
ServoMotor.write(90); | ||
} | ||
} |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
|
||
#include <Adafruit_NeoPixel.h> | ||
|
||
int ledPin= 3; | ||
int ledNo= 12; | ||
|
||
Adafruit_NeoPixel strip= Adafruit_NeoPixel(ledNo,ledPin,NEO_RGB+NEO_KHZ800); | ||
|
||
|
||
int buzzerPin= 10; | ||
int echoPin= 8; | ||
int trigPin= 2; | ||
int minDistance = 100; | ||
int maxDistance = 300; | ||
|
||
void setup() | ||
{ | ||
pinMode(buzzerPin, OUTPUT); | ||
pinMode(trigPin, OUTPUT); | ||
pinMode(echoPin, INPUT); | ||
Serial. begin(9600); | ||
strip.begin(); | ||
for(int i = 0; i < ledNo; i++) | ||
{ | ||
strip.setPixelColor(i,strip.Color(0,0,0)); | ||
} | ||
strip.show(); | ||
} | ||
|
||
void loop() | ||
{ | ||
int distance = calcDistance(); | ||
Serial.println(distance); | ||
int ledsToGlow = map(distance, minDistance, maxDistance, ledNo, 1); | ||
Serial.println(ledsToGlow); | ||
if(ledsToGlow == 12) | ||
{ | ||
digitalWrite(buzzerPin, HIGH); | ||
} | ||
else | ||
{ | ||
digitalWrite(buzzerPin, LOW); | ||
} | ||
for(int i = 0; i < ledsToGlow; i++) | ||
{ | ||
if(i < 4) | ||
{ | ||
strip.setPixelColor(i,strip.Color(50,0,0));//green,red,blue | ||
} | ||
else if(i >= 4 && i < 8) | ||
{ | ||
strip.setPixelColor(i,strip.Color(50,50,0));//green,red,blue | ||
} | ||
else if(i >= 8 && i < 12) | ||
{ | ||
strip.setPixelColor(i,strip.Color(0,50,0));//green,red,blue | ||
} | ||
} | ||
for(int i = ledsToGlow; i < ledNo; i++) | ||
{ | ||
strip.setPixelColor(i,strip.Color(0,0,0)); | ||
} | ||
strip.show(); | ||
delay(50); | ||
} | ||
|
||
int calcDistance() | ||
{ | ||
long distance,duration; | ||
digitalWrite(trigPin, LOW); | ||
delayMicroseconds(2); | ||
digitalWrite(trigPin, HIGH); | ||
delayMicroseconds(10); | ||
digitalWrite(trigPin, LOW); | ||
duration = pulseIn(echoPin, HIGH); | ||
distance = duration/29/2; | ||
if(distance >= maxDistance) | ||
{ | ||
distance = maxDistance; | ||
} | ||
if(distance <= minDistance) | ||
{ | ||
distance = minDistance; | ||
} | ||
return distance; | ||
} |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
void setup() | ||
{ | ||
pinMode(9, OUTPUT); | ||
pinMode(3, OUTPUT); | ||
pinMode(2, OUTPUT); | ||
} | ||
|
||
void loop() | ||
{ | ||
digitalWrite(9, HIGH); | ||
digitalWrite(3, LOW); | ||
digitalWrite(2, LOW); | ||
delay(1000); // Wait for 1000 millisecond(s) | ||
digitalWrite(9, LOW); | ||
digitalWrite(3, HIGH); | ||
digitalWrite(2, LOW); | ||
delay(1000); // Wait for 1000 millisecond(s) | ||
digitalWrite(9, LOW); | ||
digitalWrite(3, LOW); | ||
digitalWrite(2, HIGH); | ||
delay(1000); // Wait for 1000 millisecond(s) | ||
} |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
void setup() | ||
{ | ||
pinMode(8, OUTPUT); | ||
} | ||
|
||
void loop() | ||
{ | ||
digitalWrite(8, HIGH); | ||
delay(1000); // Wait for 1000 millisecond(s) | ||
digitalWrite(8, LOW); | ||
delay(1000); // Wait for 1000 millisecond(s) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
void setup() | ||
{ | ||
pinMode(6,OUTPUT); | ||
pinMode(5,OUTPUT); | ||
pinMode(4,OUTPUT); | ||
pinMode(3,OUTPUT); | ||
} | ||
|
||
void loop() | ||
{ | ||
Forward(); | ||
delay(3000); | ||
Backward(); | ||
|
||
} | ||
void Forward(){ | ||
digitalWrite(6,HIGH); | ||
digitalWrite(5,LOW); | ||
digitalWrite(3,HIGH); | ||
digitalWrite(4,LOW); | ||
} | ||
|
||
void Backward(){ | ||
digitalWrite(6,LOW); | ||
digitalWrite(5,HIGH); | ||
digitalWrite(3,LOW); | ||
digitalWrite(4,HIGH); | ||
} |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Oops, something went wrong.