Arduino Video Lab
DuinoLab Starter Kit #2 : LED
Program :
const int LED_PIN = 13;
const int WAKTU_KEDIP = 200; // milisecond
void setup() {
pinMode( LED_PIN, OUTPUT );
}
void loop() {
digitalWrite( LED_PIN, HIGH );
delay( WAKTU_KEDIP );
digitalWrite( LED_PIN, LOW );
delay( WAKTU_KEDIP );
}
DuinoLab Starter Kit #4 : Analog IO w - Potensiometer
Program :
const int POT_PIN = A0;
const int LED_PIN = 11;
void setup() {
pinMode( POT_PIN, INPUT );
pinMode( LED_PIN, OUTPUT );
}
void loop() {
int val = analogRead( POT_PIN ); // {0,1023}
val = map( val, 0, 1023, 0 , 255 );
analogWrite( LED_PIN, val );
}
Langganan:
Postingan (Atom)