Home

Sunday, November 30, 2014

EEPROM

#include <EEPROM.h>
void setup() {
  // put your setup code here, to run once:
  Serial.begin(9600);
  readEEPROM();
}

void loop() {
}
  // put your main code here, to run repeatedly:
void readEEPROM() {
  int value =0;
  int addr = 0;
  value = EEPROM.read(addr);
  while (value != 0) {
    Serial.print(value);
    addr = addr + 1;
    value = EEPROM.read(addr);
  }
  Serial.println();
}

Thursday, November 20, 2014

0000

int led1 = 2;
int led2 = 3;
int led3 = 4;

int sw = 8;
void setup() {
  // put your setup code here, to run once:
  pinMode(led1, OUTPUT);
  pinMode(led2, OUTPUT);
  pinMode(led3, OUTPUT);
  pinMode(sw, INPUT);
}
void loop() {
  // put your main code here, to run repeatedly:
  int swInput = digitalRead(sw);
  if (swInput == ' '){
    digitalWrite (led1,HIGH);
    digitalWrite (led2,LOW);
    digitalWrite (led3,LOW);
  } else {
    (swInput == ' ');
    digitalWrite (led1,LOW);
    digitalWrite (led2,LOW);
    digitalWrite (led3,LOW);
  }
}

Exam2

int led1 = 2;
int led2 = 3;
int sw1 = 7;
int sw2 = 8;
int time = 100;
int count = 0;
int s = LOW;
int a;
int old = HIGH;
void setup() {
// put your setup code here, to run once:
pinMode(led1,OUTPUT);
pinMode(led2,OUTPUT);
pinMode(sw7,INPUT);
pinMode(sw8,INPUT);
}

void loop() {
// put your main code here, to run repeatedly:
if(digitalRead(sw1)==LOW && digitalRead(sw2)==HIGH ){
for(int i = 1;i <= 3;i++){
digitalWrite(led1,!s);
delay(time);
digitalWrite(led1,LOW);
digitalWrite(led2,!s);
delay(time);
digitalWrite(led2,LOW);

if(digitalRead(sw2)==LOW && digitalRead(sw1)==HIGH){
time = time + 100;
}
i = 1; 
}
}
}

Wednesday, November 19, 2014

arduino-lcd-alarm-clock

http://fritzing.org/projects/arduino-lcd-alarm-clock/

Thursday, November 13, 2014

Exam

#define LED_PIN 13
int DT = 2000;

void setup() {
 pinMode(LED_PIN,OUTPUT);
 Serial.begin(9600);
 Serial.println("Please select: \n + - increase_speed \n - - decrease_speed");
}

void loop() {
 
  char inp;
 
  if(Serial.available() > 0){
   inp = Serial.read();
   if (inp == '+') {
     DT = DT + 200;
   }
     else if (inp == '-'){
     DT = DT+ - 200;
   } else{
     DT = 2000;
   }
 }
 digitalWrite(LED_PIN, HIGH);
 delay(DT);
 digitalWrite(LED_PIN, LOW);
 delay(DT);

}

Monday, November 10, 2014

.include "D:\4th years\INTRODUCTION TO VERY LARGE SCALE INTEGRATED\necessary file\morbn20.md"
VDD VDD GND 5
VA A GND BIT ({00001111}) AC 5
VB B GND BIT ({00110011}) AC 5
VCin Cin GND BIT ({01010101}) AC 5

.tran/op 1n 80n method=bdf

.print tran v(A) v(B) v(Cin) v(Sum) v(Cout)

Tuesday, October 21, 2014

zZZZZz

VDD VDD GND 5
VA A GND PULSE (5 0 0 1n 1n 800n 1600n)
VB B GND PULSE (5 0 0 1n 1n 400n 800n)
VC C GND PULSE (5 0 0 1n 1n 200n 400n)
VD D GND PULSE (5 0 0 1n 1n 100n 200n)
.tran/op 1n 1600n method=bdf
.print tran v(OUT) v(A) v(B) v(C) v(D)

Monday, October 20, 2014

L-Edit

VDD VDD GND 5
VA A GND PULSE (0 5 0 1n 1n 800n 1600n)
VB B GND PULSE (0 5 0 1n 1n 400n 800n)
VC C GND PULSE (0 5 0 1n 1n 200n 400n)
VD D GND PULSE (0 5 0 1n 1n 100n 200n)
.tran/op 1n 1600n method=bdf
.print tran v(OUT) v(A) v(B) v(C) v(D)

Thursday, October 16, 2014

๊today

import processing.serial.*;
Serial myPort;
String serialData = " ";

void setup(){
  size(800, 600);
  myPort = new Serial(this, "COM6", 9600);
  myPort.bufferUntil('\n');
}

void draw(){
  int bgColor = 0;
  if serialData.length()>0 {
    bgColor = Float.parseFloat(serialData) / 4.0;
  }
  background(bgColor,0,0);
  textSize(40);
  text(serialData, 400, 200);
 
}

void serialEvent(Serial port){
  serialData = myPort.readStringUntil('\n');
  serialData = serialData.substring(0,serialData.length()-1);
}

Saturday, October 04, 2014

Arrive VTSP

PHUKET INTL AIRP, TH
VTSP 041300Z 28014KT 7000 FEW014 SCT016 BKN120 26/23 Q1012 A2988 RERA



VTBS -> WSSS

International route flight second round of week with Boeing 737-900NGX
Departure : VTBS (Suvarnabhumi Intl) 19.45UTC
Arrive : WSSS (Changi Intl) 21.20UTC


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;
}

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;
}

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;
}

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;
}

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 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;
}

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);
}

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);
}

Landing VTCC Chiang Mai Intl RWY36


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);
  }

Friday, January 24, 2014

SWITCH_02


ORG 0000H
MOV A,#00H

LOOP1: PUSH ACC
LOOP: MOV A,P2
CJNE A,#0FFH,LOOP1
POP ACC

MOV P1,A
ACALL DELAY
CPL A
SJMP LOOP

DELAY: MOV R7,#00H
DLY: MOV R6,0FFH
DJNZ R6,$
DJNZ R7,DLY
RET
END

Switch


ORG 0000H
MOV A,#00H
LOOP: MOV P1,A
ACALL DELAY
CPL A
SJMP LOOP

DELAY: MOV R7,#00H
DLY: MOV R6,0FFH
DJNZ R6,$
DJNZ R7,DLY
RET
END

LED SKIP P1 to P2


ORG 0000H
MAIN: MOV DPTR,#TABLE
MOV A,#00H
MOV P2,#00H

LOOP: PUSH ACC
MOVC A,@A+DPTR
MOV P1,A
POP ACC
INC A
ACALL DELAY
CJNE A,#8,LOOP

MOV DPTR,#TABLE1
MOV A,#00H
MOV P1,#00H

LOOP1: PUSH ACC
MOVC A,@A+DPTR
MOV P2,A
POP ACC
INC A
ACALL DELAY
CJNE A,#8,LOOP1
SJMP MAIN

DELAY: MOV R7,#0FFH
DLY: MOV R6,#0FFH
DJNZ R6,$
DJNZ R7,DLY
RET
TABLE: DB 01H,02H,04H,08H,10H,20H,40H,80H
TABLE1: DB 80H,40H,20H,10H,08H,04H,02H,01H

END

LOOP LED


ORG 0000H
MAIN: MOV DPTR,#TABLE
MOV A,#00H

LOOP: PUSH ACC
MOVC A,@A+DPTR
MOV P1,A
POP ACC
INC A
ACALL DELAY
CJNE A,#14,LOOP
SJMP MAIN

DELAY: MOV R7,#0FFH
DLY: MOV R6,#0FFH
DJNZ R6,$
DJNZ R7,DLY
RET
TABLE: DB 01H,02H,04H,08H,10H,20H,40H,80H
TABLE1: DB 40H,20H,10H,08H,04H,02H

END