Tuesday, December 3, 2019

MM32f103 led blink program

To work on mind motion MM32 microcontroller we need to install the keil uvision 5 version
then install the mm32-link programmer

go to library folder their you will get the
MM32F103_library_examples\MM32F103xx_m_Lib_Samples_V1.01_SC\MM32F103RegLibMB_Ver1.9.5\Boards_MM32x103\MB103CBT6_lib\BLINK\IOToggle\KEIL_PRJ

open the file in keil. options target  their to need to do mm32-ulink.


/****************************************Copyright (c)****************************************************
**
**                                   
**
**--------------File Info---------------------------------------------------------------------------------
** File name:      main.c
** modified Date:  2019-12-04
** Last Version:   V1.9.5
** Descriptions:   Led blink program by anil durgam
**
*********************************************************************************************************/
#include "sys.h"
#include "delay.h"
#include "uart.h"
#include "led.h"

int main(void)
{
 
    delay_init();  
 
    LED_Init();
 
    while(1)           
    {
        LED1=!LED1;
        LED2=!LED2;
        LED3=!LED3;
        LED4=!LED4;
        delay_ms(1000); 
    }
}



Monday, December 2, 2019

finding the length of tuple in python

t1=(10,20,30)
print(len(t1))

output:
3


multiplication of Tuple in python

t1=(10,20,30)
t2=t1*2
print(t2)


output:
(10, 20, 30, 10, 20, 30)

example 2:


t1=(10,20,30)
t2=t1*3
print(t2)

output:
(10, 20, 30, 10, 20, 30, 10, 20, 30)

addition of Tuple in python

t1=(10,20,30)
t2=(40,50,60)
t3=t1+t2
print(t1)
print(t2)
print(t3)

output 1:
(10, 20, 30)
(40, 50, 60)
(10, 20, 30, 40, 50, 60)

Tuesday, November 26, 2019

single value Tuple in python

If we indicate the parenthesis with single value  then that should not be considered as tuple .

example 1:

t=(10)
print(type(t))
print(t)

output:
<class 'int'>
10

example 2:
t=('A')
print(type(t))

print(t)

output:
<class 'str'>
A

single value tuple indicates as (first value,)

example 3:
t=(10)
print(type(t))
print(t)
t=('A')
print(type(t))
print(t)
t=(10,)
print(type(t))

print(t)

output:
<class 'int'>
10
<class 'str'>
A
<class 'tuple'>
(10,)


Monday, November 25, 2019

write a program to search the vowel in the given string in python

# -*- coding: utf-8 -*-
"""
Created on Tue Nov 26 07:16:18 2019

@author: anil durgam
program:
    write a program to search the vowel in the given string
   
"""
vowels=['a','e','i','o','u']
word=input("enter the some word to search for vowels\n")
found=[]
for letter in word:
    if letter in vowels:
        if letter not in found:
            found.append(letter)
print(found)
print("the number of different vowels present in",word,"is:",len(found) )


output:

enter the some word to search for vowels
anildurgam
['a', 'i', 'u']
the number of different vowels present in anildurgam is: 3


slice operator in python

# -*- coding: utf-8 -*-
"""
Created on Tue Nov 26 06:53:23 2019

@author: anil
Topic:slice operator

"""
a='0123456789'
#a[begin index:end index:direction]
#begin index start from zero
#end index goes upto length of the string.in my case it is ten
#the last parameter indicates the direction if that is '+' its mean positive direction
#if that is '-' then negative direction and also step to increse
print(a[0:11:1])
#in end index forward direction then it should be '-1' need to delete
print(a[0:11:2])
print(a[0:11:3])
print(a[0:11:4])
print(a[0:11:5])
print(a[0:11:6])
print(a[0:11:7])
print(a[0:11:8])
print(a[0:11:9])

#begin index from different values
print()
print("slice operator begin value from different indexes")
print(a[1:11:2])
print(a[1:11:3])
print(a[1:11:4])

output:
0123456789
02468
0369
048
05
06
07
08
09

slice operator begin value from different indexes
13579
147
159


Happy face symbol using arcade game library in python

# -*- coding: utf-8 -*-
"""
Drawing an example happy face

If Python and Arcade are installed, this example can be run from the command line with:
python -m arcade.examples.happy_face
"""

import arcade

# Set constants for the screen size
SCREEN_WIDTH = 600
SCREEN_HEIGHT = 600
SCREEN_TITLE = "Happy Face Example"

# Open the window. Set the window title and dimensions
arcade.open_window(SCREEN_WIDTH, SCREEN_HEIGHT, SCREEN_TITLE)

# Set the background color
arcade.set_background_color(arcade.color.WHITE)

# Clear screen and start render process
arcade.start_render()

# --- Drawing Commands Will Go Here ---

# Draw the face
x = 300
y = 300
radius = 200
arcade.draw_circle_filled(x, y, radius, arcade.color.YELLOW)

# Draw the right eye
x = 370
y = 350
radius = 20
arcade.draw_circle_filled(x, y, radius, arcade.color.BLACK)

# Draw the left eye
x = 230
y = 350
radius = 20
arcade.draw_circle_filled(x, y, radius, arcade.color.BLACK)

# Draw the smile
x = 300
y = 280
width = 120
height = 100
start_angle = 190
end_angle = 350
arcade.draw_arc_outline(x, y, width, height, arcade.color.BLACK,
                        start_angle, end_angle, 10)

# Finish drawing and display the result
arcade.finish_render()

# Keep the window open until the user hits the 'close' button
arcade.run()

Sunday, November 24, 2019

pygame introduction program

this code shows that how to display a window using pygame library


import pygame

# Define some colors
BLACK = (0, 0, 0)
WHITE = (255, 255, 255)
GREEN = (0, 255, 0)
RED = (255, 0, 0)

pygame.init()

# Set the width and height of the screen [width, height]
size = (700, 500)
screen = pygame.display.set_mode(size)

pygame.display.set_caption("My Game")

# Loop until the user clicks the close button.
done = False

# Used to manage how fast the screen updates
clock = pygame.time.Clock()

# -------- Main Program Loop -----------
while not done:
    # --- Main event loop
    for event in pygame.event.get():
        if event.type == pygame.QUIT:
            done = True

    # --- Game logic should go here

    # --- Screen-clearing code goes here

    # Here, we clear the screen to white. Don't put other drawing commands
    # above this, or they will be erased with this command.

    # If you want a background image, replace this clear with blit'ing the
    # background image.
    screen.fill(WHITE)

    # --- Drawing code should go here

    # --- Go ahead and update the screen with what we've drawn.
    pygame.display.flip()

    # --- Limit to 60 frames per second
    clock.tick(60)

# Close the window and quit.
pygame.quit()

Thursday, November 21, 2019

tkinter label example

from tkinter import *
root = Tk()

one =Label(root,text="ONE",bg="red",fg="white")
one.pack()
two =Label(root,text="TWO",bg="green",fg="black")
two.pack(fill=X)
three =Label(root,text="THREE",bg="blue",fg="white")
three.pack(side=LEFT,fill=Y)


root.mainloop()

output:

tkinter example making of button


from tkinter import *

mm32=tk.Tk()

topframe = Frame(mm32)
topframe.pack()
bottomframe=Frame(mm32)
bottomframe.pack(side=BOTTOM)

button1=Button(topframe,text="MM32F",fg="red",font=('Helvetica', 15))
button2=Button(topframe,text="MM32L",fg="red",font=('Helvetica', 15))
button3=Button(topframe,text="MM32SPIN",fg="red",font=('Helvetica', 15))
button4=Button(topframe,text="MM32W",fg="red",font=('Helvetica', 15))
button5=Button(topframe,text="MM32P",fg="red",font=('Helvetica', 15))

button1.pack(side=LEFT)
button2.pack(side=LEFT)
button3.pack(side=LEFT)
button4.pack(side=LEFT)
button5.pack(side=LEFT)

mm32.mainloop()

OUTPUT:


MM32f103 led blink program

To work on mind motion MM32 microcontroller we need to install the keil uvision 5 version then install the mm32-link programmer go to li...