Back to Browse

Arduino Simple Pendulum Experiment

4.6K views
Dec 20, 2019
4:05

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

Download

0 formats

No download links available.

Arduino Simple Pendulum Experiment | NatokHD