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

Listing Program Pada Arduino

The document describes an Arduino program that controls 6 LEDs (on pins 8-13) using serial input characters. The program initializes the pins as outputs and sets them low, then enters a loop checking for serial input. If it receives the characters A-F, it will turn the corresponding LED on. Characters O-T will turn them off, while X turns all on and Y turns all off.

Uploaded by

Adef Priyambodo
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as RTF, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
41 views

Listing Program Pada Arduino

The document describes an Arduino program that controls 6 LEDs (on pins 8-13) using serial input characters. The program initializes the pins as outputs and sets them low, then enters a loop checking for serial input. If it receives the characters A-F, it will turn the corresponding LED on. Characters O-T will turn them off, while X turns all on and Y turns all off.

Uploaded by

Adef Priyambodo
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as RTF, PDF, TXT or read online on Scribd
You are on page 1/ 4

Modul 1 Led

Listing Program Pada Arduino

int x=0;

void setup() {

Serial.begin(9600);

pinMode (8, OUTPUT);

pinMode (9, OUTPUT);

pinMode (10, OUTPUT);

pinMode (11, OUTPUT);

pinMode (12, OUTPUT);

pinMode (13, OUTPUT);

digitalWrite(8, LOW);

digitalWrite(9, LOW);

digitalWrite(10, LOW);
digitalWrite(11, LOW);

digitalWrite(12, LOW);

digitalWrite(13, LOW);

void loop()

if (Serial.available()>0)

x=Serial.read();

if (x=='A')

digitalWrite(13, HIGH);

if(x=='B')

digitalWrite(12, HIGH);

if(x=='C')

digitalWrite(11, HIGH);

if(x=='D')

digitalWrite(10, HIGH);
}

if(x=='E')

digitalWrite(9, HIGH);

if(x=='F')

digitalWrite(8, HIGH);

if(x=='O')

digitalWrite(13, LOW);

if(x=='P')

digitalWrite(12, LOW);

if(x=='Q')

digitalWrite(11, LOW);

if(x=='R')

digitalWrite(10, LOW);

if(x=='S')

{
digitalWrite(9, LOW);

if(x=='T')

digitalWrite(8, LOW);

if(x=='X')

digitalWrite(8, HIGH);

digitalWrite(9, HIGH);

digitalWrite(10, HIGH);

digitalWrite(11, HIGH);

digitalWrite(12, HIGH);

digitalWrite(13, HIGH);

if (x=='Y')

digitalWrite(8, LOW);

digitalWrite(9, LOW);

digitalWrite(10, LOW);

digitalWrite(11, LOW);

digitalWrite(12, LOW);

digitalWrite(13, LOW);

delay(300); }

You might also like