tugas pendahuluan (modul 3)







1. Kondisi [kembali]
Ganti potensiometer dengan push button, ketika push button ditekan maka led padam. Ketika push button dilepas led menyala.

2. Rangkaian Simulasi [kembali]



3. Flowchart [kembali]
MASTER

SLAVE


4. Listing Program [kembali]
MASTER
#include <Wire.h>
#define SLAVE_ADDR 9

int butt=12;
int val = 0;

void setup() {
  pinMode(butt, INPUT);
  Wire.begin();

}

void loop() {
  delay(50);
  val=digitalRead(butt);
  Wire.beginTransmission(SLAVE_ADDR);
  Wire.write(val);
  Wire.endTransmission();
  // put your main code here, to run repeatedly:

}

SLAVE
#include <Wire.h>
#define SLAVE_ADDR 9

int LED = 13;
int rd;

void setup() {
  pinMode(LED, OUTPUT);
  Wire.begin(SLAVE_ADDR);
  Wire.onReceive(receiveEvent);
  Serial.begin(9600);
  Serial.println("I2C Slave demo");
  digitalWrite(LED,HIGH);
 
}

void receiveEvent() {
  rd = Wire.read();
  Serial.println(rd);

}

void loop() {
  if(rd==0){
    digitalWrite(LED,LOW);
    delay(100);
  }
  else{
    digitalWrite(LED,HIGH);
    delay(100);
  }
} 
5. Video [kembali]


6. Link Download [kembali]

1. File HTML
    Download File
2. Video
    Download File
3. File rangkaian simulasi
    Download File

Tidak ada komentar:

Posting Komentar