IO Expander - Using I/O Expander module
Preparation
- Ameba x 1
- SparkFun SX1509 I/O Expander x 1
- LED x 1
Example
In this example we use SX1509 I/O Expander module to expand I/O ports to 16 I/O ports.
We need the following library:
https://github.com/sparkfun/SparkFun_SX1509_Arduino_Library/archive/master.zip
We need the following library:
https://github.com/sparkfun/SparkFun_SX1509_Arduino_Library/archive/master.zip
Please refer to Arduino official tutorial to add .zip library to Ameba:
https://www.arduino.cc/en/Guide/Libraries#toc4
Open the sample code in “File” -> “Examples” -> “SX1509 IO Expander” -> “breathe”
RTL8195 Wiring diagram:
RTL8710 Wiring diagram:
Code reference
This example makes the LED dims and lights like the breathing lights.
First, set pin 15 of SX1509 to be the output port of LED. Therefore, the positive pole of LED should be connected to pin 15 on SX1509.
First, set pin 15 of SX1509 to be the output port of LED. Therefore, the positive pole of LED should be connected to pin 15 on SX1509.
const byte SX1509_LED_PIN = 15;
Use internal 2MHz oscillator and set the LED clock to 500kHz (2MHz / (2^(3-1)).
io.clock(INTERNAL_CLOCK_2MHZ, 3);
Let LED repeat the full-dimmed, full-light, half-light, half-dimmed cycle. The arguments:
full-dimmed time: 1000ms
full-light time: 500ms
half-light time: 500ms
half-dimmed time: 250ms
io.breathe(SX1509_LED_PIN, 1000, 500, 500, 250);
Copyrights ©瑞晟微电子(苏州)有限公司 2021. All rights reserved. Terms of Use