EasyManuals Logo

Freenove Ultimate Starter Kit User Manual

Freenove Ultimate Starter Kit
286 pages
To Next Page IconTo Next Page
To Next Page IconTo Next Page
To Previous Page IconTo Previous Page
To Previous Page IconTo Previous Page
Page #55 background imageLoading...
Page #55 background image
55
Chapter 1 LED
www.freenove.com
support@freenove.com
Code
According to the circuit, when the GPIO17 of RPi output high level, LED is turned on. Conversely, when the
GPIO17 RPi output low level, LED is turned off. Therefore, we can let GPIO17 output high and low level in
cycle to make LED blink. We will use both C code and Python code to achieve the target.
C Code 1.1.1 Blink
First, execute command into the terminal one by one. Then observe the project result, and analyze the code.
1. Use cd command to enter 01.1.1_Blink directory of C code.
cd ~/Freenove_Ultimate_Starter_Kit_for_Raspberry_Pi/Code/C_Code/01.1.1_Blink
2. Use the following command to compile the code “Blink.cand generate executable file Blink.
l of lwiringPi is low case of L.
gcc Blink.c -o Blink -lwiringPi
3. Then run the generated file blink”.
sudo ./Blink
Now, LED start blink.
You can press “Ctrl+C” to end the program. The following is the program code:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
#include <wiringPi.h>
#include <stdio.h>
#define ledPin 0
int main(void)
{
if(wiringPiSetup() == -1){ //when initialize wiring failed, print message to screen
printf("setup wiringPi failed !");
return 1;
}
//when initialize wiring successfully, print message to screen
printf("wiringPi initialize successfully, GPIO %d(wiringPi pin) \n",ledPin);
pinMode(ledPin, OUTPUT);
while(1){
digitalWrite(ledPin, HIGH); //led on

Table of Contents

Questions and Answers:

Question and Answer IconNeed help?

Do you have a question about the Freenove Ultimate Starter Kit and is the answer not in the manual?

Freenove Ultimate Starter Kit Specifications

General IconGeneral
BrandFreenove
ModelUltimate Starter Kit
CategorySingle board computers
LanguageEnglish