MicroBit Project #06 for INF 294

Project description:

Using code for MicroBit built in C/C++, display current temperature in Celsius when button A is clicked and in Fahrenheit when button B is clicked.

I used the MakeCode editor to test the algorithm in the MicroBit framework, then wrote the code in the mbed compiler to create the HEX file and test the program.

/https:/os.mbed.com/media/uploads/tsfarber/basic_logic_for_project_6.png

Following is the JavaScript that corresponds to the blocks in makeCode. This serves as a pretty good algorithm when the image of the blocks cannot be viewed.

input.onButtonPressed(Button.A, function () {
    basic.showNumber(input.temperature())
    basic.pause(200)
    basic.showString("C")
    basic.pause(1000)
    basic.clearScreen()
})
input.onButtonPressed(Button.B, function () {
    basic.showNumber(Math.round(input.temperature() * 1.8 + 32))
    basic.pause(200)
    basic.showString("F")
    basic.pause(1000)
    basic.clearScreen()
})

https://os.mbed.com/users/tsfarber/code/microbit-6-tempByButtons/


Please log in to post comments.