@@ -39,17 +39,32 @@ Use the :mod:`time <utime>` module::
3939 start = time.ticks_ms() # get value of millisecond counter
4040 delta = time.ticks_diff(time.ticks_ms(), start) # compute time difference
4141
42- LEDs
43- ----
42+ Internal LEDs
43+ -------------
4444
4545See :ref: `pyb.LED <pyb.LED >`. ::
4646
4747 from pyb import LED
4848
49- led = LED(1) # red led
49+ led = LED(1) # 1= red, 2=green, 3=yellow, 4=blue
5050 led.toggle()
5151 led.on()
5252 led.off()
53+
54+ # LEDs 3 and 4 support PWM intensity (0-255)
55+ LED(4).intensity() # get intensity
56+ LED(4).intensity(128) # set intensity to half
57+
58+ Internal switch
59+ ---------------
60+
61+ See :ref: `pyb.Switch <pyb.Switch >`. ::
62+
63+ from pyb import Switch
64+
65+ sw = Switch()
66+ sw.value() # returns True or False
67+ sw.callback(lambda: pyb.LED(1).toggle())
5368
5469Pins and GPIO
5570-------------
@@ -99,6 +114,17 @@ See :ref:`pyb.Timer <pyb.Timer>`. ::
99114 tim.freq(0.5) # 0.5 Hz
100115 tim.callback(lambda t: pyb.LED(1).toggle())
101116
117+ RTC (real time clock)
118+ ---------------------
119+
120+ See :ref: `pyb.RTC <pyb.RTC >` ::
121+
122+ from pyb import RTC
123+
124+ rtc = RTC()
125+ rtc.datetime((2017, 8, 23, 1, 12, 48, 0, 0)) # set a specific date and time
126+ rtc.datetime() # get date and time
127+
102128PWM (pulse width modulation)
103129----------------------------
104130
@@ -167,3 +193,25 @@ See :ref:`pyb.I2C <pyb.I2C>`. ::
167193 i2c.recv(5, 0x42) # receive 5 bytes from slave
168194 i2c.mem_read(2, 0x42, 0x10) # read 2 bytes from slave 0x42, slave memory 0x10
169195 i2c.mem_write('xy', 0x42, 0x10) # write 2 bytes to slave 0x42, slave memory 0x10
196+
197+ CAN bus (controller area network)
198+ ---------------------------------
199+
200+ See :ref: `pyb.CAN <pyb.CAN >`. ::
201+
202+ from pyb import CAN
203+
204+ can = CAN(1, CAN.LOOPBACK)
205+ can.setfilter(0, CAN.LIST16, 0, (123, 124, 125, 126))
206+ can.send('message!', 123) # send a message with id 123
207+ can.recv(0) # receive message on FIFO 0
208+
209+ Internal accelerometer
210+ ----------------------
211+
212+ See :ref: `pyb.Accel <pyb.Accel >`. ::
213+
214+ from pyb import Accel
215+
216+ accel = Accel()
217+ print(accel.x(), accel.y(), accel.z(), accel.tilt())
0 commit comments