Blinking LEDs

The simplest thing to start with is to control LEDs connected to any of the terminals. Connect an LED from PB0 to Ground with 5k resistor in series, for current limiting. The LED should blink when you run the Python program

while 1:
    setReg(PORTD, 255)
    setReg(PORTD, 0)

Let us examine the code line by line:
from kuttyPy import *
This line imports the kuttyPy module ( should be in your working directory). This module gives you  functions that can read/write the Registers of the micro-controller connected to the USB port.  This line also searches for the hardware on the available USB ports. If nothing found, the program is terminated.

DDRB is an 8bit Register that decides the direction of the terminals PB0 -- PB7. If a bit is 1, the corresponding terminal becomes an output. If it is zero, the terminal becomes an input. DDR stands for Data Direction Register. The last letter represents the port, for example DDRA decides the direction of port A.

time.sleep(1)   , for a one second wait

PORTB is an 8bit Register where you set the output level of the terminals PB0 -- PB7. If a bit is 1, the voltage at the corresponding terminal becomes HIGH, else it becomes LOW. Here we are making all the terminals HIGH, means LED conected to any of them will glow.  In a similar manner you can use PORTA, PORTC and PORTD.

setReg(PORTB, 0)
As explained above, PB0 to PB7 will be set to LOW.

Running this loop makes the LEDs connected to any of the terminals PB0 to PB7 will blink. The frequency will be decided by the delay specified in time.sleep()