Still unable to display tenths of a second with the monk maker´s 7-Segment display for the Microbit…any ideas ?
I used the following example script and tried to modify it, but unluckily it is not possible to display less than 170 miliseconds.
The script :
let n = 0
serial.redirect(
SerialPin.P0,
SerialPin.P16,
BaudRate.BaudRate9600
)
basic.pause(100)
n = 100
for (let count = 0; count <= n; count++) {
serial.writeString(" “)
serial.writeNumber(n - count)
serial.writeString(”,")
basic.pause(170)
}
serial.writeString("/done")
basic.forever(() => {
Is it maybe the basic.pause(170) line? That is 170ms right?
Just for the record, I haven’t touched my Micro-Bit in ages and don’t have that display.
And can’t make heads nor tales of what that code does. Thats just me though so the above is just a best guess. ;)
Do you have a link to the original unmodified code?
If you put your code between 3 ` and another ``` at the end it will retain the original code indents etc. Its effectively code tags. On my keyboard its the key under the esc with the ~ on it.
What I do is put ``` on a line.
Then under it clip and past my code right from the python editor
Then put three more `` at the end on thier own line. If you do it right you don’t see the ` 's
Its actually hard to post how to do it without it actually doing the code tag. Thats why there are only two in the above line. If I put three they disappear. and my text shows up as code.
import os
import time, datetime
import bme680
import ledshim
from sense_hat import SenseHat, ACTION_PRESSED, ACTION_HELD, ACTION_RELEASED
sense = SenseHat()
sense.set_rotation(180)
sense.set_imu_config(False, False, False)
sense.low_light = True
ledshim.set_brightness(0.4)
def ledtemp():
if sensor.get_sensor_data():
t = sensor.data.temperature
t = round(t)
if t > 28: # Realy Hot
set_multiple_pixels(range(0,27), 255, 0, 0) # Red
set_multiple_pixels(range(27,28), 255,140, 0) # Orange
M = (t - 56) * (-1)
# R R R R R R R R R R R R R R R R R R R R R R R R R R R O
elif t > 0 and t <= 28: # Main
set_multiple_pixels(range(0,3), 255, 140, 0) # Orange
set_multiple_pixels(range(3,16), 0, 255, 0) # Green
set_multiple_pixels(range(16,28), 255, 255, 0) # Yellow
M = (28 - t)
# O O O G G G G G G G G G G G G G Y Y Y Y Y Y Y Y Y Y Y Y
elif t <= 0 and t >= -27: # Cold
ledshim.set_all(0, 0, 255) # Blue
M = (t * (-1))
# B B B B B B B B B B B B B B B B B B B B B B B B B B B B
elif t < -27: # Really cold
set_multiple_pixels(range(0,3), 255, 255, 255) # Blue
set_multiple_pixels(range(3,28), 0, 255, 255) # Aqua
M = ((28 + t) * (-1))
# B B B A A A A A A A A A A A A A A A A A A A A A A A A A
…telling me how to use this WYSIWYG Editor would not bring us closer to a possible solutio the still existing problem…btw…the script i filled in is almost the genuine one from the makecode, simply not in blocks, but the java version…
It was meant to be a by the way type of post. Python is really fussy about indents, and thats what is usually lost when code is posted without code tags, thats all. I didn’t mean to distract from the real issue.
I have next to no experience with make code. It was an exercise in futility for me trying make any sense out of it. I had wrongly assumed you were using micro python, my bad. Sorry about that. =(
I use the MU editor with my Micro Bits and code in micro python. Only because thats what I use with my Raspberry Pi’s.