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 #112 background imageLoading...
Page #112 background image
Chapter 8 Potentiometer & LED
112
www.freenove.com
support@freenove.com
Code
C Code 8.1.1 Softlight
First observe the project result, and then analyze the code.
1. Use cd command to enter 08.2.1_Softlight directory of C code.
cd ~/Freenove_Ultimate_Starter_Kit_for_Raspberry_Pi/Code/C_Code/08.1.1_Softlight
2. Use following command to compile “Softlight.c and generate executable file Softlight”.
gcc Softlight.c -o Softlight -lwiringPi -lpthread
3. Then run the generated file “Softlight”.
sudo ./Softlight
After the program is executed, shift the potentiometer, then the terminal window will print out the voltage
value of the potentiometer and the converted digital quantity. And brightness of LED will be changed
consequently.
The following is the code:
1
2
3
4
5
6
7
8
9
10
#include <wiringPi.h>
#include <pcf8591.h>
#include <stdio.h>
#include <softPwm.h>
#define address 0x48 //pcf8591 default address
#define pinbase 64 //any number above 64
#define A0 pinbase + 0
#define A1 pinbase + 1
#define A2 pinbase + 2

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