# \[햄스터로봇] 왼쪽/오른쪽 근접센서

### 코드

```
@햄스터 왼쪽 근접센서
@햄스터 오른쪽 근접센서
```

***

### 설명

* 햄스터로봇의 좌우 근접센서 값을 읽어 장애물과의 가까움을 판단할 때 사용해요.

***

### 주의사항

* 센서 값 범위는 기기/환경에 따라 달라질 수 있어요.
* 기준값(예: 30 이상)을 정해서 조건문으로 제어해요.

***

### 파이썬 대응 코드

```
from roboid import *
hamster = Hamster()
while True:
    print(hamster.left_proximity(), hamster.right_proximity()) # python 3.x.x
    print hamster.left_proximity(), hamster.right_proximity() # python 2.7.x
    wait(20)
```

***

### 예시

{% code title="예시 코드" %}

```
왼쪽값 = @햄스터 왼쪽 근접센서
오른쪽값 = @햄스터 오른쪽 근접센서
왼쪽값 + "," + 오른쪽값 보여주기
```

{% endcode %}

{% code title="예시 코드의 결과" %}

```
(햄스터로봇의 현재 좌우 근접센서 값이 출력돼요.)
```

{% endcode %}

***

### 검색 키워드

햄스터로봇, 근접센서, 왼쪽 근접센서, 오른쪽 근접센서


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://codebook.horang.it/undefined/undefined-3.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
