Tkinter Toplevel Widget

The Toplevel widget work pretty much like Frame, but it is displayed in a separate, top-level window. Such windows usually have title bars, borders, and other “window decorations”.

The Toplevel widget is used to display extra application windows, dialogs, and other “pop-up” windows.

ref: http://effbot.org/tkinterbook/toplevel.htm

Ball – Ball Collision

Below is a python code written in codeskulptor to test the reflection of a ball when it collides with another ball. Different values can be given to v and v1 to test it if is working in the manner we want to.

from math import *
v = [1, 0]
v1= [0, 0]
angle = pi/4

def update_collision(v,angle):
v1[0]=v[0]*(sin(angle)**2-cos(angle)**2)-2*v[1]*sin(angle)*cos(angle)
v1[1]=-v[1]*(sin(angle)**2-cos(angle)**2)-2*v[0]*sin(angle)*cos(angle)
return v1

print update_collision(v)

DX BALL

This is a game that I made after completing a course on interactive python. The coding was done in codeskulptor.

  • The course helped me to learn how to write code for GUIs.
  • It helped me to understand how powerful classes are in programming.
  • As it had a certain deadline for the projects, I learnt to manage my time better than I usually do.
  • From this program, I learnt how to make a ball reflect of another ball when they collide with each other.
  • Link : http://www.codeskulptor.org/#user40_gYWOngGyxdBfvwS_0.py

game

Scripting with Python for Arduino

I had to learn on programming the Arduino for producing two square signals that operated in different frequencies and at the same time, had to perform a duty sweep along with a Frequency sweep. The Arduino had a machine level commands of nop; No Operation command, given directly to the required pins. Each nop has a time period of 62.5ns and manually doing each frequency seemed to be a time consuming process. Then scripting the a python code that could take inputs of Frequency and duty cycle and produce a .ino file that the Arduino reads was super efficient, files were created instantly. but i faced another issue my files contained periods in the files name i had to debug cause Arduino does not accept periods in its file names. Following is the script file that i converted into an executable using pyinstaller.

PrintArduinoDuty

Timer in Python

I encountered a situation where I had to check if a function is running for a certain time. The below method called ‘after’ was very useful. This registers an alarm callback that is called after a given time.

Syntax : after(delay_ms, callback=None, *args) 

Programming the Deek Robot

The Deek robot is similar to the Arduino pro mini with a ATmega 328. it has no USB interface. i used the Arduino UNO to program the Deek robot, without removing the micro controller ATmega 328 from the UNO board.

1. Connect the Arduino UNO and upload the program

2. Connect jumpers as follows
Arduino      UNO               –>         pro mini
RESET             –>         GRN
RX                   –>         RXD
TX                   –>         TXD
5V                   –>         VCC
GND               –>         GND

GND             –>           BLK

Arduino      UNO               –>         DEEK_ROBOT
RESET             –>         RESET
TX                   –>         TXD
5V                   –>         VCC
GND               –>         GND

GND               –>         GRD

Now using Arduino UNO as an ISP, from the Tools, Programmer .

and selecting the board as Arduino Pro or Pro mini (5V,16Mhz)w ATmega 328, from the Tools, Board.

Upload the program.

USING FTDI to program;

FTDI                –>         DEEK_ROBOT
RX                   –>         TXD
TX                   –>         RXD
5V                   –>         VCC
GND               –>         GND

Dt                   –>         DTX

Now  use AVR ISP, from the Tools, Programmer .

and selecting the board as Arduino Pro or Pro mini (5V,16Mhz)w ATmega 328, from the Tools, Board.

 

 

 

Learning Algebra With the the help of scratch

After finished Geometry i was switched to Algebra. Mastering algebra is important for moving on to nearly all other types of mathematics in  school. However, even the most basic algebra skills can be tricky for beginners to understand the first time they encounter them. I was in the need to know their prior knowledge in algebra in order to build on that (if that was conceptual) or correct them (if that was misconception). So, I gave some equations to solve, asked some stories (Multiplication & Division) and gave them small puzzles  to understand their understandings in algebra.

Except few, all posses some sort of difficulties. Some of them could not able to interpret the question, some of them having difficulties in calculation part, Some were guessed the answers. From that i inferred they need more explanation to understand the concepts. So, i took them to computer lab to practise algebra using scratch programming. First, i gave an expression of 5x+10 and asked them to draw bar graphs in scratch,                                     where x = 1,2,3,4,…….10(with guidance).

Screenshot from 2015-03-13 08:23:18Screenshot from 2015-03-13 08:23:02

Then, i asked them to find out the value of x in the following equation 5x+10=70.

Screenshot from 2015-03-18 16:27:14 Screenshot from 2015-03-18 16:27:45

<iframe allowtransparency=”true” width=”485″ height=”402″ src=”http://scratch.mit.edu/projects/embed/53042546/?autostart=false”

Link: http://scratch.mit.edu/projects/53046628/

What I was  inferred, they could learn(understand) the things comparatively quicker by programming than doing it manually (as procedural). Hence i decided to add one more concept on that just like fun by asking them to draw multi-stair case like structure by modifying the program   ( underScreenshot from 2015-03-13 12:22:31 guidance).

 

Screenshot from 2015-03-13 12:23:36

<iframe allowtransparency=”true” width=”485″ height=”402″ src=”http://scratch.mit.edu/projects/embed/53046628/?autostart=false”

Link:   http://scratch.mit.edu/projects/53046628/