April 2020
Intermediate to advanced
412 pages
9h 58m
English
We are going to create a simple application that gradually changes the brightness of an LED connected to a general-purpose pin on a Raspberry Pi board:
#include <chrono>#include <thread>#include <wiringPi.h>using namespace std::literals::chrono_literals;const int kLedPin = 0;void Blink(std::chrono::microseconds duration, int percent_on) { digitalWrite (kLedPin, HIGH); std::this_thread::sleep_for( duration * percent_on / 100) ; digitalWrite (kLedPin, LOW); std::this_thread::sleep_for( duration * (100 ...