-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy pathProgram.cs
More file actions
61 lines (57 loc) · 2.09 KB
/
Program.cs
File metadata and controls
61 lines (57 loc) · 2.09 KB
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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
using System;
using System.Threading;
using Microsoft.SPOT;
using Microsoft.SPOT.Hardware;
using SecretLabs.NETMF.Hardware;
using SecretLabs.NETMF.Hardware.Netduino;
namespace Netduino.Sample1
{
public class Program
{
public static void Main()
{
#region BlinkingLed
InputPort sw1 = new InputPort(Pins.ONBOARD_SW1, false,Port.ResistorMode.Disabled);
OutputPort led = new OutputPort(Pins.ONBOARD_LED, false);
OutputPort[] ports = new OutputPort[14];
ports[0] = new OutputPort(Pins.GPIO_PIN_D0, false);
ports[1] = new OutputPort(Pins.GPIO_PIN_D1, false);
ports[2] = new OutputPort(Pins.GPIO_PIN_D2, false);
ports[3] = new OutputPort(Pins.GPIO_PIN_D3, false);
ports[4] = new OutputPort(Pins.GPIO_PIN_D4, false);
ports[5] = new OutputPort(Pins.GPIO_PIN_D5, false);
ports[6] = new OutputPort(Pins.GPIO_PIN_D6, false);
ports[7] = new OutputPort(Pins.GPIO_PIN_D7, false);
ports[8] = new OutputPort(Pins.GPIO_PIN_D8, false);
ports[9] = new OutputPort(Pins.GPIO_PIN_D9, false);
ports[10] = new OutputPort(Pins.GPIO_PIN_D10, false);
ports[11] = new OutputPort(Pins.GPIO_PIN_D11, false);
ports[12] = new OutputPort(Pins.GPIO_PIN_D12, false);
ports[13] = new OutputPort(Pins.GPIO_PIN_D13, false);
int index = 0;
bool newValue=false;
DateTime expectedTime = DateTime.Now.AddSeconds(1);
while (true)
{
bool state = sw1.Read();
led.Write(state);
if (DateTime.Now < expectedTime)
{
continue;
}
expectedTime = DateTime.Now.AddSeconds(1);
newValue = !newValue;
ports[index].Write(newValue);
if (newValue)
continue;
else
{
index++;
if (index > 13)
index = 0;
}
}
#endregion
}
}
}