Arduino Simple Pendulum Experiment
3.5 هزار بار بازدید -
5 سال پیش
-
Experiment to find the time
Experiment to find the time period of the simple pendulum using arduino board and an ir sensor.
Things Required:
1. Arduino Board
2. IR Sensor
3. Simple Pendulum
The Code For The Experiment
-------------------------------------------------------------------
unsigned long pretime;
unsigned long currtime;
int pin = 2;
unsigned long timePeriod;
boolean flag = true;
float t;
void setup(){
Serial.begin(9600);
pinMode(pin, INPUT);
pretime = micros();
Serial.println("Initialized");
}
void loop(){
if (digitalRead(pin) == 0)
{
if (flag == true)
{
currtime = micros();
timePeriod = currtime-pretime;
pretime = currtime;
flag = !flag;
t = timePeriod/1000;
Serial.println(timePeriod/1000);
delay(100);
}
else{
flag = !flag;
delay(100);
}
}
}
------------------------------------------------------------------------
Just Copy Paste The Code.
Let us know your thoughts in the comments below.
Please Subscribe to our channel
Things Required:
1. Arduino Board
2. IR Sensor
3. Simple Pendulum
The Code For The Experiment
-------------------------------------------------------------------
unsigned long pretime;
unsigned long currtime;
int pin = 2;
unsigned long timePeriod;
boolean flag = true;
float t;
void setup(){
Serial.begin(9600);
pinMode(pin, INPUT);
pretime = micros();
Serial.println("Initialized");
}
void loop(){
if (digitalRead(pin) == 0)
{
if (flag == true)
{
currtime = micros();
timePeriod = currtime-pretime;
pretime = currtime;
flag = !flag;
t = timePeriod/1000;
Serial.println(timePeriod/1000);
delay(100);
}
else{
flag = !flag;
delay(100);
}
}
}
------------------------------------------------------------------------
Just Copy Paste The Code.
Let us know your thoughts in the comments below.
Please Subscribe to our channel
5 سال پیش
در تاریخ 1398/09/29 منتشر شده
است.
3,556
بـار بازدید شده