0% found this document useful (0 votes)
65 views

"Simulasi Motor": Program

This document summarizes a program to control motor direction using switches and adjust motor speed based on temperature. The program uses switches connected to pins 8, 9 and 10 to control the direction of a motor connected to pins 13, 12 and 11. When switch 1 is pressed, the motor turns on in one direction. When switch 2 is pressed, the motor turns in the opposite direction. Switch 3 turns the motor off. The program also measures temperature using a sensor and adjusts the motor speed based on the temperature reading. The motor speed increases as temperature increases.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
65 views

"Simulasi Motor": Program

This document summarizes a program to control motor direction using switches and adjust motor speed based on temperature. The program uses switches connected to pins 8, 9 and 10 to control the direction of a motor connected to pins 13, 12 and 11. When switch 1 is pressed, the motor turns on in one direction. When switch 2 is pressed, the motor turns in the opposite direction. Switch 3 turns the motor off. The program also measures temperature using a sensor and adjusts the motor speed based on the temperature reading. The motor speed increases as temperature increases.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 5

PROGRAM

“SIMULASI MOTOR”

DISUSUN OLEH :
TATMAINNAH AINUN HAQ. MH
17.054

POLITEKNIK KESEHATAN MUHAMMADIYAH MAKASSAR


PRODI TEKNOLOGI ELEKTROMEDIS
A N G K A T A N XXI
TAHUN AKADEMIK 2018-2019
A. Mengatur Arah Motor dengan Tombol Switch

R1
10k

SW1

16 8 U1
2 3
R2 7
IN1 VSS VS OUT1
6
IN2 OUT2
1
10k EN1
SW2
9
EN2
10 11
IN3 OUT3
15 14
IN4 GND GND OUT4

L293D

R3
10k

13
12

10
11

9
8

7
6
5
4
3
2
1
0
DUINO1
PB4/MISO

PB0/ICP1/CLKO
AREF

TX PD1/TXD
RX PD0/RXD
PD7/AIN1
~ PD6/AIN0
PD5/T1

~ PD3/INT1
PD2/INT0
PB5/SCK

~PB3/MOSI/OC2A
~ PB2/SS/OC1B
~ PB1/OC1A

PD4/T0/XCK
ARDUINO UNO R3

~
DIGITAL (~PWM)

ATMEGA328P-PU
1121

microcontrolandos.blogspot.com
PC4/ADC4/SDA
PC5/ADC5/SCL

ANALOG IN
PC0/ADC0
PC1/ADC1
PC2/ADC2
PC3/ADC3

+138
RESET

A0
A1
A2
A3
A4
A5

PROGRAM :
const int PBF=8;
const int PBS=9;
const int PBT=10;
int buttonState=0;

void setup() {
pinMode(PBF,INPUT);
pinMode(PBS,INPUT);
pinMode(PBT,INPUT);
pinMode(13,OUTPUT);
pinMode(12,OUTPUT);
pinMode(11,OUTPUT);

void loop() {
buttonState = digitalRead(PBF);
if (buttonState == HIGH){
digitalWrite (13,HIGH);
digitalWrite(12,LOW);

analogWrite(11,255);
}
{
buttonState = digitalRead(PBS);
if (buttonState == HIGH){
digitalWrite (13,LOW);
digitalWrite(12,HIGH);
analogWrite(11,255);
}
{
buttonState = digitalRead(PBT);
if (buttonState == HIGH){
digitalWrite (13,LOW);
digitalWrite(12,LOW);

}
}
}
}
B. Putaran Arah Motor Berdasarkan Suhu
LCD1
LM016L

VDD
VSS

VEE

RW
RS

D0
D1
D2
D3
D4
D5
D6
D7
E
1
2
3

4
5
6

7
8
9
10
11
12
13
14
16 8 U1
2 3
IN1 VSS VS OUT1
7 6
IN2 OUT2
1
EN1

9
EN2
10 11
IN3 OUT3
15 14
IN4 GND GND OUT4

L293D

13
12

10
11

9
8

7
6
5
4
3
2
1
0
DUINO1
PB4/MISO

PB0/ICP1/CLKO
AREF

TX PD1/TXD
RX PD0/RXD
PD7/AIN1
~ PD6/AIN0
PD5/T1

~ PD3/INT1
PD2/INT0
PB5/SCK

~PB3/MOSI/OC2A
~ PB2/SS/OC1B
~ PB1/OC1A

PD4/T0/XCK
ARDUINO UNO R3

~
DIGITAL (~PWM)

ATMEGA328P-PU
1121

microcontrolandos.blogspot.com
PC4/ADC4/SDA
PC5/ADC5/SCL
ANALOG IN
1 U2
PC0/ADC0
PC1/ADC1
PC2/ADC2
PC3/ADC3

-192
RESET

47.0
A0
A1
A2
A3
A4
A5

2
VOUT

3 LM35

PROGRAM :
#include <LiquidCrystal.h>;
LiquidCrystal lcd (7,6,5,4,3,2);

int potPin=0;
long val = 0;
float temperature=0;

void setup() {
pinMode(13,OUTPUT);
pinMode(12,OUTPUT);
pinMode(11,OUTPUT);
lcd.begin(16,2);

void loop() {
val = analogRead(potPin);
temperature = ((5.0*val*100.01)/1024.0);
lcd.setCursor (0,0);
lcd.print ("TEMP:");
lcd.setCursor (4,1);
lcd.print ((long)temperature);
lcd.print ("deg.C");
delay(1000);
if (temperature > 50)
{
digitalWrite (13,LOW);
digitalWrite(12,HIGH);

analogWrite(11,255);
}
else if (temperature <= 50)
{
digitalWrite (13,HIGH);
digitalWrite(12,LOW);

analogWrite(11,255);
}

You might also like