User Manual

65
Step 1: Build the circuit
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 07_relay
Step 4: Run the executable file above
sudo ./07_relay
Code Explanation
digitalWrite(relayPin, LOW); // set the I/O port as low level (0V) to energize the
transistor. The coil of the relay is powered and generate electromagnetic force, and the
relay closes.
digitalWrite(relayPin, HIGH); // Set the I/O port as high level (5V), thus the
transistor is not energized and the coil is not powered. There is no electromagnetic
force, so the relay opens.
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 07_relay.py
Code Explanation
SunFounder