Bahan Presentasi untuk Praktikum Mikroprosesor dan Mikrokontroller 2019.
TUGAS PENDAHULUAN MODUL 3
1. Kondisi[kembali]
Ganti potensiometer denĀan push button dan led denĀan motor DC. Jika push button ditekan maka motor berputar berlawanan jarum jam. Dan jika push button dilepas maka motor berputar searah jarum jam.
2. Rangkaian Simulasi[kembali]
3. Flowchart[kembali]
1. Master
2. Slave
4. Listing Program[kembali]
MASTER
#include <Wire.h>
#define SLAVE_ADDR 9
int analogPin = 0;
int bt;
void setup() {
Wire.begin();
digitalWrite(analogPin,HIGH);
}
void loop() {
delay(50);
bt = digitalRead(analogPin);
Wire.beginTransmission(SLAVE_ADDR);
Wire.write(bt);
Wire.endTransmission();
}
FOR SLAVE
#include <Wire.h>
#define SLAVE_ADDR 9
int in1= 13;
int in2= 12;
int rd;
int br;
void setup() {
pinMode(in1, OUTPUT);
pinMode(in2, OUTPUT);
Wire.begin(SLAVE_ADDR);
Wire.onReceive(receiveEvent);
Serial.begin(9600);
Serial.println("I2C Slave demo");
}
void receiveEvent(int) {
rd = Wire.read();
Serial.println(rd); }
void loop() {
delay(50);
if ( rd == HIGH)
{
digitalWrite(in1,HIGH);
digitalWrite(in2,LOW);
delay(100);
}
if(rd == LOW)
{
digitalWrite(in1,LOW);
digitalWrite(in2,HIGH);
delay(100);
}
}
5. Video [kembali]
Download listing program di sini
Download file rangkaian di sini
Download video simulasi di sini
Download file html di sini
Subscribe to:
Posts (Atom)
No comments:
Post a Comment