1. Kondisi [Kembali]
Kondisi yang digunakan pada Tugas Pendahuluan ini adalah Percobaan 3 nomor 2 yaitu membuat led berkedip dengan frekuensi berbanding lurus dengan nilai potensiometer.
2. Hardware [Kembali]
3. Rangkaian Simulasi [Kembali]
4. Flowchart [Kembali]
5. Video Simulasi
[[Kembali]
6. Listing Program [Kembali]
7. Link Download [Kembali]
Download file video simulasi rangkaian disini
Download Html disini
3. Rangkaian Simulasi [Kembali]
4. Flowchart [Kembali]
6. Listing Program [Kembali]
- 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();
}
- 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);
}
}
Download file video simulasi rangkaian disini
Download Html disini
No comments:
Post a Comment