66
For C language users:
Step 2: Open the code file
cd
/
home
/
pi
/
SunFounder_Super_Kit_V3.0_for_Raspberry_Pi/C
Step 3:
Compile the Code
make
08_
4N35
Step 4: Run the executable file above.
sudo
./
08_4N35
Code Explanation
digitalWrite(_4N35Pin, LOW);
// set the I/O port as low level (0V), thus the optocoupler
is energized, and the pin connected to LED conducts to the 0V. Then the LED lights up.
delay(500);
// optocoupler is a kind of electronic device and there is no limitation on
its on-off frequency.
digitalWrite(_4N35Pin, HIGH);
// set I/O port as high level (3.3V), thus the optocoupler
is not energized ,and the pin connected to LED cannot conduct to the 0V. Then the LED
goes out.
For Python users:
Step 2: Open the code file
cd
/
home
/
pi
/
SunFounder_Super_Kit_V3.0_for_Raspberry_Pi
/
Python
Step 3: Run
sudo
python
08_4N35
.py
Code Explanation
GPIO.output(Pin_4N35, GPIO.LOW)
# set the pins of optocoupler as low level, thus the
optocoupler is energized, and the pin connected to LED conducts to the 0V.Then the LED
lights up.
time.sleep(0.5)
#wait for 0.5 second. The on-off frequency of the
optocoupler can be changed by modifying this parameter.
GPIO.output(Pin_4N35, GPIO.HIGH)
# set the pins of optocoupler as high level, thus the
optocoupler is disconnected, and the pin connected to LED break the connection to the
0V. Then the LED goes out.
time.sleep(0.5)
You will see the LED blinks.
Содержание Super Kit 3.0
Страница 7: ...4 22 RGB LED 1 23 LED red 8 24 LED white 4 25 LED green 4 26 LED yellow 4 27 NPN Transistor S8050 2 ...
Страница 30: ...27 Also we have drawn a table of the corresponding BCM wiringPi and Name of each pins ...
Страница 78: ...75 Now pull the slide and you can see the two LEDs light up alternately ...