Loading...
Searching...
No Matches
arduino Namespace Reference

Arduino-style functions for the Phyduino Pico, built on phyduino.py. More...

Functions

 pinMode (pin, mode)
 Sets a pin up as an input or an output.
 digitalWrite (pin, value)
 Sets an output pin high or low.
 digitalRead (pin)
 Reads a pin's level.
 analogReadResolution (bits)
 Sets the number of bits analogRead() returns.
 analogRead (pin)
 Reads an analogue pin.
 analogWriteResolution (bits)
 Sets the range analogWrite() takes.
 analogWriteFreq (hz)
 Sets the PWM frequency for analogWrite() on pins set up after this.
 analogWrite (pin, value)
 Puts a PWM signal on a pin: a fraction of the time high.
 tone (pin, frequency, duration=None)
 Plays a square wave (a note) on a pin, for example for a piezo buzzer.
 noTone (pin)
 Stops a tone() on a pin.
 delay (ms)
 Waits a number of milliseconds.
 delayMicroseconds (us)
 Waits a number of microseconds.
 millis ()
 Milliseconds since the board started.
 micros ()
 Microseconds since the board started.
 map (value, fromLow, fromHigh, toLow, toHigh)
 Rescales a number from one range to another.
 constrain (value, low, high)
 Limits a number to a range.

Variables

int HIGH = 1
 Pin level: high (3.3 V).
int LOW = 0
 Pin level: low (0 V).
int INPUT = 0
 pinMode(): a digital input with no pull resistor.
int OUTPUT = 1
 pinMode(): a digital output.
int INPUT_PULLUP = 2
 pinMode(): a digital input pulled up to 3.3 V.
int INPUT_PULLDOWN = 3
 pinMode(): a digital input pulled down to 0 V.
str LED_BUILTIN = "LED"
 The on-board green LED.
str A0 = "A0"
 Analogue pin A0 (RP2040 ADC, 0-3.3 V).
str A1 = "A1"
 Analogue pin A1 (RP2040 ADC, 0-3.3 V).
str A2 = "A2"
 Analogue pin A2 (RP2040 ADC, 0-3.3 V).
str A3 = "A3"
 Analogue pin A3 (MAX11635, 0-2.048 V).
str A4 = "A4"
 Analogue pin A4 (MAX11635, 0-2.048 V).
str A5 = "A5"
 Analogue pin A5 (MAX11635, 0-2.048 V).

Detailed Description

Arduino-style functions for the Phyduino Pico, built on phyduino.py.

Built into the Phyduino Pico firmware next to phyduino.py. Optional: use it when you want code that reads like an Arduino sketch.

from arduino import *
pinMode(LED_BUILTIN, OUTPUT)
digitalWrite(LED_BUILTIN, HIGH)
print(analogRead(A0))

Digital pins are numbers, as on an Arduino: 2 is D2, 13 is D13. The names used by phyduino.py ("D2", "A0", "LED") work too. analogRead() also takes 0-5 for A0-A5.

The ranges are Arduino's: analogRead() gives 0-1023 and analogWrite() takes 0-255 until analogReadResolution() or analogWriteResolution() changes them.

from arduino import * replaces Python's map() with the Arduino one; use import arduino if your code needs Python's map().

Licence: GPL-3.0.