Modul Praktik 1 Robotika SMA Marsudirini Bekasi: 1. Mengenal LED

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 5

Modul Praktik 1

Robotika SMA Marsudirini Bekasi

1. Mengenal LED

int led1= 2;
void setup(){

pinMode(led1, OUTPUT);

digitalWrite(led1, HIGH);

void loop(){

}
2. LED Paralel

int led1= 2;
void setup(){

pinMode(led1, OUTPUT);

digitalWrite(led1, HIGH);

void loop(){

3. LED dengan Algoritma


int led1= 2, led2=3, led3=4;

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

digitalWrite(led1, LOW);
digitalWrite(led2, LOW);
digitalWrite(led3, LOW);
}

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

4. Resistor
5. Mengenal Button

int led1= 2;
void setup(){

pinMode(led1, OUTPUT);

digitalWrite(led1, HIGH);

void loop(){

}
6. Button Dengan Algoritma
// C++ code
//
/*
Button
Turns on and off a light emitting diode(LED)
connected to digital pin 13, when pressing a
pushbutton attached to pin 2.

The circuit:
* LED attached from pin 13 to ground
* pushbutton attached to pin 2 from +5V
* 10K resistor attached to pin 2 from ground
* Note: on most Arduinos there is already an LED
on the board attached to pin 13.

created 2005 by DojoDave <http://www.0j0.org>

modified 30 Aug 2011 by Tom Igoe

This example code is in the public domain.


http://www.arduino.cc/en/Tutorial/Button
*/

int buttonState = 0;

void setup()
{
Serial.begin(9600);
pinMode(2, INPUT);

void loop()
{
// read the state of the pushbutton value
buttonState = digitalRead(2);

if (buttonState == HIGH) {
Serial.println("ON");

} else {
Serial.println("OFF");

}
delay(10); // Delay a little bit to improve simulation performance
}

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy