Voting resources, early voting, and poll worker information - VOTE. ... Adafruit is open and shipping.
0

Setting Graph minimum to something other than 0
Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.

Re: Setting Graph minimum to something other than 0

by V2man on Sat Feb 22, 2020 8:02 pm

@ 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 57 times



Code: Select all | TOGGLE FULL SIZE
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)
})

V2man
 
Posts: 704
Joined: Mon Dec 03, 2018 12:38 am

Please be positive and constructive with your questions and comments.