Mohammed Ameen
Created September 4, 2024

Navigating Urban Environments

Compact and Portable Mobility Aid System for Navigating Urban Environments

18
Navigating Urban Environments

Things used in this project

Hardware components

Blues Notecard (Cellular)
Blues Notecard (Cellular)
×1
Blues Notecarrier A
Blues Notecarrier A
×1

Software apps and online services

The Things Stack
The Things Industries The Things Stack

Hand tools and fabrication machines

PCBWay 3D Printing
PCBWay 3D Printing
Sensor Assembly, for use with EC1201A Soldering Iron
Sensor Assembly, for use with EC1201A Soldering Iron

Story

Read more

Code

java code

Java
import android.location.Location;
import android.location.LocationListener;
import android.os.Bundle;
import android.widget.TextView;

public class MainActivity extends AppCompatActivity implements LocationListener {
    
    private TextView locationTextView;
    
    @Override
    protected void onCreate(Bundle savedInstanceState) {
 {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        
        locationTextView = findViewById(R.id.locationTextView);
        // Request location updates
        // (Assuming necessary permissions have been granted)
    }
    
    @Override
    public void onLocationChanged(Location location) {
        String locationInfo = "Latitude: " + location.getLatitude() + "\nLongitude: " + location.getLongitude();
        locationTextView.setText(locationInfo);
    }
    
    @Override
    public void onStatusChanged(String provider, int status, Bundle extras) { }
    @Override
    public void onProviderEnabled(String provider) { }
    @Override
    public void onProviderDisabled(String provider) { }
}

cpp code

C/C++
#include <M5Core2.h>
#include <NewPing.h>

#define TRIGGER_PIN  12
#define ECHO_PIN     13
#define MAX_DISTANCE 200 // Maximum distance (in cm) to detect

NewPing sonar(TRIGGER_PIN, ECHO_PIN, MAX_DISTANCE);

void setup() {
  M5.begin();
  Serial.begin(115200);
}

void loop() {
  delay(50); // Wait for 50ms between readings
  unsigned int distance = sonar.ping_cm();
  
  if (distance > 0 && distance < 50) { // If an obstacle is within 50 cm
    M5.Lcd.fillScreen(BLACK);
    M5.Lcd.setTextColor(RED);
    M5.Lcd.setTextSize(2);
    M5.Lcd.setCursor(10, 10);
    M5.Lcd.print("Obstacle Detected!");
  } else {
    M5.Lcd.fillScreen(GREEN);
    M5.Lcd.setTextColor(WHITE);
    M5.Lcd.setTextSize(2);
    M5.Lcd.setCursor(10, 10);
    M5.Lcd.print("Path Clear");
  }
}

Credits

Mohammed Ameen

Mohammed Ameen

1 project • 1 follower

Comments