int tombol30= 13;
int tombol60= 12;
int tombol90= 11;
int tombol120= 10;
int tombol150= 9;
int tombol180= 8;
int nilai;
#include <Servo.h>
const int PIN_SERVO = 3;
Servo motorServo;
#include <Wire.h>
#include <LiquidCrystal_I2C.h>
LiquidCrystal_I2C lcd(0x27, 16, 2);
void setup(){
lcd.init();
lcd.backlight();
motorServo.attach(PIN_SERVO);
pinMode(tombol30, INPUT);
pinMode(tombol60, INPUT);
pinMode(tombol90, INPUT);
pinMode(tombol120, INPUT);
pinMode(tombol150, INPUT);
pinMode(tombol180, INPUT);
}
void loop(){
derajat30();
derajat60();
derajat90();
derajat120();
derajat150();
derajat180();
}
void derajat30(){
nilai= digitalRead(tombol30);
if(nilai == 1){
lcd.clear();
lcd.setCursor(0,0);
lcd.print("30 Derajat");
motorServo.write(30);
}
}
void derajat60(){
nilai= digitalRead(tombol60);
if(nilai == 1){
lcd.clear();
lcd.setCursor(0,0);
lcd.print("60 Derajat");
motorServo.write(60);
}
}
void derajat90(){
nilai= digitalRead(tombol90);
if(nilai == 1){
lcd.clear();
lcd.setCursor(0,0);
lcd.print("90 Derajat");
motorServo.write(90);
}
}
void derajat120(){
nilai= digitalRead(tombol120);
if(nilai == 1){
lcd.clear();
lcd.setCursor(0,0);
lcd.print("120 Derajat");
motorServo.write(120);
}
}
void derajat150(){
nilai= digitalRead(tombol150);
if(nilai == 1){
lcd.clear();
lcd.setCursor(0,0);
lcd.print("150 Derajat");
motorServo.write(150);
}
}
void derajat180(){
nilai= digitalRead(tombol180);
if(nilai == 1){
lcd.clear();
lcd.setCursor(0,0);
lcd.print("180 Derajat");
motorServo.write(180);
}
}