Tugas Pendahuluan Modul 3


 
1. Kondisi [Kembali]

       Buatlah led menyala ketika potensiometer 0% dan led padam ketika potensiometer 100%

2. Rangkaian Simulasi [Kembali]


LED menyala ketika kondisi potensiometer 0%


LED mati ketika kondisi potensiometer 100%



3. Flowchart








4. Listing Program [Kembali]

//MASTER

#include <Wire.h>
#define MASTER_ADDR 9
//0-127 alamat 12c
int analogPin = 0;
int val = 0;//dari mapping

void setup() {
  Wire.begin();//siap mengirimkan data
}

void loop() {
  delay(50);
  val = map(analogRead(analogPin), 0, 1023, 255, 1);//pembacaan potensiometer, prubahan poten, proses adc
  //0-123adc
  //1-255pwm

  Wire.beginTransmission(MASTER_ADDR);//memulai transmisi
  Wire.write(val);//dituliaskan sesuai dg value y didapatkan
  Wire.endTransmission();//berhenti

}

//SLAVE

#include <Wire.h>
#define SLAVE_ADDR 9

int LED = 13;
int rd;
int br;

void setup() {
  pinMode(LED, OUTPUT);
  Wire.begin(SLAVE_ADDR);
  Wire.onReceive(receiveEvent);

}

void receiveEvent() {
  rd = Wire.read();
}
void loop() {
 delay(50);

  br = map(rd, 1, 255, 100, 2000);

  if (br == 2000){
  delay(1000);
  digitalWrite(LED, HIGH);
  }else{
  delay(1000);
  digitalWrite(LED, LOW);
  }
}


5. Video Simulasi [Kembali]


6. Link Download [Kembali]

File HTML - Download

File Rangkaian Simulasi - Download

File Video Simulasi - Download

File Program :

- Master : Download

- Slave : Download





Tidak ada komentar:

Posting Komentar

BAHAN PRESENTASI UNTUK MATAKULIAH SISTEM DIGITAL 2021 OLEH: Elfiwani Juliaranti 1910952006 Dosen Pengampu: Dr. ...

Cari Blog Ini