Arduino ADC를 사용해 보자~
Arduino UNO는 총 6개의 ADC를 가지고 있다. 10bit ADC 이고 0~1023까지 표현이 가능하다.
analogRead(A); 이 함수로 ADC 데이터를 읽을수 있고고, A는 analog 핀 번호이다. 이 함수를 사용하면 ADC 값이 return이 되므로 이 값을 변수에 저장을 해야한다. 아래와 같이 사용해봐.
ex.
|
아래의 회로로 실습을 했어. 가변저항 3개를 이용한 회로야

아래 사진은 시리얼로 출력된 ADC 값이야~

[#M_소스코드보기|접기|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 | <code> void setup() { // put your setup code here, to run once: Serial.begin(115200); } void loop() { // put your main code here, to run repeatedly: int adc0, adc1, adc2; adc0 = analogRead(A0); adc1 = analogRead(A1); adc2 = analogRead(A2); Serial.print( "ADC0 : " ); Serial.println(adc0); Serial.print( "ADC1 : " ); Serial.println(adc1); Serial.print( "ADC2 : " ); Serial.println(adc2); Serial.println( "==============================" ); delay(1000); }</code> |
ADC.ino
다운로드
'IT / Development > Arduino' 카테고리의 다른 글
Visual Studio에서 Aduino IDE 사용하기 - Visual Micro (0) | 2015.05.06 |
---|---|
Arduino ADC+PWM을 같이 사용해 보자. (0) | 2014.09.01 |
Arduino PWM 사용해 보자 (0) | 2014.09.01 |
Arduino Switch로 RGB LED Toggle 하기 (0) | 2014.05.25 |
Arduino Switch로 RGB LED 제어 + Serial 출력 (0) | 2014.05.04 |