April 2020
Intermediate to advanced
412 pages
9h 58m
English
We are going to create a simple application that controls a Light Emitting Diode (LED) connected to a general-purpose pin on a Raspberry Pi board:
#include <chrono>#include <iostream>#include <thread>#include <wiringPi.h>using namespace std::literals::chrono_literals;const int kLedPin = 0;int main (void){ if (wiringPiSetup () <0) { throw std::runtime_error("Failed to initialize wiringPi"); } pinMode (kLedPin, OUTPUT); while (true) { digitalWrite (kLedPin, HIGH); std::cout << "LED on" << std::endl; std::this_thread::sleep_for(500ms) ...