• Home
  • pcDuino
  • WiKi
  • Store
  • Distributors
  • Home
  • pcDuino
  • WiKi
  • Store
  • Distributors
HomepcDuinoPythonpingoUse pingo uniform API to program pcDuino
Previous Next

Use pingo uniform API to program pcDuino

Posted by: Yang , June 30, 2014

pingo

pingo provides a uniform API to program devices like the Raspberry Pi, BeagleBone Black, pcDuino etc. just like the Python DBAPI provides an uniform API for database programming in Python.

The API is object-oriented but easy to use: a board is an instance of a Board subclass. Every board has a dictionary called pins which lists all GPIO pins on the board. Each pin is an instance of a Pin subclass with attributes that you can inspect to learn about its capabilities.

The name Pingo is a tribute to Garoa Hacker Clube, where the project started (the words pingo and garoa are related in Portuguese). To our English-speaking friends we like to say that it means “pin, go!” — the main purpose of this package.

Donwnload Latest version pingo – 0.1.9 https://pypi.python.org/pypi/pingo/0.1.9

pingo-0.1.9.tar.gz 

https://pypi.python.org/packages/source/p/pingo/pingo-0.1.9.tar.gz

Git clone it :

$sudo apt-get install git

$git clone https://github.com/garoa/pingo

OR

$git clone https://github.com/pcduino/pingo

 

Basic usage

To use pingo, the first step is to instatiate a concrete Board. Each Pingo driver is a concrete board, for example, pingo.rpi.RaspberryPi and pingo.arduino.ArduinoFirmata are two such boards.

Pingo can automatically detect the board in most common cases. If it is running on a supported board, pingo.detect.MyBoard() returns an proper board instance. If Pingo is running on an unsupported machine (eg. a PC running GNU/Linux), it will try to find a remote Arduino using the Firmata protocol via USB and — if succesfull — will return a pingo.arduino.ArduinoFirmata instance.

Once you have a board instance, its possible to access its pins through the board.pins dict.

import time
import pingo

board = pingo.detect.MyBoard()
led = board.pins[13]
led.mode = pingo.OUT

while True:
    led.toggle()
    time.sleep(.1)

2014-07-01-033329_660x464_scrot

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

Note: We  test many examples on pcDuino 3, just only above script  correct.

Note:  board = pingo.detect.MyBoard() instead of pingo.pcduino.PcDuino()

board = pingo.pcduino.PcDuino() is correct .It’s not  pcduino(), pcDuino(), PCDUINO() or any other .

Beside this script from pingo 0.1.9  https://pypi.python.org/pypi/pingo

import pingo
from time import sleep

board = pingo.detect.MyBoard()
led_pin = board.pins[13]
led_pin.mode pingo.OUT

while True:
    led_pin.hi()
    sleep(1)
    led_pin.lo()
    sleep(1)

and this script from Basic Usage https://github.com/garoa/pingo

import pingo
from time import sleep

board = pingo.detect.MyBoard()
led_pin = board.pins[13]
led_pin.mode pingo.OUT

while True:
    led_pin.hi()
    sleep(1)
    led_pin.lo()
    sleep(1)

and this script from https://pypi.python.org/pypi/pingo/0.1.8

import pingo
from time import sleep

board = pingo.pcduino.PcDuino()
led_pin = board.pins[13]
led_pin.set_mode(pingo.OUTPUT)

while True:
    led_pin.high()
    sleep(1)
    led_pin.low()
    sleep(1)

All of them raise different errors.

 

 

 

Tags: pingo

Share!
Tweet

Yang

About the author

Leave a Reply Cancel reply

You must be logged in to post a comment.

Category

  • Home
  • pcDuino
  • WiKi
  • Store
  • Distributors