2014-git-work/arduino/mini_rhinoceros/mini_rhinoceros.pde
2012-08-28 22:52:01 +09:00

40 lines
676 B
Text

#define pin_l_0 6
#define pin_l_1 7
#define pin_r_1 8
#define pin_r_0 9
#define pin_sensor_0 3
#define pin_sensor_1 2
byte sensor;
void setup(){
pinMode(pin_l_0,OUTPUT);
pinMode(pin_l_1,OUTPUT);
pinMode(pin_r_0,OUTPUT);
pinMode(pin_r_1,OUTPUT);
digitalWrite(pin_l_0,HIGH);
digitalWrite(pin_l_1,LOW);
digitalWrite(pin_r_0,HIGH);
digitalWrite(pin_r_1,LOW);
/*--------------------*/
sensor = 0b11;
}
void loop(){
if(analogRead(pin_sensor_0)<100){
sensor = 0b10;
}else if(analogRead(pin_sensor_1)<100){
sensor = 0b01;
}
digitalWrite(pin_r_0,(sensor & 0b01) >> 0 );
digitalWrite(pin_l_0,(sensor & 0b10) >> 1 );
}