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 Gadgeteer.Networking;
using GT = Gadgeteer;
using GTM = Gadgeteer.Modules;
using Gadgeteer.Modules.GHIElectronics;
using GHI.OSHW.Hardware; // 追加、参照設定にも追加
using GHI.Hardware.FEZCerb; // 追加、参照設定にも追加
using Microsoft.SPOT.Hardware;
namespace JoystickTest
{
public partial class Program
{
GT.Timer tm = new GT.Timer(100, GT.Timer.BehaviorType.RunContinuously);
OutputPort LED1 = new OutputPort(Pin.PB1, false);
AnalogInput X = new AnalogInput(Cpu.AnalogChannel.ANALOG_1);
AnalogInput Y = new AnalogInput(Cpu.AnalogChannel.ANALOG_2);
void ProgramStarted()
{
tm.Start();
tm.Tick += new GT.Timer.TickEventHandler(TimeCounter);
}
void TimeCounter(GT.Timer timer)
{
double x = X.Read();
double y = Y.Read();
Debug.Print("x= "+x.ToString().Substring(0,6)+" "+
"y= "+y.ToString().Substring(0,6));
if (x + y > 1.0) LED1.Write(true);
else LED1.Write(false);
}
}
}
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
|