Presentation is loading. Please wait.

Presentation is loading. Please wait.

FIRST GADGETEER PROJECT. Where are you? Making a VS project Parts of a C# program Basics of C# syntax Debugging in VS Questions? 2.

Similar presentations


Presentation on theme: "FIRST GADGETEER PROJECT. Where are you? Making a VS project Parts of a C# program Basics of C# syntax Debugging in VS Questions? 2."— Presentation transcript:

1 FIRST GADGETEER PROJECT

2 Where are you? Making a VS project Parts of a C# program Basics of C# syntax Debugging in VS Questions? 2

3 Gadgeteer Assignments Each of you will be assigned a kit. You are responsible for that kit. Make sure all parts are there Make sure kit is returned to appropriate numeric order in storage Missing parts or kits will be assessed as a fine. Checking out kits: By seating order at the beginning of lab. Can not just get them Checking in kits: By seating order – at the end of lab. Need to maintain numeric order Need a lab supervisior 3

4 Creating a Gadgeteer Project Start with ‘New Project …’ Select the Gadgeteer template Name it ‘’FirstGadgeteerApp’ ‘OK’ 4

5 Select a Mainboard: FEZCeberus 5

6 This brings up ‘the wizard’ 6

7 Important Points Get modules from the toolbox You always need a (red) power module Right Click -> Connect all modules Note the connections and names of the modules 7

8 Wizard ready to generate code 8

9 Step #1 Create a Gadgeteer project named: FirstGadgeteerApp Add A red power module (USB Client SP Module) A Potentiometer (aka the Knob) A LED Strip Module Right Click - Connect the modules Raise your hand when you are done or if you have a problem 9

10 PHYSICALLY CONNECTING UP THE GADGETEER MODULES 10

11 Solution Explorer 11

12 Connecting up the Gadgeteer Connect to the same connectors that you used in the wizard. Forgot what connectors you used? 12

13 Step #2 Connect the knob, LED Strip Module, and USBClient modules (In the right places) The connectors are ‘keyed’ so they will only go in the right way Don’t force anything Connect the USB cable to the red module and to your machine Raise you hand when you are done 13

14 ADDING SOME CODE 14

15 Step 3 – Adding the code void ProgramStarted() { double percent; // this variable holds the output from the potentiometer. This ia a value between 0 and 1 int intensity; // this variable holds the level of the intensity that the led will be set to. This is a value between 0 and 255 Debug.Print("Program Started"); while (true) // this loop goes on forever since the condition is always true { percent = potentiometer.ReadPotentiometerPercentage(); // read the current potentiometer value into the variable intensity = (int)(percent * 255); // convert the percentage ( double 0-1) to intensity (integer 0-255) Debug.Print("Integer = " + intensity.ToString()); // write the intensity that we are setting to the output window for comparison System.Threading.Thread.Sleep(50); //slow the loop down a bit by waiting 50 mS between iterations } 15

16 Important Points in Adding Code IntelliSense – Use the ‘Tab’ key to let it do the typing. Use drop down to see\use: Properties Methods events If needed, most not. Replace the ‘Not Implemented’ exception in the event handler ‘Exception’ == Error event and message 16

17 Step #3 Add the code to your application Use IntelliSense Do you have any Syntax errors? Fix them Build Solution Build Succeeded? Raise your hand when you are done 17

18 DEPLOYING YOUR APPLICATION 18

19 Step #4 Deploying your Application Your device is connected to the USB port on your laptop Hit ‘F5’ or ‘Debug->StartDebugging Immediate Window shows ‘Program Started’ This may take a bit – the program is rebuilt, sent to the device, and the device is restarted. To clear program: Press the button on your device to reset (only do to clear for a new program). 19

20 Important Points F5 to deploy Watch the build status Lots of output you don’t need to worry about in the Immediate window – just the last bit Your application is running on the micro processor on the mainboard 20

21 Exercise 1 - See Knobs values in output window Deploy and test your app. Raise you hand when you have change numbers of the knob’s value in the console. Raise your hand if you get an error 21

22 Exercise 2 – Light the Led Strip in Order Use conditional statements and the potentiometer values to light the led strip lights in order from 0 to 7. When complete the turning the knob should turn off and on the lights on the led strip. 22


Download ppt "FIRST GADGETEER PROJECT. Where are you? Making a VS project Parts of a C# program Basics of C# syntax Debugging in VS Questions? 2."

Similar presentations


Ads by Google