本文整理汇总了C#中Microsoft.SPOT.Hardware.OutputPort.Read方法的典型用法代码示例。如果您正苦于以下问题:C# OutputPort.Read方法的具体用法?C# OutputPort.Read怎么用?C# OutputPort.Read使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Microsoft.SPOT.Hardware.OutputPort
的用法示例。
在下文中一共展示了OutputPort.Read方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Main
public static void Main()
{
//NetworkInterface.GetAllNetworkInterfaces()[0].EnableDhcp();
NetworkInterface.GetAllNetworkInterfaces()[0].EnableStaticIP("192.168.0.16","255.255.255.0","192.168.0.1");
// NetworkInterface.GetAllNetworkInterfaces()[0].RenewDhcpLease();
// var ipAddress = NetworkInterface.GetAllNetworkInterfaces()[0].IPAddress;
Thread.Sleep(1000);
Debug.Print("Dirs: ");
Debug.Print(Directory.GetCurrentDirectory());
Directory.SetCurrentDirectory(@"\SD");
string[] dirs = Directory.GetDirectories(@"\SD");
var webServer = new Server.WebServer {WebFolder = WebFolder, Port = 80};
webServer.Start();
var led = new OutputPort(Pins.ONBOARD_LED, false);
while (true)
{
// Blink LED to show we're still responsive
led.Write(!led.Read());
Thread.Sleep(2000);
}
}
示例2: Main
public static void Main()
{
mainThread = Thread.CurrentThread;
activityLED = new OutputPort(Pins.ONBOARD_LED, false);
if (enableLogging)
{
int i = 0;
while (File.Exists(csvPath + i + ".csv"))
i++;
csvPath += i + ".csv";
writer = new FileStream(csvPath, FileMode.Append);
buffer = Encoding.UTF8.GetBytes("A X,A Y,A Z,M X,M Y,M Z,G X,G Y,G Z,,Yaw,Pitch,Roll \n");
writer.Write(buffer, 0, buffer.Length);
}
//ComplexNumTests();
//VectorTests();
//MatrixTests();
InitializeACDC();
mainThread.Priority = ThreadPriority.BelowNormal;
// Loop forever to keep the code running
// flashing the on board led to let us know code hasn't crashed
while (true)
{
activityLED.Write(!activityLED.Read() && enableLogging);
Thread.Sleep(10);
}
}
示例3: FlashLed
static void FlashLed()
{
var outputPort = new OutputPort(Pins.GPIO_PIN_D0, false);
while (true)
{
outputPort.Write(!outputPort.Read());
Thread.Sleep(1000);
}
}
示例4: Main
public static void Main()
{
OutputPort outputPort = new OutputPort(Cpu.Pin.GPIO_Pin0, true);
while (true)
{
Thread.Sleep(500);
outputPort.Write(!outputPort.Read()); //toggle port
}
}
示例5: Main
static void Main(string[] args)
{
OutputPort o = new OutputPort(Cpu.Pin.GPIO_Pin17, true);
for (int i = 0; i < 5; i++)
{
o.Write(true);
Console.WriteLine("Read: " + o.Read());
Thread.Sleep(500);
o.Write(false);
Console.WriteLine("Read: " + o.Read());
Thread.Sleep(500);
}
o.Dispose();
InputPort input = new InputPort(Cpu.Pin.GPIO_Pin17, true, Port.ResistorMode.Disabled);
Console.WriteLine("Read: " + input.Read());
input.Dispose();
Console.WriteLine("Finishing");
}
示例6: Main
public static void Main()
{
var led = new OutputPort(Pins.ONBOARD_LED, false);
while (true)
{
led.Write(!led.Read());
Thread.Sleep(1000);
}
}
示例7: Main
public static void Main()
{
var led = new OutputPort(Pins.GPIO_PIN_D13, false);
var button = new InputPort(Pins.GPIO_PIN_D2, false, Port.ResistorMode.Disabled);
while (true)
{
if (!button.Read())
{
led.Write(!led.Read());
Thread.Sleep(1000);
}
}
}
示例8: Main
public static void Main()
{
led = new OutputPort(Pins.GPIO_PIN_D8, false);
Microsoft.SPOT.Net.NetworkInformation.NetworkInterface NI = Microsoft.SPOT.Net.NetworkInformation.NetworkInterface.GetAllNetworkInterfaces()[0];
NI.EnableStaticIP("192.168.0.75", "255.255.255.0", "192.168.0.1");
Debug.Print(NI.IPAddress.ToString());
LightbulbInterface l = new LightbulbInterface(5436);
l.OnLampStatusChangeRequest += (s, a) => { led.Write(a.Data); };
l.OnLampStateRequest += (s, a) => { a.Data = led.Read(); };
l.Start();
Thread.Sleep(Timeout.Infinite);
}
示例9: Main
public static void Main()
{
// write your code here
var led=new OutputPort(Pins.ONBOARD_LED, false);
var button = new InputPort(Pins.ONBOARD_SW1, false, Port.ResistorMode.Disabled);
while (true)
{
if (!button.Read())
{
led.Write(!led.Read());
Thread.Sleep(300);
}
}
}
示例10: Main
public static void Main()
{
// write your code here
OutputPort led = new OutputPort(Pins.ONBOARD_LED, false);
int port = 80;
// Wait 5 seconds for DHCP to assign an address
Thread.Sleep(5000);
Microsoft.SPOT.Net.NetworkInformation.NetworkInterface networkInterface = Microsoft.SPOT.Net.NetworkInformation.NetworkInterface.GetAllNetworkInterfaces()[0];
Debug.Print("My IP Address is: " + networkInterface.IPAddress.ToString());
Socket listenerSocket = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
IPEndPoint endpoint = new IPEndPoint(IPAddress.Any, port);
listenerSocket.Bind(endpoint);
listenerSocket.Listen(1);
while (true)
{
Socket clientSocket = listenerSocket.Accept();
bool dataReady = clientSocket.Poll(5000, SelectMode.SelectRead);
if (dataReady && clientSocket.Available > 0)
{
byte[] buffer = new byte[clientSocket.Available];
int bytesRead = clientSocket.Receive(buffer);
string request = new string(System.Text.Encoding.UTF8.GetChars(buffer));
if (request.IndexOf("ON") >= 0)
led.Write(true);
else
led.Write(false);
string statusText = "LED is " + (led.Read() ? "ON" : "OFF") + ".";
string response = "HTTP/1.1 200 OK\r\n" +
"Content-Type: text/html; charset=utf-8\r\n\r\n" +
"<html><head><title>Netduino Networking Example</title></head>" +
"<body>" + statusText + "</body></html>";
clientSocket.Send(System.Text.Encoding.UTF8.GetBytes(response));
clientSocket.Close();
}
}
}
示例11: Main
public static void Main()
{
Debug.Print("Hello World!");
var button = new InterruptPort((Cpu.Pin)HydraNativePins.S12P03, true, Port.ResistorMode.PullUp, Port.InterruptMode.InterruptEdgeLow);
var button2 = new InterruptPort((Cpu.Pin)HydraNativePins.S03P03, true, Port.ResistorMode.PullUp, Port.InterruptMode.InterruptEdgeLow);
var p4 = new OutputPort((Cpu.Pin)HydraNativePins.S07P04, false);
var p6 = new OutputPort((Cpu.Pin)HydraNativePins.S07P06, false);
var p8 = new OutputPort((Cpu.Pin)HydraNativePins.S07P08, false);
var p9 = new OutputPort((Cpu.Pin)HydraNativePins.S07P09, false);
var level = new OutputPort((Cpu.Pin)HydraNativePins.S07P05, true);
var led = new OutputPort((Cpu.Pin)HydraNativePins.S07P07, false);
button.OnInterrupt += OnButtonPressed;
button2.OnInterrupt += OnButtonPressed;
while (true)
{
Thread.Sleep(500);
led.Write(!led.Read());
}
}
示例12: Main
public static void Main()
{
LCD.ByteMap = Bitmap;
LCD.Refresh();
//LCD.DrawString("Start initial.");
//LCD.Refresh();
//start the LCD sheild
//Nokia_5110 LCD = new Nokia_5110(false, Pins.GPIO_PIN_D5, Pins.GPIO_PIN_D7, Pins.GPIO_PIN_D6, Pins.GPIO_PIN_D4);
LCD.BacklightBrightness = 100;
//set ip static
NetworkInterface networkInterface = NetworkInterface.GetAllNetworkInterfaces()[0];
networkInterface.EnableStaticIP("192.168.1.199", "255.255.255.0", "192.168.1.1");
//the server:
//Listener webServer = new Listener(RequestReceived);
AnalogInput keys_port = new AnalogInput(Cpu.AnalogChannel.ANALOG_0);
AnalogInput test_port = new AnalogInput(Cpu.AnalogChannel.ANALOG_2);
OutputPort led = new OutputPort(Pins.ONBOARD_LED, false);
//LCD.DrawString("Done init.");
//LCD.Refresh();
while (true)
{
// Blink LED to show we're still responsive
led.Write(!led.Read());
Thread.Sleep(1000);
LCD.Clear();
LCD.DrawString(0, 0, "========");
LCD.DrawString(0, 1, "AD Port 0:");
LCD.DrawString(0, 2, keys_port.ReadRaw().ToString());
LCD.DrawString(0, 3, "AD Port 2:");
LCD.DrawString(0, 4, test_port.ReadRaw().ToString());
LCD.DrawString(0, 5, "========");
LCD.Refresh();
}
}
示例13: Main
//END RC constants
public static void Main()
{
//RC stuff
// Setup steering servo
steering = new Servo(Pins.GPIO_PIN_D9);
// Setup ESC
xl5 = new SpeedController(Pins.GPIO_PIN_D10, new TRAXXAS_XL5());
xl5.DriveMode = SpeedController.DriveModes.Forward;
//End RC stuff
Listener webServer = new Listener(RequestReceived);
OutputPort led = new OutputPort(Pins.ONBOARD_LED, false);
while (true)
{
// Blink LED to show we're still responsive
led.Write(!led.Read());
Thread.Sleep(500);
}
}
示例14: Main
/***********************************************************************
* Initialization
***********************************************************************/
public static void Main()
{
OutputPort LED;
LED = new OutputPort((Cpu.Pin)FEZ_Pin.Digital.LED, true);
for (int i=0; i<0*2; i++)
{
LED.Write(!LED.Read());
Thread.Sleep(100);
}
if (TEST)
test();
else
initializePorts();
Thread.Sleep(Timeout.Infinite);
}
示例15: Main
public static void Main()
{
// write your code here
servo = new Servo(Pins.GPIO_PIN_D9);
servo.Degree = servo_degree;
greenled = new OutputPort(Pins.GPIO_PIN_D3, true);
blueled = new OutputPort(Pins.GPIO_PIN_D4, true);
redled = new OutputPort(Pins.GPIO_PIN_D5, true);
whitebutton = new OutputPort(Pins.GPIO_PIN_D0, true);
blackbutton = new OutputPort(Pins.GPIO_PIN_D1, true);
redbutton = new OutputPort(Pins.GPIO_PIN_D2, true);
bluebutton = new OutputPort(Pins.GPIO_PIN_D6, true);
greenbutton = new OutputPort(Pins.GPIO_PIN_D7, true);
yellowbutton = new OutputPort(Pins.GPIO_PIN_D8, true);
bool whitestate = false;
bool whitestate_prev = false;
bool blackstate = false;
bool blackstate_prev = false;
bool redstate = false;
bool redstate_prev = false;
bool bluestate = false;
bool bluestate_prev = false;
bool greenstate = false;
bool greenstate_prev = false;
bool yellowstate = false;
bool yellowstate_prev = false;
while (true)
{
if (AcceptInput)
{
whitestate = whitebutton.Read();
if ((whitestate_prev == true) && (whitestate == false))
{
WhitePressed();
RecordAndCheckUserStep(3);
}
whitestate_prev = whitestate;
blackstate = blackbutton.Read();
if ((blackstate_prev == true) && (blackstate == false))
BlackPressed();
blackstate_prev = blackstate;
yellowstate = yellowbutton.Read();
if ((yellowstate_prev == true) && (yellowstate == false))
{
YellowPressed();
RecordAndCheckUserStep(4);
}
yellowstate_prev = yellowstate;
redstate = redbutton.Read();
if ((redstate_prev == true) && (redstate == false))
{
TurnOffLED(COLORS.RED);
RecordAndCheckUserStep(0);
}
else if ((redstate_prev == false) && (redstate == true))
TurnOnLED(COLORS.RED);
redstate_prev = redstate;
bluestate = bluebutton.Read();
if ((bluestate_prev == true) && (bluestate == false))
{
TurnOffLED(COLORS.BLUE);
RecordAndCheckUserStep(2);
}
else if ((bluestate_prev == false) && (bluestate == true))
TurnOnLED(COLORS.BLUE);
bluestate_prev = bluestate;
greenstate = greenbutton.Read();
if ((greenstate_prev == true) && (greenstate == false))
{
TurnOffLED(COLORS.GREEN);
RecordAndCheckUserStep(1);
}
else if ((greenstate_prev == false) && (greenstate == true))
TurnOnLED(COLORS.GREEN);
greenstate_prev = greenstate;
}
}
}