Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Threading;
- using Microsoft.SPOT;
- using Microsoft.SPOT.Hardware;
- namespace MFConsoleApplication3
- {
- public class Program
- {
- public enum AdcChannel { ADC1, ADC2, ADC3, ADC4 };
- public static void Main()
- {
- Debug.Print(
- Resources.GetString(Resources.StringResources.String1));
- //Week 2 Lab a
- SPI.Configuration SpiConf = new SPI.Configuration(Cpu.Pin.GPIO_Pin1, false, 1, 1, true, false, 16000, SPI.SPI_module.SPI1);
- SPI Spi = new SPI(SpiConf);
- ushort[] writeBuffer = new ushort[1];
- ushort[] readBuffer = new ushort[1];
- writeBuffer[0] = (ushort)AdcChannel.ADC2;
- readBuffer[0] = 0;
- while (true)
- {
- Spi.WriteRead(writeBuffer, readBuffer);
- ushort raw = readBuffer[0];
- float f = raw / 4096.0f * 5;
- Debug.Print("Read: " + f.ToString());
- Thread.Sleep(1000);
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement