Pynguino 2.0 /

Filename Size Date modified Message
pinguino
python
85 B
Update package
2.3 KB
README.md edited online with Bitbucket

Pynguino 2.0

It is a program that allows develop interfaces with Pinguino using any programming language that can communicate with the serial or USB port where the board are connected.

Features

  • The commands use the same syntax that used in the IDE.
  • Is easy to use for develop libraries for languages programming.

Modules

Modules developed with this code.

Examples

Examples using raw code and manual configuration.

Python

from serial import Serial
pinguino = Serial("/dev/ttyACM0", timeout=0.1, baudrate=9600)
pinguino.write("pinMode(0,OUTPUT)")
pinguino.write("digitalWrite(0,HIGH)")
pinguino.write("pinMode(7,INPUT)")
read = pinguino.write("digitalRead(7)")
pinguino.close()
Python 2.7.3 (default, Sep 26 2012, 21:51:14) 
[GCC 4.7.2] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import serial
>>> pinguino=serial.Serial("/dev/ttyACM0")
>>> pinguino.write("pinMode(0,OUTPUT)")
>>> pinguino.write("digitalWrite(0,HIGH)")
>>> pinguino.write("digitalWrite(0,LOW)")
>>>
>>> pinguino.write("pinMode(13,INPUT)")
>>> pinguino.write("analogRead(13)")
>>> pinguino.readline()
'689\n'
>>> pinguino.write("pinMode(10,OUTPUT)")
>>> pinguino.write("analogWrite(10, 987)")
>>>

Ruby

#!/usr/bin/env ruby

#Importamos el módulo serial
require 'serialport'

port_str = "/dev/ttyACM0" #El puerto puede variar
baud_rate = 9600 
data_bits = 8 
stop_bits = 1 
parity = SerialPort::NONE 

pinguino = SerialPort.new(port_str, baud_rate, data_bits, stop_bits, parity)  

pinguino.write "pinMode(13,OUTPUT)"
while true do 
    pinguino.write "digitalWrite(13,HIGH)"
    sleep(0.25) 
    pinguino.write "digitalWrite(13,LOW)"
    sleep(0.25)
end

Scilab

--> atomsInstall('serial')
pinguino=openserial('/dev/ttyACM1')
writeserial(pinguino, "pinMode(0,OUTPUT)")

i=0
while (i<=10)
    writeserial(pinguino, "digitalWrite(0,HIGH)")
    printf("HIGH\n")
    sleep(500)
    writeserial(pinguino, "digitalWrite(0,LOW)")
    printf("LOW\n")
    sleep(500)
    i=i+1
end

closeserial(pinguino)