FEZ Cerbotで A/Dコンバーターを使う

FEZ Cerbotで A/Dコンバーターを使う

回路図によると、以下のピンが使えるようです
ADC1X5-4
ADC2X5-5
ADC3X4-3
ADC4X4-4
ADC5X4-5
ADC6X6-6


Program.cs
using System;
using System.Collections;
using System.Threading;
using Microsoft.SPOT;
using Microsoft.SPOT.Presentation;
using Microsoft.SPOT.Presentation.Controls;
using Microsoft.SPOT.Presentation.Media;
using Microsoft.SPOT.Presentation.Shapes;
using Microsoft.SPOT.Touch;
using Microsoft.SPOT.Hardware;

using Gadgeteer.Networking;
using GT = Gadgeteer;
using GTM = Gadgeteer.Modules;
using Gadgeteer.Modules.GHIElectronics;

namespace ADConverter
{
    public partial class Program
    {
        AnalogInput adLeft = new AnalogInput(Cpu.AnalogChannel.ANALOG_3);
        AnalogInput adRight = new AnalogInput(Cpu.AnalogChannel.ANALOG_4);

        void ProgramStarted()
        {
            new Thread(DoRun).Start();
        }
        void DoRun()
        {
            GT.Timer timer = new GT.Timer(500, GT.Timer.BehaviorType.RunContinuously);
            timer.Tick += new GT.Timer.TickEventHandler(timer_Tick);
            timer.Start();
        }
        void timer_Tick(GT.Timer timer)
        {
            double valLeft = adLeft.Read();
            double valRight = adRight.Read();
            Debug.Print(valLeft+" "+valRight);
        }
    }
}
 1 
 2 
 3 
 4 
 5 
 6 
 7 
 8 
 9 
10 
11 
12 
13 
14 
15 
16 
17 
18 
19 
20 
21 A/Dコンバーターのオブジェクトを作る
22 
23 
24 
25 
26 
27 
28 
29 
30 500ミリ秒ごとにタイマーイベントが起こる
31 
32 
33 
34 
35 
36 A/Dコンバーター
37 
38 
39 
40 
41