| 라인트레이서를 만드려고 tcrt5000 센서를 사용하였는데 센서값을 읽어오지를 못합니다. 센서를 제외하고 모터제어하는 부분은 작동하는것을 확인하엿습니다. 코드부분과 함께 올리겠습니다. 코드에서 값을 계속 바꿔도 안되네요 ㅠㅠ  
 #define MOTORA_PIN1 7#define MOTORA_PIN2 8
 #define MOTORA_PIN3 12
 #define MOTORA_PIN4 13
 void motor_CW(int speed) //backward{
 analogWrite (MOTORA_PIN1, speed);
 digitalWrite (MOTORA_PIN2, LOW);
 analogWrite (MOTORA_PIN3, speed);
 analogWrite (MOTORA_PIN4, LOW);
 delay(10);
 }
 void motor_CCW(int speed) //foward{
 analogWrite (MOTORA_PIN1, 255-speed);
 digitalWrite (MOTORA_PIN2, HIGH);
 analogWrite (MOTORA_PIN3, 255-speed);
 digitalWrite (MOTORA_PIN4, HIGH);
 
 }
 void motor_RIGHT(int speed)//right
 {
 analogWrite (MOTORA_PIN1, 255-speed);
 digitalWrite (MOTORA_PIN2, HIGH);
 analogWrite (MOTORA_PIN3, speed);
 digitalWrite (MOTORA_PIN4, LOW);
 delay(10);
 }
 void motor_LEFT(int speed)
 {
 analogWrite (MOTORA_PIN1, speed);
 digitalWrite (MOTORA_PIN2, LOW);
 analogWrite (MOTORA_PIN3, 255-speed);
 digitalWrite (MOTORA_PIN4, HIGH);
 delay(10);
 }
 void motor_STOP(int speed)//stop
 {
 analogWrite (MOTORA_PIN1, speed);
 digitalWrite (MOTORA_PIN2, LOW);
 analogWrite (MOTORA_PIN3, speed);
 digitalWrite (MOTORA_PIN4, LOW);
 
 }
 void setup() {Serial.begin(9600);
 // put your setup code here, to run once:
 pinMode (MOTORA_PIN1, OUTPUT);
 pinMode (MOTORA_PIN2,OUTPUT);
 }void loop() {
 
 // A2 : 왼쪽, A3 : 가운데, A4 : 오른쪽 센서와 연결되어 있습니다.
 if(analogRead(A4) > 100 && analogRead(A3) > 100 && analogRead(A2) > 100){
 // 3개의 센서가 모두 인식이 됬을 경우는 멈춰있습니다.
 analogWrite(7, 0);
 analogWrite(8, 0);
 }
 else if(analogRead(A2) > 100 && analogRead(A3) < 100 && analogRead(A4) < 100){
 // 왼쪽 센서만 인식했을 경우 왼쪽으로 이동합니다.
 motor_LEFT(255);
 }
 else if(analogRead(A4) > 500 && analogRead(A3) < 500 &&analogRead(A2) < 500){
 // 오른쪽 센서만 인식했을 경우 오른쪽으로 이동합니다,
 motor_RIGHT(255);
 }
 
 else if(analogRead(A3) > 800){
 // 가운데 센서가 인식 했을 경우 앞으로 이동합니다.
 motor_CCW(255);
 }
 }
 /////////////
   | 
			
				| 다음글   |   
					GPS 데이터의 시리얼 모니터 출력 | 2016-02-12 |