PROJECTILE MOTION-A REAL LIFE APPLICATION OF TRIGONOMETRY
6 Views, 0 Favorites, 0 Comments
PROJECTILE MOTION-A REAL LIFE APPLICATION OF TRIGONOMETRY
Project: Motion and Trigonometry
Related Subjects: Physics-Mathematics
Proper Grade: Grade 10
Objectives:
- The relation between distance-time,
- Calculating trigonometrik ratios of given angles
- The usage of trigonometric functions in Physics
- Projectile Motion
- Parabola
Necessary Materials:
Arduino Uno, Distance sensor, OLED sreen, Button, Jumper wires, Buzzer, classroom materials for students own work and TI calculator to calculate trgionometric functions.
Description:
Students already know how to calculate the distance traveled over a given period of time from their math classes. They are also familiar with how and when to use the sine and cosine functions in different scenarios. In the Arduino project we will work on, the horizontal and vertical distances traveled over time by an object projected at a 30 angle will be displayed on an OLED screen.
To calculate these distances, the Arduino first analyzes the relationship between horizontal distance and time.
To prevent measurement errors, the measurement will be started by pressing a button to define the initial time t=0 Meanwhile, the OLED screen will display a countdown before the measurement begins.
For the improvement of the Project:
It will be better to connect a motor with a constant speed . All these measurements should be verified and cross-checked using a TI (Texas Instruments) calculator.
1. Arduino Board
- This is the brain of the project. All components will connect here.
2. Ultrasonic Sensor (like HC-SR04)
- VCC (Power) → Connect to Arduino 5V pin.
- GND (Ground) → Connect to Arduino GND pin.
- Trig (Trigger) → Connect to Arduino Pin 9.
- Echo → Connect to Arduino Pin 10.
3. OLED Display (SSD1306)
The OLED screen usually uses I2C communication with 4 pins:
- VCC → Connect to Arduino 3.3V or 5V (Check your OLED module’s voltage requirement, usually 3.3V or 5V).
- GND → Connect to Arduino GND.
- SDA (Data line) → Connect to Arduino A4 pin (for Arduino Uno).
- SCL (Clock line) → Connect to Arduino A5 pin (for Arduino Uno).
4. Button
- Connect one leg of the button to Arduino Pin 2.
- Connect the other leg to GND.
5. Summary of Connections
Component
Arduino Pin
Notes
Ultrasonic VCC
5V
Ultrasonic GND
GND
Ultrasonic Trig
9
Digital Pin
Ultrasonic Echo
10
Digital Pin
OLED VCC
3.3V or 5V
Check your OLED voltage needs
OLED GND
GND
OLED SDA
A4
I2C Data Line
OLED SCL
A5
I2C Clock Line
Button Leg 1
2
Digital Pin
Button Leg 2
GND
Code:
#include <Wire.h>
#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h>
#include <math.h>
#define SCREEN_WIDTH 128
#define SCREEN_HEIGHT 64
#define OLED_ADDR 0x3C
Adafruit_SSD1306 display(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire, -1);
const int trigPin = 9;
const int echoPin = 10;
const int buttonPin = 2;
const float g = 9.8;
const float angleDeg = 30.0;
enum State { WAIT_FOR_START, COUNTDOWN, MEASURING, MEASUREMENT_DONE };
State currentState = WAIT_FOR_START;
unsigned long countdownStart = 0;
unsigned long measureStart = 0;
unsigned long elapsedMillis = 0;
float lastMesafeCM = 0;
float lastVerticalCM = 0;
int countdownNumber = 3;
void setup() {
Serial.begin(115200);
Wire.begin();
pinMode(trigPin, OUTPUT);
pinMode(echoPin, INPUT);
pinMode(buttonPin, INPUT_PULLUP);
if (!display.begin(SSD1306_SWITCHCAPVCC, OLED_ADDR)) {
Serial.println(F("OLED baslatilamadi!"));
for (;;);
}
display.clearDisplay();
display.display();
}
void loop() {
static bool lastButtonState = HIGH;
bool buttonState = digitalRead(buttonPin);
// --- Buton kontrolü ---
if (lastButtonState == HIGH && buttonState == LOW) {
if (currentState == WAIT_FOR_START) {
currentState = COUNTDOWN;
countdownStart = millis();
} else if (currentState == MEASURING) {
// Ölçüm tamamlandı → zamanı ve mesafeyi DONDUR
currentState = MEASUREMENT_DONE;
// Zamanı kaydet
elapsedMillis = millis() - measureStart;
// Tek seferlik ölçüm yap
digitalWrite(trigPin, LOW);
delayMicroseconds(2);
digitalWrite(trigPin, HIGH);
delayMicroseconds(10);
digitalWrite(trigPin, LOW);
long sure = pulseIn(echoPin, HIGH);
lastMesafeCM = sure * 0.0343 / 2.0;
// Dikey mesafe hesapla
float angleRad = angleDeg * 3.14159265359 / 180.0;
float R = lastMesafeCM / 100.0;
float H = (R * pow(sin(angleRad), 2)) / (2 * sin(2 * angleRad));
lastVerticalCM = H * 100.0;
} else if (currentState == MEASUREMENT_DONE) {
currentState = WAIT_FOR_START;
}
delay(200); // debounce
}
lastButtonState = buttonState;
switch (currentState) {
case WAIT_FOR_START:
display.clearDisplay();
display.setTextSize(1);
display.setTextColor(SSD1306_WHITE);
display.setCursor(0, 20);
display.println("Press button to start");
display.display();
break;
case COUNTDOWN: {
unsigned long now = millis();
int elapsedSec = (now - countdownStart) / 1000;
if (elapsedSec >= 3) {
currentState = MEASURING;
measureStart = millis();
} else {
int showNumber = 3 - elapsedSec;
display.clearDisplay();
display.setTextSize(5);
display.setTextColor(SSD1306_WHITE);
display.setCursor(50, 20);
display.print(showNumber);
display.display();
}
break;
}
case MEASURING: {
unsigned long currentMillis = millis();
unsigned long elapsedSeconds = (currentMillis - measureStart) / 1000;
// Sürekli ölçüm
digitalWrite(trigPin, LOW);
delayMicroseconds(2);
digitalWrite(trigPin, HIGH);
delayMicroseconds(10);
digitalWrite(trigPin, LOW);
long sure = pulseIn(echoPin, HIGH);
float mesafeCM = sure * 0.0343 / 2.0;
// Dikey mesafe hesapla
float angleRad = angleDeg * 3.14159265359 / 180.0;
float R = mesafeCM / 100.0;
float H = (R * pow(sin(angleRad), 2)) / (2 * sin(2 * angleRad));
float verticalDistanceCM = H * 100.0;
// OLED yaz
display.clearDisplay();
display.setTextSize(1);
display.setTextColor(SSD1306_WHITE);
display.setCursor(0, 0);
display.print("Time: ");
display.print(elapsedSeconds);
display.println(" s");
display.setCursor(0, 12);
display.print("Horizontal Dist:");
display.setCursor(0, 22);
display.print(mesafeCM, 1);
display.println(" cm");
display.setCursor(0, 38);
display.print("Vertical Dist:");
display.setCursor(0, 48);
display.print(verticalDistanceCM, 1);
display.println(" cm");
display.display();
break;
}
case MEASUREMENT_DONE: {
unsigned long elapsedSeconds = elapsedMillis / 1000;
// Durdurulmuş hali göster
display.clearDisplay();
display.setTextSize(1);
display.setTextColor(SSD1306_WHITE);
display.setCursor(0, 0);
display.println("Measurement Stopped");
display.setCursor(0, 12);
display.print("Time: ");
display.print(elapsedSeconds);
display.println(" s");
display.setCursor(0, 24);
display.print("Horizontal: ");
display.print(lastMesafeCM, 1);
display.println(" cm");
display.setCursor(0, 38);
display.print("Vertical: ");
display.print(lastVerticalCM, 1);
display.println(" cm");
display.display();
break;
}
}
delay(100); // sensör yükünü azalt
}