Skip to Content
Hands-On Robotics Programming with C++
book

Hands-On Robotics Programming with C++

by Dinesh Tavasalkar
March 2019
Intermediate to advanced
312 pages
7h 37m
English
Packt Publishing
Content preview from Hands-On Robotics Programming with C++

Writing the LEDBuzzer.cpp program

The name of our program is LEDBuzzer.cpp. The LEDBuzzer.cpp program can be downloaded from the Chapter05 folder of the GitHub repository. The LEDBuzzer program is as follows:

#include <ncurses.h>#include <wiringPi.h>#include <stdio.h>int main(){ wiringPiSetup(); pinMode(15,OUTPUT); //LED 1 pin pinMode(4, OUTPUT); //LED 2 pin pinMode(27,OUTPUT); //Buzzer pinfor(;;){initscr();int keypressed = getch();if(keypressed=='L' || keypressed=='l'){ digitalWrite(15,HIGH); delay(1000); digitalWrite(15,LOW); delay(1000);}if(keypressed== 69 || keypressed=='e')       // 69 is ASCII number for E.{ digitalWrite(4,HIGH); delay(1000); digitalWrite(4,LOW); delay(1000);}if(keypressed=='D' || keypressed=='d'){ digitalWrite(15,HIGH); ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Learn Robotics Programming

Learn Robotics Programming

Danny Staple
C++ Reactive Programming

C++ Reactive Programming

Praseed Pai, Peter Abraham

Publisher Resources

ISBN: 9781789139006Supplemental Content