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_Beep_01
- {
- public partial class Program
- {
- GT.Timer timer = new GT.Timer(1000, GT.Timer.BehaviorType.RunContinuously);
- GT.Interfaces.PWMOutput beeper;
- uint highNote = 1000;
- uint lowNote = 100;
- double noteRange;
- // 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);
- beeper = new GT.Interfaces.PWMOutput(socket, GT.Socket.Pin.Seven, eBlockExpansion);
- noteRange = highNote - lowNote;
- // print something so we know we have started
- Debug.Print("Program Started");
- }
- void timer_Tick(GT.Timer timer)
- {
- printSound(20, lowNote + (UInt32)(joystick.GetJoystickPostion().X * noteRange));
- }
- void printSound(uint soundLength, uint soundSetting)
- {
- beeper.SetPulse(soundLength * 1000 * 1000, soundSetting * 10 * 1000);
- Debug.Print("soundSetting " + soundSetting);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment