Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Threading;
- using Microsoft.SPOT;
- using Microsoft.SPOT.Presentation;
- using Microsoft.SPOT.Presentation.Controls;
- using Microsoft.SPOT.Presentation.Media;
- using Microsoft.SPOT.Touch;
- using Gadgeteer.Networking;
- using GT = Gadgeteer;
- using GTM = Gadgeteer.Modules;
- using Gadgeteer.Modules.GHIElectronics;
- namespace Gadgeteer_Servo_Test_02
- {
- public partial class Program
- {
- GT.Timer timer = new GT.Timer(1000, GT.Timer.BehaviorType.RunContinuously);
- GT.Interfaces.PWMOutput servo;
- Boolean sway = true;
- // This method is run when the mainboard is powered up or reset.
- void ProgramStarted()
- {
- timer.Tick += new GT.Timer.TickEventHandler(timer_Tick);
- timer.Start();
- GT.Socket socket = GT.Socket.GetSocket(11, true, null, null);
- servo = new GT.Interfaces.PWMOutput(socket, GT.Socket.Pin.Seven, extender);
- //GT.Interfaces.PWMOutput servo = extender.SetupPWMOutput(GT.Socket.Pin.Seven);
- //servo = extender.SetupPWMOutput(GT.Socket.Pin.Seven);
- //servo.Active = true;
- // print something so we know we have started
- Debug.Print("Program Started");
- }
- void timer_Tick(GT.Timer timer)
- {
- //GetXmlFromWeb();
- if (sway)
- {
- printServoDisplay(0, Convert.ToUInt32("75"));
- sway = false;
- }
- else {
- printServoDisplay(0, Convert.ToUInt32("150"));
- sway = true;
- }
- }
- void printServoDisplay(int lineNumber, uint displaySetting)
- {
- //uint xPos = 0;
- //oledDisplay.SimpleGraphics.DisplayText(displayMessage, Resources.GetFont(Resources.FontResources.NinaB), GT.Color.White, xPos, lineNumber*12);
- switch (lineNumber)
- {
- case 0:
- // 750,000 to 2,250,000 mid point is 1,500,000
- //servo.SetPulse(20 * 1000 * 1000, (displaySetting - 10) * 100 * 1000);
- servo.SetPulse(20 * 1000 * 1000, displaySetting * 10 * 1000);
- Debug.Print("displaySetting " + displaySetting);
- break;
- default:
- break;
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment