Tugas Arduino
Tugas Arduino
pinMode(13, OUTPUT);
void loop()
digitalWrite(13, HIGH);
digitalWrite(13, LOW);
}
void setup()
pinMode(13, OUTPUT);
void loop()
digitalWrite(13, HIGH);
digitalWrite(13, LOW);
}
#define LED 13
#define BUTTON 2
int val = 0;
void setup() {
pinMode(LED, OUTPUT);
pinMode(BUTTON, INPUT);
void loop(){
val = digitalRead(BUTTON);
if (val == HIGH) {
} else {
digitalWrite(LED, LOW);
}
int LED = 13;
int value;
void setup(){
pinMode(LED, OUTPUT);
pinMode(POT, INPUT);
void loop(){
value = analogRead(POT);
analogWrite(LED, value);
delay(100);
}
#define LED 9
int i = 0;
void setup() {
pinMode(LED, OUTPUT);
void loop(){
analogWrite(LED, i);
delay(5);
analogWrite(LED, i);
delay(5);
}
void setup()
pinMode(13, OUTPUT);
void loop()
digitalWrite(2, HIGH);
digitalWrite(2, LOW);
digitalWrite(3, HIGH);
digitalWrite(3, LOW);
digitalWrite(4, HIGH);
digitalWrite(4, LOW);
digitalWrite(5, HIGH);
delay(500); // Wait for 1000 millisecond(s)
digitalWrite(5, LOW);
digitalWrite(6, HIGH);
digitalWrite(6, LOW);
digitalWrite(7, HIGH);
digitalWrite(7, LOW);
}
const int analogPin = A0;
int ledPins[] = {
2, 3, 4, 5, 6, 7, 8, 9, 10, 11
};
void setup() {
pinMode(ledPins[thisLed], OUTPUT);
void loop() {
digitalWrite(ledPins[thisLed], HIGH);
}
else {
digitalWrite(ledPins[thisLed], LOW);
}
int ledPins[] = {2,3,4,5,6,7,8,9};
// We're using the values in this array to specify the pin numbers
void setup()
{
int index;
// each step. For() loops are a very handy way to get numbers to
// count up or down.
// semicolons (;):
// Here we'll use a for() loop to initialize all the LED pins
// This for() loop will make index = 0, then run the pinMode()
pinMode(ledPins[index],OUTPUT);
void loop()
// the "//" in front of the ones you'd like to run, and add "//"
// in front of those you don't to comment out (and disable) those
// lines.
/*
oneAfterAnotherNoLoop()
This function will light one LED, delay for delayTime, then light
the next LED, and repeat until all the LEDs are on. It will then
This function does NOT use a for() loop. We've done it the hard way
to show you how much easier life can be when you use for() loops.
*/
void oneAfterAnotherNoLoop()
{