Posts

Embedded

Image
PB0 Functions Function Description GPIO Input Read a push button or switch GPIO Output Control an LED, relay, or buzzer ADC Input Read analog signals from sensors (if enabled on this pin) EXTI External interrupt input Timer / Alternate Function PWM generation or timer input/output (depending on the timer mapping) Common Uses 1. LED Control HAL_GPIO_WritePin ( GPIOB , GPIO_PIN_0 , GPIO_PIN_SET ); // LED ON HAL_GPIO_WritePin ( GPIOB , GPIO_PIN_0 , GPIO_PIN_RESET ); // LED OFF 2. Push Button if ( HAL_GPIO_ReadPin ( GPIOB , GPIO_PIN_0 ) == GPIO_PIN_SET ) { // Button is pressed } 3. Analog Sensor You can connect: Potentiometer LM35 Temperature Sensor LDR Soil Moisture Sensor (analog output) to  PB0  if it is configured as an ADC input. 4. PWM Output PB0 can be configured as a timer output to: Control LED brightness Drive a servo motor Control DC motor speed Pin Type PB0 │ ├── GPIO ├── ADC ├── EXTI └── Timer (Alternate Function) In STM32CubeMX Click  PB0  and you...

python check balance

 class bank():     def __init__(self,name,age,balance):         self.name=name         self._age=age         self.__balance=balance     def display(self):         print(self.name,self._age,self.__balance) obj=bank("sai",90,134) obj.name="dimpul" obj._age=23 obj.__balance=1234 obj.display()

Linked list in python

 class ll:     def __init__(self,n):         self.n=n         self.next=None node=ll(10) node.next=ll(20) node.next.next=ll(30) node.next.next.next=ll(44) count=0 new_node=ll(98) new_node.next=node.next node.next=new_node curr=node while(curr!=None):     print(curr.n,end=" ")     curr=curr.next  import java.util.Scanner; class Main {     public static void main(String[] args) { Scanner sc=new Scanner(System.in); int num=sc.nextInt(); int ornum=num; int sum=0; while(num>0){     int digit=num%10;     //int sum=0;     sum= sum + (digit * digit * digit);     num=num/10; }if(ornum==sum){ System.out.println("Is a armstrong");     }     else{         System.out.println("Is a not armstrong");     } } }fewf     

2 class parent class

 class person:     def __init__(self,name,age):         self.name=name         self.age=age class student(person):     def __init__(self,name,age,roll):         super().__init__(name,age)         self.roll=roll     def display(self):         print("student",self.name)         print("student",self.age)         print("student",self.roll) class employee(person):     def __init__(self,name,age,roll):         super().__init__(name,age)         self.id1=id1     def display(self):         print("employee",self.name)         print("employee",self.age)         print("employee",self.id1) n=int(input()) for i in range(n):     t=input()     if t=="student":         name...

queu in python

class queu():     def __init__(self):         self.l=[]     def push(self,val):         self.l.append(val)     def pop(self):         self.l.pop(0)     def peak(self):         for i in range(len(self.l)):             return self.l[0]     def emty(self):         for i in range(len(self.l)):             return len(self.l)==0              def display(self):         print(self.l) q=queu() q.push(10) q.push(20) q.push(40) q.push(100) q.display() q.pop() q.display() print(q.emty()) print(q.peak()) 

stack in python

 class stack():     def __init__(self):         self.l=[]     def push(self,val):         self.l.append(val)     def pop(self):         self.l.pop()     def peak(self):         for i in range(len(self.l)):             return self.l[-1]     def emty(self):         for i in range(len(self.l)):             return len(self.l)==0              def display(self):         print(self.l) s=stack() s.push(10) s.push(20) s.push(40) s.push(100) s.display() s.pop() s.display() print(s.emty()) s.display() print(s.peak())

expalin

 import java.util.Scanner; public class Main{     public static void main(String[]args){         Scanner s=new Scanner(System.in);         System.out.println("Enter no of rows");         int row=s.nextInt();         System.out.println("Enter no of cols");         int col=s.nextInt();         for (int i=1;i<=row;i++){             for(int space=1;space<=row-i;space++){                 System.out.print(" ");             }             for(int j=1;j<=2*i-1;j++){                 if(j==1||j==2*i-1){                 System.out.print("*");                 }               ...