Skip to content

Tutorial video shows invalid code (lightbulb no longer has brightness) #492

Open
@henrygab

Description

@henrygab

Describe the bug
Users following the tutorial video are instructed to create non-compiling code.
This will block users within the target audience.

To Reproduce

  1. In browser, load https://github.com/microsoft/devicescript
  2. Scroll down to embedded video.
  3. Follow along in VSCode with video until ~1m56s, where video instructs to run the program under the debugger.

Expected behavior
Example / tutorial code is correct -- it must compile and execute.
The importance of having correct sample code cannot be overstated.

Additional context
As this is a video, it is not possible to provide a simple PR.

Problematic code:

import * as ds from "@devicescript/core"

const lightbulb = new ds.LightBulb();
setInterval(async() => {
    const brightness = await lightbulb.brightness.read();
    await lightbulb.brightness.write(brightness > 0 ? 0 : 1);
}, 1000) 

Likely correct code:

import * as ds from "@devicescript/core"

const lightbulb = new ds.LightBulb();
setInterval(async() => {
    // intensity is defined as a number between 0 and 0xFFFF
    const intensity = await lightbulb.intensity.read();
    console.log("intensity: ", intensity);
    if (intensity > 0) {
        await lightbulb.off();
    } else {
        await lightbulb.on();
    }
}, 1000) 

Metadata

Metadata

Assignees

Labels

bugSomething isn't workingdocumentationImprovements or additions to documentation

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions