a. Arduino UNO
b. Modul EOG
c. IC Power Supply
d. Program Arduino IDE untuk deteksi gerakan mata
//elektroda kanan pinheader atas
//elektroda kiri pinheader bawah
int dataadc;
int adcold;
int kanan;
int kiri;
int x = 0;
void setup() {
Serial.begin(9600);
}
void loop() {
dataadc = analogRead(A0);
kanan = dataadc + 20;
kiri = dataadc - 20;
Serial.println(dataadc);
if(adcold > kanan){
//Serial.println("arah kanan ");
}
if(adcold < kiri){
//Serial.println("arah kiri");
}
if((adcold > kanan)&&(x == 0)){
x = 1;
}
if((adcold < kiri)&&(x == 1)){
x = 2;
Serial.println("kiri <=====");
}
if((adcold < kiri)&&(x == 2)){
Serial.println("kiri <=====");
x = 0;
}
if((adcold < kiri)&&(x == 0)){
x = 3;
}
if((adcold > kanan)&&(x == 3)){
Serial.println("kanan <=====");
x = 4;
}
if((adcold > kanan)&&(x == 4)){
Serial.println("kanan <=====");
x = 0;
}
adcold = dataadc;
delay(10);
}
No comments:
Post a Comment