Dept.of Engineering Education (Electronic Engineering) @King Mongkut's Ladkrabang (KMITL), BKK Thailand Advanced Flight Student (FS3) in International Virtual Aviation Organisation™ (IVAO)
Monday, September 29, 2014
CISCO
http://heiserz.com/?s=ENetwork+Chapter+2+CCNA+1
Thursday, September 25, 2014
Add LedRow = 0; in void loop()
int led1 = 2;
int led2 = 3;
int led3 = 4;
int led4 = 5;
int sw = 8;
boolean sw000 = HIGH;
int ledStatus = 0;
int ledStep1[4][4] = { 1,0,0,0,
0,1,0,0,
0,0,1,0,
0,0,0,1};
int ledStep2[4][4] = { 0,0,0,1,
0,0,1,0,
0,1,0,0,
1,0,0,0};
int ledStep3[4][4] = { 0,1,0,1,
1,0,1,0,
1,1,0,0,
0,0,1,1};
// แถวที่จะอ่านจาก ledStep
int ledRow = 0;
int delayCount = 0;
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 = debounceSwitch(sw, sw000);
if((swInput == HIGH) && (sw000 == LOW)) {
//กำหนดสถานะ led
ledStatus = ledStatus +1;
if (ledStatus > 3)ledStatus = 0;
ledRow = 0;
}
sw000 = swInput; //เก็บสถานะปัจจุบัน
int ledTemp1,ledTemp2,ledTemp3,ledTemp4;
if (ledStatus == 0){
ledTemp1 = LOW;
ledTemp2 = LOW;
ledTemp3 = LOW;
ledTemp4 = LOW;
// ledOutput(LOW,LOW,LOW,LOW);
} else if (ledStatus == 1){
ledTemp1 = ledStep1[ledRow][0];
ledTemp2 = ledStep1[ledRow][1];
ledTemp3 = ledStep1[ledRow][2];
ledTemp4 = ledStep1[ledRow][3];
// ledOutput(LOW,LOW,LOW,HIGH);
} else if (ledStatus == 2) {
ledTemp1 = ledStep2[ledRow][0];
ledTemp2 = ledStep2[ledRow][1];
ledTemp3 = ledStep2[ledRow][2];
ledTemp4 = ledStep2[ledRow][3];
// ledOutput(LOW,LOW,HIGH,HIGH);
//} else if (ledStatus == 3) {
// ledOutput(LOW,HIGH,HIGH,HIGH);
} else {
ledTemp1 = ledStep3[ledRow][0];
ledTemp2 = ledStep3[ledRow][1];
ledTemp3 = ledStep3[ledRow][2];
ledTemp4 = ledStep3[ledRow][3];
// ledOutput(HIGH,HIGH,HIGH,HIGH);
}
ledOutput(ledTemp1,ledTemp2,ledTemp3,ledTemp4);
delayCount = delayCount +1;
if (delayCount > 1500) {
delayCount = 0;
ledRow = ledRow +1;
if (ledRow > 3) ledRow = 0;
}
//delay(100);
}
void ledOutput (int ledVal1, int ledVal2, int ledVal3, int ledVal4) {
digitalWrite (led1,ledVal1);
digitalWrite (led2,ledVal2);
digitalWrite (led3,ledVal3);
digitalWrite (led4,ledVal4);
}
boolean debounceSwitch(int swPin, boolean LastLogic) {
boolean currentLogic = digitalRead (swPin);
if (currentLogic != LastLogic) {
delay(2);
currentLogic = digitalRead(swPin);
}
return currentLogic;
}
int led2 = 3;
int led3 = 4;
int led4 = 5;
int sw = 8;
boolean sw000 = HIGH;
int ledStatus = 0;
int ledStep1[4][4] = { 1,0,0,0,
0,1,0,0,
0,0,1,0,
0,0,0,1};
int ledStep2[4][4] = { 0,0,0,1,
0,0,1,0,
0,1,0,0,
1,0,0,0};
int ledStep3[4][4] = { 0,1,0,1,
1,0,1,0,
1,1,0,0,
0,0,1,1};
// แถวที่จะอ่านจาก ledStep
int ledRow = 0;
int delayCount = 0;
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 = debounceSwitch(sw, sw000);
if((swInput == HIGH) && (sw000 == LOW)) {
//กำหนดสถานะ led
ledStatus = ledStatus +1;
if (ledStatus > 3)ledStatus = 0;
ledRow = 0;
}
sw000 = swInput; //เก็บสถานะปัจจุบัน
int ledTemp1,ledTemp2,ledTemp3,ledTemp4;
if (ledStatus == 0){
ledTemp1 = LOW;
ledTemp2 = LOW;
ledTemp3 = LOW;
ledTemp4 = LOW;
// ledOutput(LOW,LOW,LOW,LOW);
} else if (ledStatus == 1){
ledTemp1 = ledStep1[ledRow][0];
ledTemp2 = ledStep1[ledRow][1];
ledTemp3 = ledStep1[ledRow][2];
ledTemp4 = ledStep1[ledRow][3];
// ledOutput(LOW,LOW,LOW,HIGH);
} else if (ledStatus == 2) {
ledTemp1 = ledStep2[ledRow][0];
ledTemp2 = ledStep2[ledRow][1];
ledTemp3 = ledStep2[ledRow][2];
ledTemp4 = ledStep2[ledRow][3];
// ledOutput(LOW,LOW,HIGH,HIGH);
//} else if (ledStatus == 3) {
// ledOutput(LOW,HIGH,HIGH,HIGH);
} else {
ledTemp1 = ledStep3[ledRow][0];
ledTemp2 = ledStep3[ledRow][1];
ledTemp3 = ledStep3[ledRow][2];
ledTemp4 = ledStep3[ledRow][3];
// ledOutput(HIGH,HIGH,HIGH,HIGH);
}
ledOutput(ledTemp1,ledTemp2,ledTemp3,ledTemp4);
delayCount = delayCount +1;
if (delayCount > 1500) {
delayCount = 0;
ledRow = ledRow +1;
if (ledRow > 3) ledRow = 0;
}
//delay(100);
}
void ledOutput (int ledVal1, int ledVal2, int ledVal3, int ledVal4) {
digitalWrite (led1,ledVal1);
digitalWrite (led2,ledVal2);
digitalWrite (led3,ledVal3);
digitalWrite (led4,ledVal4);
}
boolean debounceSwitch(int swPin, boolean LastLogic) {
boolean currentLogic = digitalRead (swPin);
if (currentLogic != LastLogic) {
delay(2);
currentLogic = digitalRead(swPin);
}
return currentLogic;
}
Add LED count
int led1 = 2;
int led2 = 3;
int led3 = 4;
int led4 = 5;
int sw = 8;
boolean sw000 = HIGH;
int ledStatus = 0;
int ledStep1[4][4] = { 1,0,0,0,
0,1,0,0,
0,0,1,0,
0,0,0,1};
int ledStep2[4][4] = { 0,0,0,1,
0,0,1,0,
0,1,0,0,
1,0,0,0};
int ledStep3[4][4] = { 0,1,0,1,
1,0,1,0,
1,1,0,0,
0,0,1,1};
// แถวที่จะอ่านจาก ledStep
int ledRow = 0;
int delayCount = 0;
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 = debounceSwitch(sw, sw000);
if((swInput == HIGH) && (sw000 == LOW)) {
//กำหนดสถานะ led
ledStatus = ledStatus +1;
if (ledStatus > 3)ledStatus = 0;
}
sw000 = swInput; //เก็บสถานะปัจจุบัน
int ledTemp1,ledTemp2,ledTemp3,ledTemp4;
if (ledStatus == 0){
ledTemp1 = LOW;
ledTemp2 = LOW;
ledTemp3 = LOW;
ledTemp4 = LOW;
// ledOutput(LOW,LOW,LOW,LOW);
} else if (ledStatus == 1){
ledTemp1 = ledStep1[ledRow][0];
ledTemp2 = ledStep1[ledRow][1];
ledTemp3 = ledStep1[ledRow][2];
ledTemp4 = ledStep1[ledRow][3];
// ledOutput(LOW,LOW,LOW,HIGH);
} else if (ledStatus == 2) {
ledTemp1 = ledStep2[ledRow][0];
ledTemp2 = ledStep2[ledRow][1];
ledTemp3 = ledStep2[ledRow][2];
ledTemp4 = ledStep2[ledRow][3];
// ledOutput(LOW,LOW,HIGH,HIGH);
//} else if (ledStatus == 3) {
// ledOutput(LOW,HIGH,HIGH,HIGH);
} else {
ledTemp1 = ledStep3[ledRow][0];
ledTemp2 = ledStep3[ledRow][1];
ledTemp3 = ledStep3[ledRow][2];
ledTemp4 = ledStep3[ledRow][3];
// ledOutput(HIGH,HIGH,HIGH,HIGH);
}
ledOutput(ledTemp1,ledTemp2,ledTemp3,ledTemp4);
delayCount = delayCount +1;
if (delayCount > 500) {
delayCount = 0;
ledRow = ledRow +1;
if (ledRow > 3) ledRow = 0;
}
//delay(100);
}
void ledOutput (int ledVal1, int ledVal2, int ledVal3, int ledVal4) {
digitalWrite (led1,ledVal1);
digitalWrite (led2,ledVal2);
digitalWrite (led3,ledVal3);
digitalWrite (led4,ledVal4);
}
boolean debounceSwitch(int swPin, boolean LastLogic) {
boolean currentLogic = digitalRead (swPin);
if (currentLogic != LastLogic) {
delay(2);
currentLogic = digitalRead(swPin);
}
return currentLogic;
}
int led2 = 3;
int led3 = 4;
int led4 = 5;
int sw = 8;
boolean sw000 = HIGH;
int ledStatus = 0;
int ledStep1[4][4] = { 1,0,0,0,
0,1,0,0,
0,0,1,0,
0,0,0,1};
int ledStep2[4][4] = { 0,0,0,1,
0,0,1,0,
0,1,0,0,
1,0,0,0};
int ledStep3[4][4] = { 0,1,0,1,
1,0,1,0,
1,1,0,0,
0,0,1,1};
// แถวที่จะอ่านจาก ledStep
int ledRow = 0;
int delayCount = 0;
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 = debounceSwitch(sw, sw000);
if((swInput == HIGH) && (sw000 == LOW)) {
//กำหนดสถานะ led
ledStatus = ledStatus +1;
if (ledStatus > 3)ledStatus = 0;
}
sw000 = swInput; //เก็บสถานะปัจจุบัน
int ledTemp1,ledTemp2,ledTemp3,ledTemp4;
if (ledStatus == 0){
ledTemp1 = LOW;
ledTemp2 = LOW;
ledTemp3 = LOW;
ledTemp4 = LOW;
// ledOutput(LOW,LOW,LOW,LOW);
} else if (ledStatus == 1){
ledTemp1 = ledStep1[ledRow][0];
ledTemp2 = ledStep1[ledRow][1];
ledTemp3 = ledStep1[ledRow][2];
ledTemp4 = ledStep1[ledRow][3];
// ledOutput(LOW,LOW,LOW,HIGH);
} else if (ledStatus == 2) {
ledTemp1 = ledStep2[ledRow][0];
ledTemp2 = ledStep2[ledRow][1];
ledTemp3 = ledStep2[ledRow][2];
ledTemp4 = ledStep2[ledRow][3];
// ledOutput(LOW,LOW,HIGH,HIGH);
//} else if (ledStatus == 3) {
// ledOutput(LOW,HIGH,HIGH,HIGH);
} else {
ledTemp1 = ledStep3[ledRow][0];
ledTemp2 = ledStep3[ledRow][1];
ledTemp3 = ledStep3[ledRow][2];
ledTemp4 = ledStep3[ledRow][3];
// ledOutput(HIGH,HIGH,HIGH,HIGH);
}
ledOutput(ledTemp1,ledTemp2,ledTemp3,ledTemp4);
delayCount = delayCount +1;
if (delayCount > 500) {
delayCount = 0;
ledRow = ledRow +1;
if (ledRow > 3) ledRow = 0;
}
//delay(100);
}
void ledOutput (int ledVal1, int ledVal2, int ledVal3, int ledVal4) {
digitalWrite (led1,ledVal1);
digitalWrite (led2,ledVal2);
digitalWrite (led3,ledVal3);
digitalWrite (led4,ledVal4);
}
boolean debounceSwitch(int swPin, boolean LastLogic) {
boolean currentLogic = digitalRead (swPin);
if (currentLogic != LastLogic) {
delay(2);
currentLogic = digitalRead(swPin);
}
return currentLogic;
}
LED pattern
int led1 = 2;
int led2 = 3;
int led3 = 4;
int led4 = 5;
int sw = 8;
boolean sw000 = HIGH;
int ledStatus = 0;
int ledStep1[4][4] = { 1,0,0,0,
0,1,0,0,
0,0,1,0,
0,0,0,1};
int ledStep2[4][4] = { 0,0,0,1,
0,0,1,0,
0,1,0,0,
1,0,0,0};
int ledStep3[4][4] = { 0,1,0,1,
1,0,1,0,
1,1,0,0,
0,0,1,1};
// แถวที่จะอ่านจาก ledStep
int ledRow = 0;
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 = debounceSwitch(sw, sw000);
if((swInput == HIGH) && (sw000 == LOW)) {
//กำหนดสถานะ led
ledStatus = ledStatus +1;
if (ledStatus > 3)ledStatus = 0;
}
sw000 = swInput; //เก็บสถานะปัจจุบัน
int ledTemp1,ledTemp2,ledTemp3,ledTemp4;
if (ledStatus == 0){
ledTemp1 = LOW;
ledTemp2 = LOW;
ledTemp3 = LOW;
ledTemp4 = LOW;
// ledOutput(LOW,LOW,LOW,LOW);
} else if (ledStatus == 1){
ledTemp1 = ledStep1[ledRow][0];
ledTemp2 = ledStep1[ledRow][1];
ledTemp3 = ledStep1[ledRow][2];
ledTemp4 = ledStep1[ledRow][3];
// ledOutput(LOW,LOW,LOW,HIGH);
} else if (ledStatus == 2) {
ledTemp1 = ledStep2[ledRow][0];
ledTemp2 = ledStep2[ledRow][1];
ledTemp3 = ledStep2[ledRow][2];
ledTemp4 = ledStep2[ledRow][3];
// ledOutput(LOW,LOW,HIGH,HIGH);
//} else if (ledStatus == 3) {
// ledOutput(LOW,HIGH,HIGH,HIGH);
} else {
ledTemp1 = ledStep3[ledRow][0];
ledTemp2 = ledStep3[ledRow][1];
ledTemp3 = ledStep3[ledRow][2];
ledTemp4 = ledStep3[ledRow][3];
// ledOutput(HIGH,HIGH,HIGH,HIGH);
}
ledOutput(ledTemp1,ledTemp2,ledTemp3,ledTemp4);
ledRow = ledRow +1;
if (ledRow > 3) ledRow = 0;
delay(100);
}
void ledOutput (int ledVal1, int ledVal2, int ledVal3, int ledVal4) {
digitalWrite (led1,ledVal1);
digitalWrite (led2,ledVal2);
digitalWrite (led3,ledVal3);
digitalWrite (led4,ledVal4);
}
boolean debounceSwitch(int swPin, boolean LastLogic) {
boolean currentLogic = digitalRead (swPin);
if (currentLogic != LastLogic) {
delay(2);
currentLogic = digitalRead(swPin);
}
return currentLogic;
}
int led2 = 3;
int led3 = 4;
int led4 = 5;
int sw = 8;
boolean sw000 = HIGH;
int ledStatus = 0;
int ledStep1[4][4] = { 1,0,0,0,
0,1,0,0,
0,0,1,0,
0,0,0,1};
int ledStep2[4][4] = { 0,0,0,1,
0,0,1,0,
0,1,0,0,
1,0,0,0};
int ledStep3[4][4] = { 0,1,0,1,
1,0,1,0,
1,1,0,0,
0,0,1,1};
// แถวที่จะอ่านจาก ledStep
int ledRow = 0;
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 = debounceSwitch(sw, sw000);
if((swInput == HIGH) && (sw000 == LOW)) {
//กำหนดสถานะ led
ledStatus = ledStatus +1;
if (ledStatus > 3)ledStatus = 0;
}
sw000 = swInput; //เก็บสถานะปัจจุบัน
int ledTemp1,ledTemp2,ledTemp3,ledTemp4;
if (ledStatus == 0){
ledTemp1 = LOW;
ledTemp2 = LOW;
ledTemp3 = LOW;
ledTemp4 = LOW;
// ledOutput(LOW,LOW,LOW,LOW);
} else if (ledStatus == 1){
ledTemp1 = ledStep1[ledRow][0];
ledTemp2 = ledStep1[ledRow][1];
ledTemp3 = ledStep1[ledRow][2];
ledTemp4 = ledStep1[ledRow][3];
// ledOutput(LOW,LOW,LOW,HIGH);
} else if (ledStatus == 2) {
ledTemp1 = ledStep2[ledRow][0];
ledTemp2 = ledStep2[ledRow][1];
ledTemp3 = ledStep2[ledRow][2];
ledTemp4 = ledStep2[ledRow][3];
// ledOutput(LOW,LOW,HIGH,HIGH);
//} else if (ledStatus == 3) {
// ledOutput(LOW,HIGH,HIGH,HIGH);
} else {
ledTemp1 = ledStep3[ledRow][0];
ledTemp2 = ledStep3[ledRow][1];
ledTemp3 = ledStep3[ledRow][2];
ledTemp4 = ledStep3[ledRow][3];
// ledOutput(HIGH,HIGH,HIGH,HIGH);
}
ledOutput(ledTemp1,ledTemp2,ledTemp3,ledTemp4);
ledRow = ledRow +1;
if (ledRow > 3) ledRow = 0;
delay(100);
}
void ledOutput (int ledVal1, int ledVal2, int ledVal3, int ledVal4) {
digitalWrite (led1,ledVal1);
digitalWrite (led2,ledVal2);
digitalWrite (led3,ledVal3);
digitalWrite (led4,ledVal4);
}
boolean debounceSwitch(int swPin, boolean LastLogic) {
boolean currentLogic = digitalRead (swPin);
if (currentLogic != LastLogic) {
delay(2);
currentLogic = digitalRead(swPin);
}
return currentLogic;
}
push LED
int led1 = 2;
int led2 = 3;
int led3 = 4;
int led4 = 5;
int sw = 8;
boolean sw000 = HIGH;
int ledStatus = 0;
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 = debounceSwitch(sw, sw000);
if((swInput == HIGH) && (sw000 == LOW)) {
//กำหนดสถานะ led
ledStatus = ledStatus +1;
if (ledStatus > 4)ledStatus = 0;
}
sw000 = swInput;
if (ledStatus == 0){
ledOutput(LOW,LOW,LOW,LOW);
} else if (ledStatus == 1){
ledOutput(LOW,LOW,LOW,HIGH);
} else if (ledStatus == 2) {
ledOutput(LOW,LOW,HIGH,HIGH);
} else if (ledStatus == 3) {
ledOutput(LOW,HIGH,HIGH,HIGH);
} else {
ledOutput(HIGH,HIGH,HIGH,HIGH);
}
}
void ledOutput (int ledVal1, int ledVal2, int ledVal3, int ledVal4) {
digitalWrite (led1,ledVal1);
digitalWrite (led2,ledVal2);
digitalWrite (led3,ledVal3);
digitalWrite (led4,ledVal4);
}
boolean debounceSwitch(int swPin, boolean LastLogic) {
boolean currentLogic = digitalRead (swPin);
if (currentLogic != LastLogic) {
delay(2);
currentLogic = digitalRead(swPin);
}
return currentLogic;
}
int led2 = 3;
int led3 = 4;
int led4 = 5;
int sw = 8;
boolean sw000 = HIGH;
int ledStatus = 0;
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 = debounceSwitch(sw, sw000);
if((swInput == HIGH) && (sw000 == LOW)) {
//กำหนดสถานะ led
ledStatus = ledStatus +1;
if (ledStatus > 4)ledStatus = 0;
}
sw000 = swInput;
if (ledStatus == 0){
ledOutput(LOW,LOW,LOW,LOW);
} else if (ledStatus == 1){
ledOutput(LOW,LOW,LOW,HIGH);
} else if (ledStatus == 2) {
ledOutput(LOW,LOW,HIGH,HIGH);
} else if (ledStatus == 3) {
ledOutput(LOW,HIGH,HIGH,HIGH);
} else {
ledOutput(HIGH,HIGH,HIGH,HIGH);
}
}
void ledOutput (int ledVal1, int ledVal2, int ledVal3, int ledVal4) {
digitalWrite (led1,ledVal1);
digitalWrite (led2,ledVal2);
digitalWrite (led3,ledVal3);
digitalWrite (led4,ledVal4);
}
boolean debounceSwitch(int swPin, boolean LastLogic) {
boolean currentLogic = digitalRead (swPin);
if (currentLogic != LastLogic) {
delay(2);
currentLogic = digitalRead(swPin);
}
return currentLogic;
}
LED uno
int led1 = 2;
int led2 = 3;
int led3 = 4;
int led4 = 5;
int sw = 8;
boolean sw000 = HIGH;
int ledStatus = 0;
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 = debounceSwitch(sw, sw000);
if((swInput == HIGH) && (sw000 == LOW)) {
//กำหนดสถานะ led
ledStatus = ledStatus +1;
if (ledStatus > 3)ledStatus = 0;
}
sw000 = swInput;
}
void ledOutput (int ledVal1, int ledVal2, int ledVal3, int ledVal4) {
digitalWrite (led1,ledVal1);
digitalWrite (led2,ledVal2);
digitalWrite (led3,ledVal3);
digitalWrite (led4,ledVal4);
}
boolean debounceSwitch(int swPin, boolean LastLogic) {
boolean currentLogic = digitalRead (swPin);
if (currentLogic != LastLogic) {
delay(2);
currentLogic = digitalRead(swPin);
}
return currentLogic;
}
int led2 = 3;
int led3 = 4;
int led4 = 5;
int sw = 8;
boolean sw000 = HIGH;
int ledStatus = 0;
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 = debounceSwitch(sw, sw000);
if((swInput == HIGH) && (sw000 == LOW)) {
//กำหนดสถานะ led
ledStatus = ledStatus +1;
if (ledStatus > 3)ledStatus = 0;
}
sw000 = swInput;
}
void ledOutput (int ledVal1, int ledVal2, int ledVal3, int ledVal4) {
digitalWrite (led1,ledVal1);
digitalWrite (led2,ledVal2);
digitalWrite (led3,ledVal3);
digitalWrite (led4,ledVal4);
}
boolean debounceSwitch(int swPin, boolean LastLogic) {
boolean currentLogic = digitalRead (swPin);
if (currentLogic != LastLogic) {
delay(2);
currentLogic = digitalRead(swPin);
}
return currentLogic;
}
int led1 = 2;
int led2 = 3;
int led3 = 4;
int led4 = 5;
int sw = 8;
boolean sw000 = HIGH;
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);
}
boolean debounceSwitch(int swPin, boolean LastLogic) {
boolean currentLogic = digitalRead (swPin);
if (currentLogic != LastLogic) {
delay(2);
currentLogic = digitalRead(swPin);
}
return currentLogic;
}
int led2 = 3;
int led3 = 4;
int led4 = 5;
int sw = 8;
boolean sw000 = HIGH;
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);
}
boolean debounceSwitch(int swPin, boolean LastLogic) {
boolean currentLogic = digitalRead (swPin);
if (currentLogic != LastLogic) {
delay(2);
currentLogic = digitalRead(swPin);
}
return currentLogic;
}
Switch UNO
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);
}
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);
}
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);
}
Subscribe to:
Posts (Atom)