int led1 = 2;
int led2 = 3;
int led3 = 4;
int led4 = 5;
int sw = 8;
void setup() {
// put your setup code here, to run once:
pinMode(led1, OUTPUT);
pinMode(led2, OUTPUT);
pinMode(led3, OUTPUT);
pinMode(led4, OUTPUT);
pinMode(sw, INPUT);
}
void loop() {
// put your main code here, to run repeatedly:
int swInput = digitalRead(sw);
if (swInput == HIGH){
ledOutput(HIGH,HIGH,HIGH,HIGH);
} else {
ledOutput(LOW,LOW,LOW,LOW);
}
}
void ledOutput (int ledVal1, int ledVal2, int ledVal3, int ledVal4) {
digitalWrite (led1,ledVal1);
digitalWrite (led2,ledVal2);
digitalWrite (led3,ledVal3);
digitalWrite (led4,ledVal4);
}
Dept.of Engineering Education (Electronic Engineering) @King Mongkut's Ladkrabang (KMITL), BKK Thailand Advanced Flight Student (FS3) in International Virtual Aviation Organisation™ (IVAO)
Thursday, September 25, 2014
Arduino 25 Sep
int led1 = 2;
int led2 = 3;
int led3 = 4;
int led4 = 5;
int sw = 8;
void setup() {
// put your setup code here, to run once:
pinMode(led1, OUTPUT);
pinMode(led2, OUTPUT);
pinMode(led3, OUTPUT);
pinMode(led4, OUTPUT);
pinMode(sw, INPUT);
}
void loop() {
// put your main code here, to run repeatedly:
ledOutput(LOW,HIGH,HIGH,LOW);
delay(500);
ledOutput(HIGH,LOW,LOW,HIGH);
delay(500);
}
void ledOutput (int ledVal1, int ledVal2, int ledVal3, int ledVal4) {
digitalWrite (led1,ledVal1);
digitalWrite (led2,ledVal2);
digitalWrite (led3,ledVal3);
digitalWrite (led4,ledVal4);
}
int led2 = 3;
int led3 = 4;
int led4 = 5;
int sw = 8;
void setup() {
// put your setup code here, to run once:
pinMode(led1, OUTPUT);
pinMode(led2, OUTPUT);
pinMode(led3, OUTPUT);
pinMode(led4, OUTPUT);
pinMode(sw, INPUT);
}
void loop() {
// put your main code here, to run repeatedly:
ledOutput(LOW,HIGH,HIGH,LOW);
delay(500);
ledOutput(HIGH,LOW,LOW,HIGH);
delay(500);
}
void ledOutput (int ledVal1, int ledVal2, int ledVal3, int ledVal4) {
digitalWrite (led1,ledVal1);
digitalWrite (led2,ledVal2);
digitalWrite (led3,ledVal3);
digitalWrite (led4,ledVal4);
}
Thursday, September 11, 2014
Arduino Code
int ledPin = 13;
int swPin = 8;
boolean X0 = LOW;
boolean X1 = HIGH;
boolean flagg = LOW;
void setup() {
// put your setup code here, to run once:
pinMode(ledPin, OUTPUT);
pinMode(swPin, INPUT);
}
void loop() {
// put your main code here, to run repeatedly:
X1=digitalRead(swPin);
if ((X0 == LOW) && (X1==HIGH)) {
flagg = !flagg;
}
X0=X1;
digitalWrite(ledPin, flagg);
}
int swPin = 8;
boolean X0 = LOW;
boolean X1 = HIGH;
boolean flagg = LOW;
void setup() {
// put your setup code here, to run once:
pinMode(ledPin, OUTPUT);
pinMode(swPin, INPUT);
}
void loop() {
// put your main code here, to run repeatedly:
X1=digitalRead(swPin);
if ((X0 == LOW) && (X1==HIGH)) {
flagg = !flagg;
}
X0=X1;
digitalWrite(ledPin, flagg);
}
Wednesday, August 20, 2014
Monday, August 18, 2014
Monday, August 04, 2014
Subscribe to:
Posts (Atom)



