Setting Graph minimum to something other than 0

Microsoft's MakeCode platform for easy blocks-style programming

Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.
User avatar
V2man
 
Posts: 704
Joined: Mon Dec 03, 2018 12:38 am

Re: Setting Graph minimum to something other than 0

Post by V2man »

@ Teedee1
This code works on CPX. It uses the graph block to plot temperature Centigrade to the onboard neopixels.
You have to define the the maximum value of the variable, np in the graph block. In my previous attempt I did not do that!
This code works on CPX using Microsoft Makecode or Maker Makecode. It does not work on a CPB using Maker Makecode.
CPX-T20t30-With-Graph.JPG
CPX-T20t30-With-Graph.JPG (57.3 KiB) Viewed 179 times

Code: Select all

let np = 0
let T = 0
let Tmin = 20
let Tmax = 30
forever(function () {
    T = input.temperature(TemperatureUnit.Celsius)
    np = Math.map(T, Tmin, Tmax, 0, light.onboardStrip().length() - 1)
    light.graph(np, light.onboardStrip().length() - 1)
    console.log(np)
    pause(100)
})

Locked
Please be positive and constructive with your questions and comments.

Return to “MakeCode”