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

Codding Adruino

The document contains code for 3 Arduino projects: 1) Blinking 3 LED lights on and off with a 1 second delay between states. 2) A LED light that turns on when a button is pressed and off when released. 3) A speaker that plays a short musical tune by generating tones at different frequencies with a half second delay between each note.

Uploaded by

Puji Surya
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)
28 views

Codding Adruino

The document contains code for 3 Arduino projects: 1) Blinking 3 LED lights on and off with a 1 second delay between states. 2) A LED light that turns on when a button is pressed and off when released. 3) A speaker that plays a short musical tune by generating tones at different frequencies with a half second delay between each note.

Uploaded by

Puji Surya
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/ 2

TIGA LAMPU MENYALA

byte led1= 9;
byte led2= 8;
byte led3= 7;

void setup(){
pinMode(led1, OUTPUT);
pinMode(led2, OUTPUT);
pinMode(led3, OUTPUT);
}

void loop(){
digitalWrite(led1, HIGH);
digitalWrite(led2, HIGH);
digitalWrite(led3, HIGH);
delay(1000);
digitalWrite(led1, LOW);
digitalWrite(led2, LOW);
digitalWrite(led3, LOW);
delay(1000);
}

LAMPU DENGAN TOMBOL

byte tombol= 2;
byte led= 13;
int nilai;

void setup(){
pinMode(led, OUTPUT);
pinMode(tombol, INPUT);
}

void loop(){
nilai= digitalRead(tombol);

if(nilai == 1){
digitalWrite(led, HIGH);
}
else{
digitalWrite(led, LOW);
}
}
SPEAKER
byte speaker= 9;

void setup(){

void loop(){
tone(speaker, 262); delay(500);
tone(speaker, 294); delay(500);
tone(speaker, 330); delay(500);
tone(speaker, 349); delay(500);
tone(speaker, 395); delay(500);
tone(speaker, 440); delay(500);
tone(speaker, 494); delay(500);
tone(speaker, 523); delay(500);
}

You might also like