Comments (2)
Sorry... I found the solution #69
My code now:
`
using System;
using Windows.UI.Xaml;
using Windows.UI.Xaml.Controls;
using Microsoft.Maker.Serial;
using Microsoft.Maker.RemoteWiring;
using Microsoft.Maker.Firmata;
namespace Raspberry
{
public sealed partial class MainPage : Page
{
private UsbSerial usb;
private RemoteDevice arduino;
private const byte led1 = 13;
private DispatcherTimer readTemperatureTimer;
public MainPage()
{
this.InitializeComponent();
usb = new UsbSerial("VID_0403", "PID_6001");
arduino = new RemoteDevice(usb);
arduino.DeviceReady += onDeviceReady;
usb.begin(57600, SerialConfig.SERIAL_8N1);
}
private void onDeviceReady()
{
var action = Dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.Normal, new Windows.UI.Core.DispatchedHandler(() =>
{
setup();
}));
}
private void setup()
{
//Set the pin mode of the led.
arduino.pinMode(led1, PinMode.OUTPUT);
arduino.pinMode("A0", PinMode.ANALOG);
textConnection.Text = "Connected";
//Set the timer to schedule every 500 ms.
readTemperatureTimer = new DispatcherTimer();
readTemperatureTimer.Interval = TimeSpan.FromMilliseconds(1000);
readTemperatureTimer.Tick += readTemperature;
readTemperatureTimer.Start();
}
private void Onbutton_Click(object sender, RoutedEventArgs e)
{
arduino.digitalWrite(led1, PinState.HIGH);
Onbutton.Visibility = Visibility.Collapsed;
Offbutton.Visibility = Visibility.Visible;
}
private void Offbutton_Click(object sender, RoutedEventArgs e)
{
arduino.digitalWrite(led1, PinState.LOW);
Offbutton.Visibility = Visibility.Collapsed;
Onbutton.Visibility = Visibility.Visible;
}
private void readTemperature(object sender, object e)
{
//Read analog value from 0 to 1023, which maps from 0 to 5V
int temperatureValue = arduino.analogRead("A0");
//Convert analog value to temperature.
double temperature = (500.0 * temperatureValue) / 1024.0;
//Print temperature to Output.
textTemp1.Text = temperature.ToString() ;
}
}
}
`
from remote-wiring.
Hi Edgar,
Since you have solved this issue, you can close this unless you have any further questions.
Sincerely,
IoTGirl
from remote-wiring.
Related Issues (20)
- "AnalogWrite" with incremental delay after using "sendSysex" HOT 3
- CPU core is fully utilized after calling Firmate.begin() HOT 1
- Xamarin Support HOT 1
- Multiple Arduinos (RemoteDevices) HOT 2
- Arduino Mega not working with WRAE HOT 5
- Win 10 suppport HOT 1
- remote-wiring in not compatible with Arduino Mega HOT 2
- RfcommDeviceService null exception HOT 1
- Could not install package 'Windows-Remote-Arduino 1.4.0 HOT 4
- Analog Write Doesn't work in v1.4 HOT 2
- Raspberry PI 3 HOT 1
- DHT11 + Arduino UNO + Raspberry pi 3 + Win10iotCore HOT 1
- Code issue
- UsbSerial apparently doesn't connect to my Arduino Uno HOT 1
- c++/winrt support? HOT 1
- Microsoft.Maker.Serial is empty HOT 1
- StringMessageReceived event not always firing HOT 2
- IS this working forVIsual Studio HOT 1
- Bluetooth problem between Arduino device and laptop. HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from remote-wiring.