Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Plot of temperature using onboard neopixels does not work on CPB board #296

Open
V2man opened this issue Feb 22, 2020 · 0 comments
Open

Comments

@V2man
Copy link

V2man commented Feb 22, 2020

Temperature does not display correctly on CPB. Works on CPX board. The code below works with Microsoft Makecode and Maker Makecode with CPX board. Try it on Maker Makecode with hardware set to CPB board to recreate problem. With CPB board all neopixels light up for about 3 seconds then go off after reset button is pushed once. May not be reading input.temperature at all. With CPX board Neopixels turn on in clockwise direction with increase temperature. Temperature Farenheit is constrained between 60 and 80 degrees. The code does not work in Maker Makecode with CPB! It does not use graph block.
`/**

  • CP-Temperature-CW
  • Example of using neopixels to measure temperature rise in
  • clockwise direction on CPX/CPB board.
    */
    let np = 0
    let n = 0
    let Tc = 0
    let T = 0
    light.onboardStrip().setBrightness(20)
    let Tmin = 60
    let Tmax = 80
    forever(function () {
    T = input.temperature(TemperatureUnit.Fahrenheit)
    Tc = Math.constrain(T, Tmin, Tmax)
    n = Math.map(Tc, Tmin, Tmax, 0, light.onboardStrip().length() - 1)
    if (T < Tmin) {
    light.onboardStrip().setAll(0x000000)
    } else {
    for (let index = 0; index <= light.onboardStrip().length() - 1; index++) {
    np = light.onboardStrip().length() - 1 - index
    if (index <= n) {
    light.onboardStrip().setPixelColor(np, light.hsv(18 * np, 255, 255))
    } else {
    light.onboardStrip().setPixelColor(np, 0x000000)
    }
    }
    }
    pause(1000)
    }) `

Here's another example that uses the graph block to plot temperature on the onboard neopixels.
It works on CPX but not on CPB. All the onboard neopixels on the CPB board are on.

CPX-T20t30-With-Graph.txt
CPX-T20t30-With-Graph

@V2man V2man changed the title Temperature displayed on CPX/CPB on board neopixels Temperature displayed on CPX/CPB with board neopixels Feb 22, 2020
@V2man V2man changed the title Temperature displayed on CPX/CPB with board neopixels Temperature displayed on CPX/CPB with onboard neopixels Feb 22, 2020
@V2man V2man changed the title Temperature displayed on CPX/CPB with onboard neopixels Plot of temperature using onboard neopixels does not work on CPB board Feb 22, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant