當input 為 0V .... 相對應的led 會亮起來... 然後 com 和 NO 會連起來
因為input 的default 為 3.3V 高電為......
config 'interface' 'example' option 'proto' 'dhcp' option 'ifname' 'eth0' option 'defaultroute' '1'
mt7688_pinmux
command to switch the pin mux for changing the function of a pin.mt7688_pinmux get
command to query the current pin mux states:ephy
and gpio
functions. And currently it is in the ephy
function due to the surrounded [
and ]
.mt7688_pinmux
command with the set
parameter. The following example changes the function of the Group ephy from ephy
to gpio
:root@mylinkit:/# mt7688_pinmux set ephy gpio
set pinmux ephy -> gpio
get
parameter to verify the current pin mux states:root@mylinkit:/# mt7688_pinmux get
Group i2c - [i2c] gpio
Group uart0 - [uart] gpio
Group uart1 - [uart] gpio
Group uart2 - [uart] gpio pwm
Group pwm0 - [pwm] gpio
Group pwm1 - [pwm] gpio
Group refclk - refclk [gpio]
Group spi_s - spi_s [gpio]
Group spi_cs1 - [spi_cs1] gpio refclk
Group i2s - i2s [gpio] pcm
Group ephy - ephy [gpio]
Group wled - [wled] gpio
ephy
to gpio
.2
:import mraa
pin = mraa.Gpio(2) # Initialize GPIO2 (P10 on LinkIt Smart 7688 board)
P10
of LinkIt Smart 7688 and it’s the IS2_WS
pin in data sheet, as shown in table below.GPIO Number | Datasheet | Silk print on LinkIt Smart 7688 |
---|---|---|
2 | I2S_WS | P10 |
/sys/class/gpio/2
which maps to exactly the same P10
pin on the LinkIt Smart 7688 board.import mraa
print (mraa.getVersion())
OUTPUT
- set the pin to HIGHor LOW to enable and disable external switches or to form signal patterns.import mraa
pin = mraa.Gpio(2) # Initialize GPIO2 (P10 on LinkIt Smart 7688 board)
pin.dir(mraa.DIR_OUT) # set as OUTPUT pin
pin.write(0)
to set the pin state to LOW or call pin.write(1)
to set the pin state to HIGH. To make the Wi-Fi LED blink periodically, set pin 44 (WLED_N) to GPIO
mode and execute the following code:import mraa
import time
# Refer to the pinout digram for the GPIO number to silk print mapping
# in this example the number 44 maps to Wi-Fi LED.
pin = mraa.Gpio(44)
pin.dir(mraa.DIR_OUT)
while True:
pin.write(1)
time.sleep(1)
pin.write(0)
time.sleep(1)
INPUT
. It takes the digital signal input from the pin and interprets it into 1 and 0. This example will continuously print out the value received from P10 on the board. You can short 3V3
and P10
to observe the change in values.import mraa
import time
# Refer to the pinout digram for the GPIO number to silk print mapping
# in this example the number 2 maps to P10 on LinkIt Smart 7688 board
pin = mraa.Gpio(2)
pin.dir(mraa.DIR_IN)
while True:
print "P10 state:", pin.read()
time.sleep(0.3)
P10
(GPIO2
) has changed. Call isr API with the trigger type you want to register and the function to be called. Note that the function runs in a different thread.import mraa
import time
def callback(userdata):
print "interrupt triggered with userdata=", userdata
pin = mraa.Gpio(2)
pin.dir(mraa.DIR_IN)
pin.isr(mraa.EDGE_BOTH, callback, None)
while(True):
time.sleep(1)
# simply wait for interrupt
import mraa
pin = mraa.Pwm(18) # initialize on GPIO18 (pin P26)
pin.period_ms(2) # set PWM frequency to 500Hz (2ms period)
pin.enable(True) # enable PWM output
pin.write(0.25) # set duty cycle to 25%
GPIO4(P21)
and GPIO5(P20)
as SCL and SDA respectively. The way I2Cs are initialized is slightly different from GPIO modules - instead of using pins, I2Cs are initialized according to its device index. Since there is only 1 set of I2C master device on LinkIt Smart 7688, you can simply pass 0
- and it is always on pin GPIO4
andGPIO5
.import mraa
i2c = mraa.I2c(0)
import mraa
i2c = mraa.I2c(0)
# Grove - 3-Axis Digital Accelerometer(+-16g)
# is a ADXL345 configured to I2C address 0x53.
i2c.address(0x53)
# The device ID should be
if 0xE5 == i2c.readReg(0x00):
print "Grove - 3-Axis Digital Accelerometer found on I2C Bus"
else:
print "Grove - 3-Axis Digital Accelerometer not found"
SPI_MOSI(P22)
, SPI_MISO(P23)
, SPI_CLK(P24)
, and SPI_CS1(P25)
.import mraa
spi = mraa.Spi(0)
GND
, 3V3
, SDA(P20)
and SCL(P21)
on LinkIt Smart 7688 board.pyupm_adxl345
module from the UPM repository in your program, you’ll do this in the next step. This module is used because the Grove 3-Axis Digital Accelerometer (±16g) uses the ADXL345 chipset.import pyupm_adxl345 as adxl
import time
device = adxl.Adxl345(0)
while True:
device.update()
a = device.getAcceleration()
print "(x,y,z)=%5.1f, %5.1f, %5.1f" % (a[0], a[1], a[2])
time.sleep(0.3)
python adxl.py
#
mjpg_streamer -i "input_uvc.so -d /dev/video0 -r 640x480 -f 25" -o "output_http.so -p 8080 -w /www/webcam" &
http://mylinkit.local:8080
and the streaming video from the webcam will be shown as below: # madplay "path_to_your_mp3_file"
# aplay -M "path_to_your_wav_file"
#
arecord -f cd -t wav -M /Media/USB-A1/my_recording.wav
.frequency()
API in MRAA is not functional. Please use the spi-config
command to adjust the SPI working frequency. The following command sets the SPI working frequency to 7MHz:# spi-config -d /dev/spidev32766.1 -s 7000000