- Kemudian tuliskan program dibawah ini pada halaman kosong software arduino seperti dibawah ini:
Listing Program:
void setup()
{
pinMode(kirimaju_pin, OUTPUT); // sets the pin as output
pinMode(kirimundur_pin, OUTPUT); // sets the pin as output
pinMode(kananmaju_pin, OUTPUT); // sets the pin as output
pinMode(kananmundur_pin, OUTPUT); // sets the pin as output
}
void loop()
{
val = analogRead(analogPin); // read the input pin
analogWrite(ledPin, val / 4); // analogRead values go from 0 to 1023, analogWrite values from 0 to 255
delay (500);
analogWrite(kananmaju_pin, 10); // analogRead values go from 0 to 1023, analogWrite values from 0 to 255
analogWrite(kananmundur_pin, 255); // analogRead values go from 0 to 1023, analogWrite values from 0 to 255
analogWrite(kirimaju_pin, 10); // analogRead values go from 0 to 1023, analogWrite values from 0 to 255
analogWrite(kirimundur_pin, 255); // analogRead values go from 0 to 1023, analogWrite values from 0 to 255
delay (500);
analogWrite(kananmaju_pin, 255); // analogRead values go from 0 to 1023, analogWrite values from 0 to 255
analogWrite(kananmundur_pin, 255); // analogRead values go from 0 to 1023, analogWrite values from 0 to 255
analogWrite(kirimaju_pin, 255); // analogRead values go from 0 to 1023, analogWrite values from 0 to 255
analogWrite(kirimundur_pin, 255); // analogRead values go from 0 to 1023, analogWrite values from 0 to 255
delay (500);
analogWrite(kananmaju_pin, 255); // analogRead values go from 0 to 1023, analogWrite values from 0 to 255
analogWrite(kananmundur_pin, 10); // analogRead values go from 0 to 1023, analogWrite values from 0 to 255
analogWrite(kirimaju_pin, 255); // analogRead values go from 0 to 1023, analogWrite values from 0 to 255
analogWrite(kirimundur_pin, 10); // analogRead values go from 0 to 1023, analogWrite values from 0 to 255
delay (500);
analogWrite(kananmaju_pin, 255); // analogRead values go from 0 to 1023, analogWrite values from 0 to 255
analogWrite(kananmundur_pin, 255); // analogRead values go from 0 to 1023, analogWrite values from 0 to 255
analogWrite(kirimaju_pin, 255); // analogRead values go from 0 to 1023, analogWrite values from 0 to 255
analogWrite(kirimundur_pin, 255); // analogRead values go from 0 to 1023, analogWrite values from 0 to 255
delay (500);
}
comment 0 komentar
more_vert