Skip to main content

Posts

Implement a preview using CameraX | Java

 MainActivity.java package com.simpy.preview; import android.Manifest; import android.content.pm.PackageManager; import android.os.Bundle; import android.widget.Toast; import androidx.activity.EdgeToEdge; import androidx.annotation.NonNull; import androidx.appcompat.app.AppCompatActivity; import androidx.camera.core.Camera; import androidx.camera.core.CameraSelector; import androidx.camera.core.Preview; import androidx.camera.lifecycle.ProcessCameraProvider; import androidx.camera.view.LifecycleCameraController; import androidx.camera.view.PreviewView; import androidx.core.app.ActivityCompat; import androidx.core.content.ContextCompat; import androidx.core.graphics.Insets; import androidx.core.view.ViewCompat; import androidx.core.view.WindowInsetsCompat; import androidx.lifecycle.LifecycleOwner; import com.google.common.util.concurrent.ListenableFuture; import com.google.mlkit.vision.barcode.BarcodeScanner; import java.util.concurrent.ExecutionException; import java.util.concurrent.Ex

How to play a video from the Internet in Android Studio - Programming Tutorial

How to play a video from the Internet in Android Studio - Programming Tutorial AndroidManifest.xml < uses-permission  android :name ="android.permission.INTERNET" /> MainActivity.java package  com.example.myapplication ; import android.os.Build ; import android.os.Bundle ; import androidx.activity.EdgeToEdge ; import androidx.appcompat.app.AppCompatActivity ; import androidx.core.graphics.Insets ; import androidx.core.view.ViewCompat ; import androidx.core.view.WindowInsetsCompat ; import androidx.media3.common.MediaItem ; import androidx.media3.exoplayer.ExoPlayer ; import androidx.media3.ui.PlayerView ; public class MainActivity extends AppCompatActivity { private PlayerView playerView ; private ExoPlayer player ; private boolean playWhenReady = true ; private Long playbackPosition = 0L ; private MediaItem mediaItem ; @Override protected void onCreate ( Bundle savedInstanceState) { super .onCreate(savedInstanceState); EdgeTo

Privacy Policy

Introduce We always strive to protect our customers' personal information. Customer Data The application fully commits not to collect and share data with third parties.

Using PIC16F887 microcontroller to control 8 single leds on and off using timer interrupt T1

Requirements: Use a PIC16F887 microcontroller to control 8 single leds on and off using the timer interrupt T1 with a delay period of 262ms.  Circuit diagram on Proteus simulation software  Figure 1. Controlling 8 LEDs to turn on and off using interrupts Main program : File: main.c ___________________ #INCLUDE <16F887.H> #FUSES NOWDT,PUT,HS,NOPROTECT,NOLVP #USE DELAY(CLOCK=20M) UNSIGNED INT8 X; #int_timer1 void interrupt_timer1() {    X=~X;    OUTPUT_D(X); } VOID MAIN() {     SET_TRIS_D(0x00); X=0X00; OUTPUT_D(X);    SETUP_TIMER_1(T1_INTERNAL | T1_DIV_BY_8);    SET_TIMER1(0);    ENABLE_INTERRUPTS(GLOBAL); ENABLE_INTERRUPTS(INT_TIMER1);    WHILE(TRUE) {} } ___________________ Link download:  https://drive.google.com/file/d/1e_8QOGfguNwGeuFN-T0MR9-vJyvMLAmz/view

Use PWM of PIC 16F887 to control 1 led

Requirements: Use PWM of PIC 16F887 to control 1 led. Let the frequency of the quartz capacitor be 20MHz. Given a PWM period of 0.8ms. Let's calculate the parameters and write a program to control the led light with level 1 equal to 1 tenth of the maximum brightness.   Circuit diagram on Proteus simulation software: Figure 1. The control circuit changes the light intensity of the lamp using PWM Main program : File: main.c ___________________ #INCLUDE <16F887.H> #FUSES NOWDT,PUT,HS,NOPROTECT,NOLVP #USE DELAY(CLOCK=20M) UNSIGNED INT16 BIEN_TOC_DO; VOID MAIN() {    SET_TRIS_C(0X00);    SETUP_CCP1(CCP_PWM);    SETUP_TIMER_2(T2_DIV_BY_16,249,1);    BIEN_TOC_DO=500;    SET_PWM1_DUTY(BIEN_TOC_DO);    WHILE(TRUE){} } ___________________ Link download:  https://drive.google.com/file/d/1bTFkDOBbnVMOfTfktRKmekfiYAq1Ipf6/view

Use the ADC of the PIC 16F887 microcontroller and the LM35 sensor to measure the temperature and display it on 3 led 7 segments common anode

Requirements: Use the ADC of the PIC16F887 microcontroller and the LM35 sensor to measure the temperature displayed on 3 led 7 segments common anode using 3 ports, only displaying units, tens and hundreds. Use a reference voltage source VREF+ connected to VDD with 5V and VREF- connected to a VSS source of 0V  Circuit diagram on Proteus simulation software Figure 1. Circuit diagram for measuring temperature using PIC16F887 displayed on 3 leds directly Main program : File: main.c ___________________ #INCLUDE<TV_16F887.C> UNSIGNED INT16 KQADC; UNSIGNED INT J,MATRAM; VOID HIEN_THI() {    MATRAM = MA7DOAN[KQADC/100];    IF (MATRAM == 0XC0) MATRAM=0XFF;    OUTPUT_B(MA7DOAN[KQADC%10]);    OUTPUT_D(MA7DOAN[KQADC/10%10]);    OUTPUT_C(MATRAM); } VOID MAIN() {    SET_TRIS_B(0x00); SET_TRIS_D(0x00);    SET_TRIS_C(0x00); SET_TRIS_A(0xFF);    SETUP_ADC(ADC_CLOCK_DIV_2);    SETUP_ADC_PORTS(SAN0);    SET_ADC_CHANNEL(0);    WHILE(TRUE)    {       KQADC=0;       FOR (J=0; J<200; J++)       {