0% found this document useful (0 votes)
31 views13 pages

Aryan's NCSC 2025

Uploaded by

Royal Aditya
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
31 views13 pages

Aryan's NCSC 2025

Uploaded by

Royal Aditya
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 13

Accelerator :

Code for it—

// Include Libraries
#include "Arduino.h"
#include "MPU6050.h"
#include "Wire.h"
#include "I2Cdev.h"
#include "PIR.h"

// Pin Definitions
#define PIR_PIN_SIG 2

// Global variables and defines


int16_t mpu6050Ax, mpu6050Ay, mpu6050Az;
int16_t mpu6050Gx, mpu6050Gy, mpu6050Gz;
// object initialization
MPU6050 mpu6050;
PIR pir(PIR_PIN_SIG);
// define vars for testing menu
const int timeout = 10000; //define timeout of 10 sec
char menuOption = 0;
long time0;

// Setup the essentials for your circuit to work. It runs first every time your
circuit is powered with electricity.
void setup()
{
// Setup Serial which is useful for debugging
// Use the Serial Monitor to view printed messages
Serial.begin(9600);
while (!Serial) ; // wait for serial port to connect. Needed for native USB
Serial.println("start");

Wire.begin();
mpu6050.initialize();
menuOption = menu();

// Main logic of your circuit. It defines the interaction between the


components you selected. After setup, it runs over and over again, in an
eternal loop.
void loop()
{
if(menuOption == '1') {
// SparkFun MPU-6050 - Accelerometer and Gyro - Test Code
mpu6050.getMotion6(&mpu6050Ax, &mpu6050Ay, &mpu6050Az,
&mpu6050Gx, &mpu6050Gy, &mpu6050Gz); //read accelerometer and
gyroscope raw data in three axes
double mpu6050Temp = ((double)mpu6050.getTemperature() + 12412.0) /
340.0;
Serial.print("a/g-\t");
Serial.print(mpu6050Ax); Serial.print("\t");
Serial.print(mpu6050Ay); Serial.print("\t");
Serial.print(mpu6050Az); Serial.print("\t");
Serial.print(mpu6050Gx); Serial.print("\t");
Serial.print(mpu6050Gy); Serial.print("\t");
Serial.print(mpu6050Gz); Serial.print("\t");
Serial.print(F("Temp- "));
Serial.println(mpu6050Temp);
delay(100);

}
else if(menuOption == '2') {
// Infrared PIR Motion Sensor Module - Test Code
bool pirVal = pir.read();
Serial.print(F("Val: ")); Serial.println(pirVal);

if (millis() - time0 > timeout)


{
menuOption = menu();
}

// Menu function for selecting the components to be tested


// Follow serial monitor for instrcutions
char menu()
{

Serial.println(F("\nWhich component would you like to test?"));


Serial.println(F("(1) SparkFun MPU-6050 - Accelerometer and Gyro"));
Serial.println(F("(2) Infrared PIR Motion Sensor Module"));
Serial.println(F("(menu) send anything else or press on board reset button\
n"));
while (!Serial.available());

// Read data from serial monitor if received


while (Serial.available())
{
char c = Serial.read();
if (isAlphaNumeric(c))
{
if(c == '1')
Serial.println(F("Now Testing SparkFun MPU-6050 -
Accelerometer and Gyro"));
else if(c == '2')
Serial.println(F("Now Testing Infrared PIR Motion Sensor
Module"));
else
{
Serial.println(F("illegal input!"));
return 0;
}
time0 = millis();
return c;
}
}
}
Circuit Diagram

Metal detector:
Components required
Metal Detector....

Components Required
1 x TDA0161 Proximity Detector IC
2 x 47nF Capacitors (Ceramic Capacitor code 473)
1 x 1 KΩ Resistor (1/4 Watt)
1 x 330 Ω Resistor (1/4 Watt)
1 x 100 Ω Resistor (1/4 Watt)
1 x 5 KΩ Potentiometer
1 x 2N2222A (NPN Transistor)
1 x 5V Buzzer
Coil (copper wire of 26 – 30 AWG is taken and it is wound in to a coil of
diamater 5 – 6 cm and 140 – 150 turns)
Additional Components (for LED)
1 x 220 Ω Resistor (1/4 Watt)
1 x 5mm LED

For the process of separation—


Code

// Include Libraries
#include "Arduino.h"
#include "Servo.h"
// Pin Definitions
#define SERVO9G1_1_PIN_SIG 2
#define SERVO9G2_2_PIN_SIG 3

// Global variables and defines


const int servo9g1_1RestPosition = 20; //Starting position
const int servo9g1_1TargetPosition = 150; //Position when event is detected
const int servo9g2_2RestPosition = 20; //Starting position
const int servo9g2_2TargetPosition = 150; //Position when event is detected
// object initialization
Servo servo9g1_1;
Servo servo9g2_2;

// define vars for testing menu


const int timeout = 10000; //define timeout of 10 sec
char menuOption = 0;
long time0;

// Setup the essentials for your circuit to work. It runs first every time your
circuit is powered with electricity.
void setup()
{
// Setup Serial which is useful for debugging
// Use the Serial Monitor to view printed messages
Serial.begin(9600);
while (!Serial) ; // wait for serial port to connect. Needed for native USB
Serial.println("start");

servo9g1_1.attach(SERVO9G1_1_PIN_SIG);
servo9g1_1.write(servo9g1_1RestPosition);
delay(100);
servo9g1_1.detach();
servo9g2_2.attach(SERVO9G2_2_PIN_SIG);
servo9g2_2.write(servo9g2_2RestPosition);
delay(100);
servo9g2_2.detach();
menuOption = menu();

// Main logic of your circuit. It defines the interaction between the


components you selected. After setup, it runs over and over again, in an
eternal loop.
void loop()
{

if(menuOption == '1') {
// 9G Micro Servo #1 - Test Code
// The servo will rotate to target position and back to resting position with
an interval of 500 milliseconds (0.5 seconds)
servo9g1_1.attach(SERVO9G1_1_PIN_SIG); // 1. attach the servo to
correct pin to control it.
servo9g1_1.write(servo9g1_1TargetPosition); // 2. turns servo to target
position. Modify target position by modifying the 'ServoTargetPosition'
definition above.
delay(500); // 3. waits 500 milliseconds (0.5 sec). change
the value in the brackets (500) for a longer or shorter delay in milliseconds.
servo9g1_1.write(servo9g1_1RestPosition); // 4. turns servo back to rest
position. Modify initial position by modifying the 'ServoRestPosition'
definition above.
delay(500); // 5. waits 500 milliseconds (0.5 sec). change
the value in the brackets (500) for a longer or shorter delay in milliseconds.
servo9g1_1.detach(); // 6. release the servo to conserve power.
When detached the servo will NOT hold it's position under stress.
}
else if(menuOption == '2') {
// 9G Micro Servo #2 - Test Code
// The servo will rotate to target position and back to resting position with
an interval of 500 milliseconds (0.5 seconds)
servo9g2_2.attach(SERVO9G2_2_PIN_SIG); // 1. attach the servo to
correct pin to control it.
servo9g2_2.write(servo9g2_2TargetPosition); // 2. turns servo to target
position. Modify target position by modifying the 'ServoTargetPosition'
definition above.
delay(500); // 3. waits 500 milliseconds (0.5 sec). change
the value in the brackets (500) for a longer or shorter delay in milliseconds.
servo9g2_2.write(servo9g2_2RestPosition); // 4. turns servo back to rest
position. Modify initial position by modifying the 'ServoRestPosition'
definition above.
delay(500); // 5. waits 500 milliseconds (0.5 sec). change
the value in the brackets (500) for a longer or shorter delay in milliseconds.
servo9g2_2.detach(); // 6. release the servo to conserve power.
When detached the servo will NOT hold it's position under stress.
}

if (millis() - time0 > timeout)


{
menuOption = menu();
}

// Menu function for selecting the components to be tested


// Follow serial monitor for instrcutions
char menu()
{

Serial.println(F("\nWhich component would you like to test?"));


Serial.println(F("(1) 9G Micro Servo #1"));
Serial.println(F("(2) 9G Micro Servo #2"));
Serial.println(F("(menu) send anything else or press on board reset button\
n"));
while (!Serial.available());

// Read data from serial monitor if received


while (Serial.available())
{
char c = Serial.read();
if (isAlphaNumeric(c))
{

if(c == '1')
Serial.println(F("Now Testing 9G Micro Servo #1"));
else if(c == '2')
Serial.println(F("Now Testing 9G Micro Servo #2"));
else
{
Serial.println(F("illegal input!"));
return 0;
}
time0 = millis();
return c;
}
}
}

Circuit diagram

You might also like