![](/media/cache/profiles/7c792a8279211dece3b4df04719c818a.50x50_q85.jpg)
ADC TEST CODE of LPC1114FN28
main.cpp@0:87a098bea248, 2013-09-14 (annotated)
- Committer:
- iqOyOpi
- Date:
- Sat Sep 14 00:49:19 2013 +0000
- Revision:
- 0:87a098bea248
ADC TEST CODE of LPC1114FN28
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
iqOyOpi | 0:87a098bea248 | 1 | #include "mbed.h" |
iqOyOpi | 0:87a098bea248 | 2 | float threshold = 0.5; // 閾値 |
iqOyOpi | 0:87a098bea248 | 3 | float val; |
iqOyOpi | 0:87a098bea248 | 4 | AnalogIn Val(dp13); // ポテンショメータのワイプ(中央の端子)に |
iqOyOpi | 0:87a098bea248 | 5 | // 両端はグランドと+5Vに接続 |
iqOyOpi | 0:87a098bea248 | 6 | DigitalOut myled(LED1); |
iqOyOpi | 0:87a098bea248 | 7 | Serial pc(dp16,dp15); |
iqOyOpi | 0:87a098bea248 | 8 | |
iqOyOpi | 0:87a098bea248 | 9 | int main() { |
iqOyOpi | 0:87a098bea248 | 10 | pc.baud(115200); |
iqOyOpi | 0:87a098bea248 | 11 | pc.printf("LPC1114 demo ADC\r\n"); |
iqOyOpi | 0:87a098bea248 | 12 | |
iqOyOpi | 0:87a098bea248 | 13 | while(1){ |
iqOyOpi | 0:87a098bea248 | 14 | val = Val; |
iqOyOpi | 0:87a098bea248 | 15 | pc.printf("Val = %2.1f\r\n", val); |
iqOyOpi | 0:87a098bea248 | 16 | if (val >= threshold) { |
iqOyOpi | 0:87a098bea248 | 17 | myled = 1; // LEDをオンに |
iqOyOpi | 0:87a098bea248 | 18 | } else { |
iqOyOpi | 0:87a098bea248 | 19 | myled = 0; // LEDをオフに |
iqOyOpi | 0:87a098bea248 | 20 | } |
iqOyOpi | 0:87a098bea248 | 21 | } |
iqOyOpi | 0:87a098bea248 | 22 | } |
iqOyOpi | 0:87a098bea248 | 23 | |
iqOyOpi | 0:87a098bea248 | 24 |