Loading...
Searching...
No Matches
arduino.py

Optional Arduino-style functions: from arduino import *, with Arduino's names and ranges. More...

Topics

 Digital I/O
 Pins as inputs and outputs: pinMode(), digitalWrite(), digitalRead() and the pin constants.
 Analog I/O
 Reading A0-A5 with analogRead() (0-1023) and PWM with analogWrite() (0-255), with their settings.
 Tones
 Notes on a piezo buzzer: tone() and noTone().
 Time
 Waiting and timing: delay(), delayMicroseconds(), millis() and micros().
 Math
 Rescaling and limiting numbers: map() and constrain().

Detailed Description

Optional Arduino-style functions: from arduino import *, with Arduino's names and ranges.

Built into the firmware next to phyduino.py:

from arduino import *
pinMode(LED_BUILTIN, OUTPUT)
digitalWrite(LED_BUILTIN, HIGH)
print(analogRead(A0)) # 0-1023
Arduino-style functions for the Phyduino Pico, built on phyduino.py.
Definition arduino.py:1

Digital pins are numbers (13 is D13) or the board's names ("D13"). The Pins rules still apply: no D14-D17, A3-A5 are analogue only, and pairs of pins share a PWM output. Serial, Wire and SPI are not here: use print(), i2c(), spi() and uart() from phyduino.py.

from arduino import * replaces Python's map() with the Arduino one.