light sensor gadgeteer project #2. step #1 create a new gadgeteer project named: sensorgadgeteerapp...

Post on 02-Jan-2016

215 Views

Category:

Documents

0 Downloads

Preview:

Click to see full reader

TRANSCRIPT

LIGHT SENSOR GADGETEER PROJECT #2

2

Step #1• Create a new Gadgeteer project named:

• SensorGadgeteerApp

• Add• A red power module (USBClientSP)• A Light Sensor• A •LED Strip Module• Display N18 Module• Click - Connect the modules

• Physically connect modules as displayed in Visual C# Express

3

Step #2• Output light sensor values to the Visual C# Express

output so that you see the changes as you hide the light sensor in your hands, hold it up to your monitor, etc.

• Copy your code from the potentiometer assignment to this assignment.

• Update it to base the LED output on the amount of light that the light sensor detects.

4

Step #3• Now add your potentiometer to your project as well.• Update your code so that the potentiometer knob will set a “target light” value, this should be a value between 0

and 100 in steps of 10 (i.e. 0, 10, 20, 30, 40, …, 100) – output this value to the Visual C# Express output window only one time when it changes.

• Update your code so that anytime the light sensor value goes above or below the “target light” value a message is output to the console (exactly one message each time the target transitions above or below the target).

Example output in red:Target Light = 40

(you turn knob up)Target Light = 50

(you put sensor near monitor)Light Sensor Above Target (53.5513)

(even though light increases only 1 message – you hide sensor in your hands)Light Sensor Below Target (48.4114)

(even though light decreases only 1 message – you turn the knob down)Target Light = 40Light Sensor Above Target (48.4114)

(even though you didn’t move the light it is now above the target rather than below it so a message prints)

Raise your hand to get signed off for “Light Sensor Part 1”

5

Step #4• Add code to put the output to the Display N18 Light

sensor values.

• Format for 2 decimal places• You choose the color• Format with the NinaB font

6

Adding a Font Resourcefont myfont = Resources.GetFont(Resources.FontResources.NinaB)

for example:

display_N182.SimpleGraphics.DisplayText("Target Value = " + (int)target, myfont, GT.Color.Blue, 1, 1)

---or ---:

display_N182.SimpleGraphics.DisplayText("Target Value = " + (int)target, Resources.GetFont(Resources.FontResources.NinaB), GT.Color.Blue, 1, 1)

top related