Python-Basic Operators

Python language supports following type of operations:
[Arithematic, Comparison, Logical, Assignment, Conditional]

Arithematic operators are:

+ ,  - ,  * ,  / ,  % , ** (exponent) , // (division but digits after decimal in quotient is removed)

Comparison Operators: 
  • ' == ' Checks if the value of two operands are equal or not, if equal then condition becomes true.
  • ' != ' Checks if the value of two operands are equal or not, if not equal then condition becomes true.
  • ' <> ' is similar to ' != '
  • ' > '  checks if the value of left operand is greater than right operand and, if yes then condition become true. Similarly there are comparison operators '<' , '>=', '<=' as in C.

Python - Variable Types

Assigning Values to Variables:

In python, variables are automatically declared when we assign a value to a variable. We use equal sign (=) to assign value to variable. For example:
a = 100                  #integer assignment
name = "linux"       # floating point
num = 244.4412   # string

Multiple Assignment: 

Assigning single value to many variables:
a = b = c = 1
Assigning multiple objects to multiple variables:
a , b , c = 30, 5.54, "hello"
   here  a= 30 , b = 5.54, c = hello


         Whitespace is important in Python. Actually, whitespace at the beginning of the line is important. This is called indentation. Leading whitespace (spaces and tabs) at the beginning of the logical line is used to determine the indentation level of the logical line, which in turn is used to determine the grouping of statements. This means that statements which go together must have the same indentation. Each such set of statements is called a block.  Program in a bracketed language would merely become more difficult to read and consumes much time of the programmer and also affects the readability. Indentation solves the above problems of a bracketed languages (like C, C++ etc).



PYTHON is an interpreted, interactive, object-oriented programming language.

- When a language is interpreted it means that it is processed at runtime by the interpreter. 
- Interactive means that we can actually sit at a python prompt and interact with the interpreter directly.
- Object-Oriented is a style or technique of programming that encapsulates code within objects.

An attempt to access a memory card (MMC) using a PIC with limited RAM (PIC16F877A)


                                      Video of my PIC16F877A based MMC digital voice recorder:

This is my first digital voice recorder which is made using a mid range PIC with a total RAM of only 256 bytes. Generally people may say that  we cannot access MMC/SD card using a microcontroller with a RAM < 512. I had seen such posts and comments in many electronics forums, sites etc. But now i could comment  it is also possible to access MMC/SD using a uC with limited RAM but may have much limitations compared to uC with enough RAM.
        Here, i used a PIC16F877A to access an MMC.  MMC is interfaced to PIC16F877A via SPI. I didn't used any file system here. It writes the 8 bit digital data from ADC to the MMC using a multiple block write command. A single block consist of 512 bytes , also called as a sector.

 Similarly it reads the 8bit digital data (digital samples)  using a mutliple block read command. After reading each byte, it is sent to the PWM register to generate PWM signal corresponding to the audio recorded.  Then after passing the PWM signal throuh a low pass filter, the analog  signal could be obtained which is then amplified and introduced to a speaker to reproduce the recorded voice.
       The audio quality was beyond my expectation. The reason for the good audio quality is the high bit rate.. Since i didn't used any file system (FAT etc) I could easily use multiple block read and multiple block write commands to read and write MMC and thus it could achieve the maximum bit rate.

TV remote controlled SNAKE GAME in 8*10 LED dotmatrix display!

Video of my TV remote controlled 8*10 LED dotmatrix SNAKE GAME

(Also, I made similar LED dotmatrix CAR RACING game and PONG game , those videos are at bottom of the page)

Philips TV remote decoder using PIC16F84A


RC-5 protocol:
The protocol uses bi-phase modulation (or so-called Manchester coding) of a 36KHz IR carrier frequency. All bits are of equal length of 1.778ms in this protocol, with half of the bit time filled with a burst of the 36KHz carrier and the other half being idle. A logical zero is represented by a burst in the first half of the bit time. A logical one is represented by a burst in the second half of the bit time.
when a button in remote is pressed, in transmits a 14 bit IR signal modulated as above. Now, the 14 bit signal is represented as below.

Scrolling text in LED dotmatrix display

Multiplexed displays are electronic displays where the entire display is not driven at one time. Instead, sub-units of the display (typically, rows or columns for a dot matrix display or individual characters for a character orientated display, occasionally individual display elements) are multiplexed, that is, driven one at a time, but the electronics and the persistence of vision combine to make the viewer believe the entire display is continuously active.

10x8 LED dot matrix display:
   Below figure illustrates the construction of a 10x8 LED dot matrix display.