Tugas Pendahuluan Modul 3





1. Kondisi [Kembali]  

Pada praktikum modul 3 ini. Dipilih percobaan 3 dengan kondisi 1. Pada kondisi 1, Membuat rangkaian LED menyala ketika potensiometer 0% dan LED padam ketika potensiometer 100%.

2. Rangkaian Simulasi [Kembali] 

LED menyala ketika potensiometer 0%
 
LED padam ketika potensiometer 100%
 

3. Flowchart [Kembali]  

MASTER
 

 
SLAVE
 
 

4. listing program [Kembali]   

a. Master


#include <Wire.h>

#define SLAVE_ADDR 9
int analogPin = 0;
int val = 0;
void setup() {
Wire.begin();
Serial.begin(9600);
}
void loop() {
delay(50);
val = map(analogRead(analogPin), 0, 1023, 255, 1);
Wire.beginTransmission(SLAVE_ADDR);
Wire.write(val);
Serial.println(val);
Serial.println(analogRead(analogPin));
Wire.endTransmission();
}

b. 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);
Serial.begin(9600);
Serial.println("I2C Slave demo");
}
void receiveEvent() {
rd = Wire.read();
Serial.println(rd);
}
void loop() {
delay(50);
br = map(rd, 1, 255, 100, 2000);
if (rd == 255){
  digitalWrite(LED, HIGH);
}
if (rd == 1){
  digitalWrite(LED, LOW);
}
}

5. Video Simulasi [Kembali]  


 

6. Link Download [Kembali]

File Library Arduino = Klik Disini

File Data Sheet Arduino = Klik Disini 

File Video Simulasi =  Klik Disini

File Rangkaian = Klik Disini

File Listing Program Master = Klik Disini

File Listing Program clave = Klik Disini

File Flowchart Master = Klik Disini

File Flowchart Clave = Klik Disini

File Html = Klik Disini

Tidak ada komentar:

Posting Komentar