23024_lapsem.docx

  • Uploaded by: Yogi Amtara
  • 0
  • 0
  • December 2019
  • PDF

This document was uploaded by user and they confirmed that they have the permission to share it. If you are author or own the copyright of this book, please report to us by using this DMCA report form. Report DMCA


Overview

Download & View 23024_lapsem.docx as PDF for free.

More details

  • Words: 377
  • Pages: 7
Workshop Interface Selasa, 5 Maret 2019 Lab. H 102 Anggota : 1. Irfan

(1110171004)

2. Yogi amtara

(1110171011)

3. Rizky Muhammad Panji (1110171023) 4. Alif Ahmad Hakim

(1110171024) Percobaan 0 Pemrograman Rapberry Pi dengan C++

1. Percobaan 0 Program yang digunakan : #include using namespace std; int main(int argc, char **argv) { cout<<"Hello World" << endl; return 0; } Output yang dihasilkan :

2. Tugas 1 Program yang digunakan : #include #include <wiringPi.h> using namespace std;

int ledPin = 29;

void setup(){

pinMode (ledPin,OUTPUT); cout<<"Hello World" << endl; }

void loop(){ digitalWrite(ledPin,HIGH); delay(1000); cout<<"LED ON" << endl; digitalWrite(ledPin,LOW); delay(1000); cout<<"LED OFF" << endl;

}

int main(void) { if(wiringPiSetup()<0){ cout<<"setup wiring pi failed"<<endl; return 1; } setup(); while(1){ loop(); } return 0; }

Output yang dihasilkan :

Blink LED

3. Tugas 2 Program yang digunakan : #include #include <wiringPi.h> using namespace std; int ledPin1 = 29, ledPin2 = 28, ledPin3 = 27, ledPin4 = 25; void setup(){ pinMode (ledPin1,OUTPUT); pinMode (ledPin2,OUTPUT); pinMode (ledPin3,OUTPUT);

pinMode (ledPin4,OUTPUT); cout<<"Hello World" << endl; } void loop(){ digitalWrite(ledPin1,HIGH); delay(500); cout<<"LED ON" << endl; digitalWrite(ledPin1,LOW); delay(500); cout<<"LED OFF" << endl; digitalWrite(ledPin2,HIGH); delay(600); cout<<"LED ON" << endl; digitalWrite(ledPin2,LOW); delay(600); cout<<"LED OFF" << endl; digitalWrite(ledPin3,HIGH); delay(700); cout<<"LED ON" << endl; digitalWrite(ledPin3,LOW); delay(700); cout<<"LED OFF" << endl; digitalWrite(ledPin4,HIGH); delay(800); cout<<"LED ON" << endl; digitalWrite(ledPin4,LOW); delay(800); cout<<"LED OFF" << endl; } int main(void) { if(wiringPiSetup()<0){

cout<<"setup wiring pi failed"<<endl; return 1; } setup(); while(1){ loop(); } return 0; } Output yang dihasilkan :

Running LED 4. Tugas 3 Program yang digunakan : #include #include <wiringPi.h> using namespace std; int ledPin1 = 29; int ledPin2 = 28; int ledPin3 = 27; int ledPin4 = 26; int buttonPin = 24; void setup(){ pinMode (ledPin1,OUTPUT); pinMode (ledPin2,OUTPUT); pinMode (ledPin3,OUTPUT);

pinMode (ledPin4,OUTPUT); pinMode (buttonPin,INPUT); cout<<"Hello World" << endl; } void loop(){ if digitalRead (buttonPin==1) { cout << "TOMBOL AKTIF" << endl; digitalWrite(ledPin1,HIGH); delay(500); digitalWrite(ledPin1,LOW); delay(500); digitalWrite(ledPin2,HIGH); delay(600); digitalWrite(ledPin2,LOW); delay(600); digitalWrite(ledPin3,HIGH); delay(700); digitalWrite(ledPin3,LOW); delay(700); digitalWrite(ledPin4,HIGH); delay(800); digitalWrite(ledPin4,LOW); delay(800); } else {cout <<"TOMBOL TIDAK AKTIF"<< endl; digitalWrite(ledPin1,HIGH); digitalWrite(ledPin2,HIGH); digitalWrite(ledPin3,HIGH); digitalWrite(ledPin4,HIGH); delay(100); digitalWrite(ledPin1,LOW); digitalWrite(ledPin2,LOW); digitalWrite(ledPin3,LOW); digitalWrite(ledPin4,LOW); delay(100);}

} int main(void) { if(wiringPiSetup()<0){ cout<<"setup wiring pi failed"<< endl; return 1; } setup(); while(1){ loop(); } return 0; } Output yang dihasilkan :

Jika PB =1 Running LED, sedangkan PB =0 Blink LED

More Documents from "Yogi Amtara"

4. Observasi Bus.docx
December 2019 8
22745_tugas 3.pdf
December 2019 1
1. Prakt Re2 - Draft.pdf
December 2019 5
23024_lapsem.docx
December 2019 0