//defining name and value of the pins
#define LED 3 //inisialisasi lampu 1 di pin 3
#define LED_2 6 //inisialisasi lampu 2 di pin 6
#define LED_3 5 //inisialisasi lampu 3 di pin 5
#define POT A0 //inisialisasi potentiometer 1 di pin A0
#define POT_2 A2 //inisialisasi potentiometer 2 di pin A2
#define POT_3 A3 //inisialisasi potentiometer 3 di pin A3
//declaring variable with integer
int NILAI = 0; //nilai potentio 1
int NILAI_2 = 0; //nilai potentio 2
int NILAI_3 = 0; //nilai potentio 3
void setup() {
//declaring pins status
Serial.begin(9600); //memulai komunikasi dengan serial rate 9600
pinMode(LED, OUTPUT); //mendeklarasikan lampu 1 sebagai keluaran
pinMode(LED_2, OUTPUT); //mendeklarasikan lampu 2 sebagai keluaran
pinMode(LED_3, OUTPUT); //mendeklarasikan lampu 3 sebagai keluaran
}
void loop() {
//repeated function
//calling variables that has been declared above
NILAI = analogRead(POT); //reading the input which potentio 1
analogWrite(LED, NILAI/4); //writing the output which led and divide into 4
NILAI_2 = analogRead(POT_2); //reading the input which potentio 1
analogWrite(LED_2, NILAI_2/4); //writing the output which led_2 and divide into 4
NILAI_3 = analogRead(POT_3); //reading the input which potentio 1
analogWrite(LED_3, NILAI_3/4); //writing the output which led_3 and divide into 4
Serial.print("Data 1:"); //printing string to give some information
Serial.println(NILAI); //printing value of potentio 1
Serial.print("Data 2:"); //printing string to give some information
Serial.println(NILAI_2); //printing value of potentio 2
Serial.print("Data 3:"); //printing string to give some information
Serial.println(NILAI_3); //printing value of potentio 3
Serial.println(); //printing space
delay(500); //delaying program for 500ms
}