#include <LiquidCrystal_I2C.h>
#include <Wire.h>
#define pinLed1 12
#define pinLed2 11
#define pinLed3 10
#define pinLed4 9
#define pinButton1 8
#define pinButton2 7
#define pinClock 6
#define pinData 5
#define pinLatch 4
#define pinClockLed 3
#define pinDataLed 2
#define pinLatchLed 13
//Set alamat I2C dan ukuran LCD
LiquidCrystal_I2C lcd(0x27,16,2);
//variabel bilangan bulat
int dataPertama = 100;
int dataButton1 = 0;
int dataButton2 = 0;
int k1 = 0;
int k2 = 0;
int menu = 0;
uint8_t dataDummy = 0;
//variabel bilangan pecahan
float dataKedua = 100.7;
//variabel array
uint8_t arraySegment[10] = {
0b00000011, //0
0b10011111, //1
0b00100101 //2
};
void setup(){
pinMode(pinLed1, OUTPUT);
pinMode(pinLed2, OUTPUT);
pinMode(pinLed3, OUTPUT);
pinMode(pinLed4, OUTPUT);
pinMode(pinButton1, INPUT);
pinMode(pinButton2, INPUT);
pinMode(pinClock, OUTPUT);
pinMode(pinData, OUTPUT);
pinMode(pinLatch, OUTPUT);
pinMode(pinClockLed, OUTPUT);
pinMode(pinDataLed, OUTPUT);
pinMode(pinLatchLed, OUTPUT);
Serial.begin(9600);
lcd.init();
lcd.backlight();
lcd.clear();
lcd.setCursor(0,0);
lcd.print("Welcome");
lcd.setCursor(0,1);
lcd.print("Hello World");
delay(2000);
lcd.clear();
// for(uint8_t i=0; i<8; i++){
// dataDummy = ((0b10000001>>i)&1);
// }
}
void loop(){
//biner 0b1001
//hexadecimal 0xA1
// dataDummy = 0b10000001 << 3;//00001000
// lcd.setCursor(0,0);
// lcd.print(dataDummy);
for(uint8_t i=0; i<8; i++){
//data
digitalWrite(pinData, (arraySegment[0]>>i)&1);
//clock
digitalWrite(pinClock, 0);
digitalWrite(pinClock, 1);
}
//latch
digitalWrite(pinLatch, 0);
digitalWrite(pinLatch, 1);
//abcdefgh
//00100101
shiftRegLed();
}
void shiftRegLed(){
for(uint8_t i=0; i<8; i++){
digitalWrite(pinDataLed, (0b10001001>>i)&1);
digitalWrite(pinClockLed, 0);
digitalWrite(pinClockLed, 1);
};
digitalWrite(pinLatchLed, 0);
digitalWrite(pinLatchLed, 1);
}